Repository navigation
Fix check compensation on ica with EEG - #5270
Conversation
|
I think one of them has EEG, maybe this one? |
|
I can confirm that the example code snippet from #5265 works with these changes. |
larsoner
left a comment
There was a problem hiding this comment.
Looks reasonable to me other than a few minor issues
| ica.get_sources(inst) | ||
|
|
||
|
|
||
|
|
There was a problem hiding this comment.
| # test apply and get_sources | ||
| for inst in [raw, epochs, evoked]: | ||
| ica.apply(inst) | ||
| ica.get_sources(inst) |
There was a problem hiding this comment.
How much time does this test add? Looks like it should be "not much" because the max_iter is so small, right?
There was a problem hiding this comment.
the entire test on my laptop takes ~8 seconds
$ pytest mne/preprocessing/tests/test_ica.py::test_ica_eeg -x --verbose
============ 1 passed, 4 warnings in 8.20 seconds ============
There was a problem hiding this comment.
That is a bit much, is it possible to reduce it by picking channels or cropping in time?
There was a problem hiding this comment.
best I can do is ...
====== 1 passed in 5.19 seconds =======
| from .io.pick import pick_channels, pick_info | ||
| from .io.compensator import get_current_comp | ||
|
|
||
| if None in [inst.info, inst2.info]: |
There was a problem hiding this comment.
When do we have inst.info is None?
There was a problem hiding this comment.
ica objects have a info is None until they are fit.
the check is needed so this part of the tests pass:
mne-python/mne/preprocessing/tests/test_ica.py
Lines 250 to 252 in 68084cc
An alternative would be to move the fit checking out the private _transform_* methods but that would likely be two checks as I think it makes sense to have it in the private method aswell since they are used in a number of places.
| eeglab_fname = op.join(test_base_dir, 'EEGLAB', 'test_raw.set') | ||
| eeglab_montage = op.join(test_base_dir, 'EEGLAB', 'test_chans.locs') | ||
|
|
||
| ctf_fname2 = op.join(test_base_dir, 'CTF', 'catch-alp-good-f.ds') |
There was a problem hiding this comment.
did this indeed have EEG channels?
There was a problem hiding this comment.
yup. at somepoint I'm going to go through the ctf data and see what it actually is but thats for another day :)
Codecov Report
@@ Coverage Diff @@
## master #5270 +/- ##
==========================================
+ Coverage 88.18% 88.22% +0.03%
==========================================
Files 358 358
Lines 65898 66187 +289
Branches 11207 11242 +35
==========================================
+ Hits 58114 58393 +279
- Misses 4975 4976 +1
- Partials 2809 2818 +9 |
| method=method) | ||
| with warnings.catch_warnings(record=True): # convergence | ||
| ica.fit(raw) | ||
| ica.fit(inst) |
|
+1 for MRG @larsoner merge if ok with you. |
|
Thanks @bloyl |
* Add test re: issue mne-tools#5265 * Fix * Add ctf test with apply compensation channels * Appease travis * Shorten test * Fix Flake
closes #5265.
The problem arises because the ica object inherits the
infoof the object used to fit it with supplied 'picks' applied. however to avoid making a copy of time domain data the picks are never applied to the supplied object. This causes a discrepancy between the channels inica.infoandraw.info(orepoch.info) and the check fails.I modified the
_check_compensation_gradeto accept channel names so the infos of both objects are mapped to the same channels before computingcompensation_grade.one case not tested is a ctf/eeg test where compensation can be applied. Are there any datasets like that which we could include in the test data?