-
Notifications
You must be signed in to change notification settings - Fork 1.4k
[MRG][FIX] Fixes to examples #2990
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
hum... what's wrong? |
Yeah. I can also look deeper later, but I was asking if anyone (@Eric89GXL ) has an idea... |
compare for now the entries in the meas info. We have utility function for
this.
|
I'm not sure what the difference would be. You could try converting the files using the C tools and swap in the .fif files for the CTF ones and see if you get the same or different results. |
That looks like a bug. I wonder why it's not caught by the tests. Can you see if the verbose output is similar to what the C code says? CTF data has some skips, and they might not match properly. I probably won't have time to check for a while. |
@@ -149,13 +150,13 @@ def _read_segment_file(self, data, idx, fi, start, stop, cals, mult): | |||
with open(self._filenames[fi], 'rb') as fid: | |||
for bi in range(len(r_lims)): | |||
samp_offset = (bi + trial_start_idx) * si['res4_nsamp'] | |||
n_read = min(si['n_samp'] - samp_offset, si['block_size']) | |||
n_read = min(si['n_samp_tot'] - samp_offset, si['block_size']) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was the bug. It wasn't caught by the tests because on our testing data n_samp
and n_samp_tot
are equal.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no need to update a test?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As I said, our testing data has equal values for these. We should probably add dataset with different values. I wonder if @dengemann or someone else has nice small files.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And I'm not entirely sure this is the correct solution to fix the bug. It almost looks like our python version tries to leave out some samples from the end (see https://github.com/mne-tools/mne-python/blob/master/mne/io/ctf/ctf.py#L214), but at least with our spm_faces dataset this wasn't behaving well. Maybe someone with deeper understanding of CTF format can help.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Both the Python and C versions can omit samples from the end. We do it differently from the C tools to handle a user's use case, see:
I suspect this fix will break that use case, but I'm not sure. We really do need to add some test files to figure it out.
If we are content with the ctf fix, this is ready for review/merge. It can be fixed in another PR if needed. |
I would check against brainstorm reader to make sure we read the correct number of samples and proper values of everything... |
You'll need a rebase since I decreased mem usage in the SPM example |
Now this happens. It might break someone's code, but that means they've been doing it wrong all along. To me it looks like the ctf bug fix here is the right one. Calling with |
Yeah the C code doesn't have an option to ignore to clock IIRC. So now the
raw data looks correct, the example renders properly, and tests pass?
Can you add a test that requires the spm face dataset to catch the
regression? It won't run on Travis but it will on most dev machines.
|
Okay test added. Now it just checks that samples are omitted. For data comparison, the data should be added to the dataset. I believe this is sufficient for now. |
Can we improve sphinx gallery instead of removing those characters? There
are multiple other files that have them as well, and they are convenient to
have. Probably better to open an issue to see if we can deal with it
properly instead of tacking it on here.
|
|
||
# We've already clicked and exported | ||
layout_path = op.join(op.dirname(mne.__file__), 'data', 'image') | ||
layout_path = op.join(op.dirname(__file__), '..', '..', 'mne', 'data', 'image') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you cannot assume the example file is at a fixed place on disk. The previous option is more robust.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It fails on circle. That's why I changed it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the failure? Is there some way to use the location of mne
instead of the location of the example file? It really should be more robust to use the repo-location to find data files from the repo than use the example-location -- people could reasonably just download the example to their Desktop and expect it to work. Maybe we need to add mne.data_path
within the repo that just points to op.join(os.abspath(__file__), 'data')
or so in __init__.py
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suspect that the gif file is not properly installed via our setup.py .... it's a bug. The example should not be changed due to this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good call, it is indeed missing
https://github.com/mne-tools/mne-python/blob/master/setup.py#L106
I agree with @Eric89GXL. the bug should be fixed in sphinx-gallery. Please open an issue there and cc me. thx |
To me allowing special characters sounds like asking for trouble. The doc builds are way too fragile to some specific versions as it is. |
at least raise the issue on sphinx gallery. They are really responsive.
|
UTF8 is pretty standard (and default on Py3k) it should really be
supported. I'd rather not mangle our docstrings if we don't have to
|
@@ -55,15 +59,12 @@ def rescale(data, times, baseline, mode='mean', copy=True, verbose=None): | |||
data_scaled: array | |||
Array of same shape as data after rescaling. | |||
""" | |||
_log_rescale(baseline, mode) | |||
if baseline is None: | |||
return data |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This changes the previous reasonable behavior of the function -- before if copy is True
then it would always return a copy, now it does in some cases and doesn't in others.
Awesome, thanks
|
let me know if we're good here. |
This should fix |
Ready for review. |
|
||
raw = io.Raw(raw_fname % 1) # Take first run | ||
raw = io.read_raw_ctf(raw_fname % 1, preload=True) # Take first run |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You shouldn't need preload=True
, if you do, we have a bug
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(this will increase memory usage substantially)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Whoops. I don't know how that got there. But in any case there is a load_data
on the line below so this seems redundant.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
More importantly, the load_data
happens after the crop
statement, which leads to memory savings
besides LGTM don't forget to update what's new BUG section |
I thought I had found a setting that would work with mayavi figures, but apparently I was wrong. I'll try it on another PR then. |
Great Merge when Travis is happy |
Noticed that with the new SPM datasets the examples are not working. See





plot_spm_faces_datasets
for example.