-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
[MRG] convert surface using python. #3273
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
mne/bem.py
Outdated
| trans[3][3] = 1. | ||
| trans = Transform(FIFF.FIFFV_COORD_UNKNOWN, FIFF.FIFFV_COORD_MRI, trans) | ||
| surf_out = transform_surface_to(surf_in, FIFF.FIFFV_COORD_MRI, trans) | ||
| write_surface(fname_out, surf_out['rr'], surf_out['tris']) |
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.
Here I saved 'tris', but there is also 'use_tris'. What's the difference?
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.
can you base the changes on the C code?
This is basically a copy paste of the c-code apart from the calls to the existing python functions. I suppose they do the same thing.
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.
Okay cool, that should work (especially if you unit-test against files processed by both Python and C)
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.
Now that I look again, I don't think this file should actually write out the result, just return it. Better separation of functionality to have the write_surface called afterward.
Current coverage is 77.80%@@ master #3273 diff @@
==========================================
Files 335 335
Lines 57322 57440 +118
Methods 0 0
Messages 0 0
Branches 8715 8733 +18
==========================================
- Hits 49567 44692 -4875
- Misses 5132 10634 +5502
+ Partials 2623 2114 -509
|
mne/bem.py
Outdated
| from .surface import _read_surface_geom, write_surface | ||
| header = _get_mgz_header(T1_mgz) | ||
| surf_in = _read_surface_geom(fname_in) | ||
| surf_in['coord_frame'] = FIFF.FIFFV_COORD_MRI |
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 this is FIFFV_COORD_UNKNOWN in the c-code, but it throws an error in python.
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 think this is actually more correct as it is in MRI coords anyway (right?)
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.
actually looking below I think it isn't MRI coords...
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.e. it shuold be FIFFV_COORD_UNKNOWN and there must be some bug below
|
how does the output compare with the output of the C code? |
|
The results look similar, but I'm not sure if it's even transforming anything for the data I have. Trying to set up a proper c-environment now so I can isolate stuff better. |
|
Okay, Now that I've actually been able to debug the c-code, I realize that most of this is unnecessary. What confuses me now is the |
|
@mshamalainen any objection? idea?
on my side whatever works :)
|
|
That's fine, we can always add the options later. So long as they are not
the defaults we should be fine.
|
|
So what do we want to do with metadata in nipy/nibabel#456? Maybe just add a |
|
nipy/nibabel#458
I just took 1h to play...
|
|
Why is mne-python not using nibabel for reading the surfaces? I see the only difference is basically |
|
Avoiding a dependency IIRC |
|
yes and also when we needed this it was not released in nibabel. I agree
that it should change to avoid to double maintenance
|
mne/surface.py
Outdated
|
|
||
| import numpy as np | ||
| from scipy.sparse import coo_matrix, csr_matrix, eye as speye | ||
| import nibabel as nib |
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.
nest this import we don't want a new hard dependency
|
I noticed that
|
mne/bem.py
Outdated
| Path to SUBJECTS_DIR if it is not set in the environment. | ||
| flash_path : str | None | ||
| Path to the flash images. If None (default), the current folder is | ||
| used. |
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 ended up adding this to reduce the amount of magic with this function.
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.
so not in mri/bem/flash anymore?
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 actually using the current folder before. Now we could default to the correct place, but is mri/bem/flash really the correct folder and not /mri/flash/parameter_maps? I can't find mri/bem/flash anywhere on my 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.
|
Anything you can do to make a test not |
|
|
||
|
|
||
| @ultra_slow_test | ||
| @requires_mne |
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.
yeah :)
|
please set to MRG when comments are addressed. thx @jaeilepp was not that easy in the end ;) |
edd4f12 to
4525e66
Compare
mne/utils.py
Outdated
| 'MNE_SKIP_TESTING_DATASET_TESTS', | ||
| 'MNE_STIM_CHANNEL', | ||
| 'MNE_USE_CUDA', | ||
| 'MNE_TESTING', |
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.
We have others of the form MNE_SKIP_*, so maybe MNE_SKIP_FLASH_CALL or something would be better.
Although in this case, we want the default behavior when running nosetests mne/tests/test_bem.py to skip the FreeSurfer call, since it takes forever. Your current code will still make the call to FreeSurfer by default (although you have made AppVeyor and Travis skip it, developers will still be haunted by the slowness).
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.
The calls to freesurfer here aren't actually that slow. It is the conversion of flash images that took a long time before. Now we have them precomputed.
|
This is also ready for review. |
383d00c to
1723797
Compare
.travis.yml
Outdated
| python -c 'import mne; mne.datasets.testing.data_path(verbose=True)'; | ||
| if [ "${DEPS}" == "full" ]; then | ||
| export FREESURFER_HOME=$(python -c 'import mne; print(mne.datasets.testing.data_path())'); | ||
| export MNE_SKIP_FLASH_CALL=1; |
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.
Is this done for speed, or because Travis and AppVeyor don't have the right command-line utilities to do 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.
Ahh, you replied below:
Yeah, this is to avoid the freesurfer calls.
Can you add a comment somewhere saying that it's done only to avoid a command that isn't available on CIs?
|
thanks @jaeilepp ! |
* 'master' of git://github.com/mne-tools/mne-python: (48 commits) FIX: Flake fix pep8 [MRG] FIX Topographic plotting for KIT-UMD data (mne-tools#3349) QUICKFIX: logging test Error message for simulate evoked. (mne-tools#3372) Warnings for big bems. (mne-tools#3374) Add test for baseline correction. Use apply_baseline in read_evokeds. Makes (None, 0) the default value baseline in apply_baseline. [FIX] Adds apply_baseline to Evoked fix component inds in ica tutorial (mne-tools#3379) FIX: Xdawn with shuffled epochs (mne-tools#3373) FIX consistency: Epochs.load_data() should always return self (mne-tools#3376) MRG: Build relevant examples (mne-tools#3365) [MRG] set vmin, vmax after smoothing in plot_epochs_image (mne-tools#3360) [FIX] Attempt to fix circle. fixing a bg plotting bug for topo plots Modified test and tutorial. [MRG] convert surface using python. (mne-tools#3273) [MRG] raw.plot_psd() with flat channel (mne-tools#3342) ...
Closes #3107
closes #3281
For most parts I had no idea what I was doing, but it seems to give similar results.