Skip to content

FIX: Addressing raw reading regression - #429

Merged
agramfort merged 1 commit into
mne-tools:masterfrom
larsoner:raw-read-fix
Feb 4, 2013
Merged

agramfort merged 1 commit into
mne-tools:masterfrom
larsoner:raw-read-fix

Conversation

@larsoner

@larsoner larsoner commented Feb 3, 2013

Copy link
Copy Markdown
Member

@agramfort I was apparently too hasty in one assumption I made about raw reading. Specifically, the line if this['ent'] is None: when reading through raw.rawdirs can happen even if the skip is not being read (!). I had changed this to throw an error in a previous PR, since I thought that should only happen if skip was being read.

The behavior I have it set to now is to wait until it gets a valid tag to choose the dtype (which fixes what would have been a regression before regarding assuming real dtype), and if no valid tags are ever read, it will return an array of zeros of the correct size. I could also have it throw a warning if no valid tags are ever read if we want.

It's a little hard to discern the changes I made since GitHub tracks indentation changes poorly. Basically I 1) indented the reading lines in one more, to only run if the tag is not None (whereas before having it be None would have thrown an error), 2) moved the allocation to a helper function since it is now used in two places (on demand after finding a good tag, or after all tags are found to be invalid), and 3) speeding/cleaning up the calibration lines a tiny bit by moving it outside the loop.

In any case, we don't have a test file with this property, so I can't really add a test for it. And I'm not the sole owner of the data file that I found the error on, so I can't add that to the test suite... but I can at least verify it now works on the file that used to throw an error.

@ghost ghost assigned larsoner Feb 3, 2013
Comment thread mne/fiff/raw.py

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

detail : I prefer the use of one.reshape rather than touching the attributes manually

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You probably know this, but the two methods actually differ in terms of their implications:

http://docs.scipy.org/doc/numpy/reference/generated/numpy.reshape.html
"If you want an error to be raise if the data is copied, you should assign the new shape to the shape attribute of the array."

Numpy actually checks to make sure that the new shape attribute will work in terms of returning a modified view instead of making a copy. That's why I used it here -- if we implement a change in the future in the reading functions that causes a copy to be necessary, it will slow down our code, and we should re-code the change if possible. Thus I see the error as a check on future changes. I figured if we get to that point and it's not possible to do it without a copy, we could then move to .reshape(). Does that make sense?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok you win. Merging.

@agramfort

Copy link
Copy Markdown
Member

LGTM +1 for merge

agramfort added a commit that referenced this pull request Feb 4, 2013
FIX: Addressing raw reading regression
@agramfort
agramfort merged commit 79f3a12 into mne-tools:master Feb 4, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants