-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
[MRG] ENH coreg-GUI: use high-res head shape if available #3383
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/coreg.py
Outdated
| fid_fname = pformat(bem_fname, name='fiducials') | ||
| fid_fname_general = os.path.join(bem_dirname, "{head}-fiducials.fif") | ||
| src_fname = os.path.join(bem_dirname, '{subject}-{spacing}-src.fif') | ||
| high_res_head_fname = os.path.join(subject_dirname, 'surf', 'lh.seghead') |
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.
see what surface is produced by
mne make_scalp_surfaces
it's not the surface that should default to if you assume you ran "mne make_scalp_surfaces"
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.
Typically you should if possible take the high res surface for
coregistration, if it is available. MNE analyze relies on users linking
them correctly ...
On Tue, Jul 5, 2016 at 5:08 PM Alexandre Gramfort notifications@github.com
wrote:
In mne/coreg.py
#3383 (comment):@@ -39,6 +39,7 @@
fid_fname = pformat(bem_fname, name='fiducials')
fid_fname_general = os.path.join(bem_dirname, "{head}-fiducials.fif")
src_fname = os.path.join(bem_dirname, '{subject}-{spacing}-src.fif')
+high_res_head_fname = os.path.join(subject_dirname, 'surf', 'lh.seghead')see what surface is produced by
mne make_scalp_surfaces
it's not the surface that should default to if you assume you ran "mne
make_scalp_surfaces"—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
https://github.com/mne-tools/mne-python/pull/3383/files/f285ec969a9dc99a8fd3fe827184990a3b6ac382#r69591426,
or mute the thread
https://github.com/notifications/unsubscribe/AB0fitjdp-7vywfzwGX6TDZFyDUwSh4kks5qSoGBgaJpZM4JFP8_
.
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.
@agramfort lh.seghead is produced by FreeSurfer's mkheadsurf (the first step of $ mne make_scalp_surfaces) and seems to contain the same information as head-dense-bem.fif (as in np.allclose). My next plan was to generate lh.seghead when it is not present with a call to FreeSurfer. Is there a reason to create an additional file with the same information? If there is a use case for modifying head-dense.fif we could look for head-dense.fif before lh.seghead?
@dengemann that is the intention behind this PR
|
Would we also prefer the high resolution head shape for FSAverage? I don't know the details of how it is computed but it showed up when I pointed the GUI to fsaverage (i.e., the GUI ran |
|
This is just intuition, but I would say no, since it is an average (and a particularly special average at that: I was even surprised mkheadsurf would produce something vaguely head shaped). I think keeping it smooth gives an appropriate amount of play and smoothness for any unrecommended case where someone is using fsaverage, and it is less likely to throw off the ICP alignment via overfitting to a non-individual's brain. my 2 cents |
|
So then I'm wondering how this should be reflected in the GUI. Should we detect an average brain and only show the normal head even though |
aff7b3c to
7bf0268
Compare
|
Is there anything that can tell that a subject is not the genuine subject?, we could just uncheck the box and put a note saying for non-individual MRIs we don't recommend using the high resolution surface (assuming people agree, I haven't tested, it just seems like there is potential for find "strange minima"). |
|
I don't know if there is a general rule, fsaverage could be detected based on its name |
|
what is the reason why the high res head is bad for non individual MRIs?
|
|
Because the two features the high res is most useful for (the ears and nose) are highly variable in their shape (and the ears can have different positions). People can easily overfit or worry about their match based on the fiducials. The advantage of the high res, is that I can fit the points right in the valley between the crus of helix and the tragus (where I digitize) and the nasion. In the case of using an MRI of someone you didn't scan, It isn't important for them to be at the right spot there. What matters most is that the EEG sensors are in the correct position. If someone uses for example the keep nasion option, on a person's data who has an odd shaped nose then, they will be hurting their ability to get a good fit. Again this is intuition, so feel free to ignore |
Current coverage is 86.63%@@ master #3383 diff @@
==========================================
Files 337 337
Lines 58119 58151 +32
Methods 0 0
Messages 0 0
Branches 8861 8867 +6
==========================================
+ Hits 50357 50381 +24
- Misses 5081 5088 +7
- Partials 2681 2682 +1
|
mne/coreg.py
Outdated
| mri = 'T1' | ||
| run_subprocess('source $FREESURFER_HOME/FreeSurferEnv.sh; ' + | ||
| 'mkheadsurf -subjid ' + subject + ' -srcvol ' + mri, | ||
| env=env, shell=True) |
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 don't like this much as it means computation is done by the GUI while we should document how it should be done with mne command. If you don't agree with how the mne command does stuff the fix should be there.
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 have no issue with the mne command, it does the same thing. :)
But what should the GUI do if the high resolution head is not present? Show an error message that asks the user to leave the GUI, run a command for each subject in the command line, and then restart the GUI? I feel like we discussed a similar issue with creating the average subject, where we ended up preferring that the GUI should automatically do a task for the user if it is deterministic...
On Jul 7, 2016, at 5:50 AM, Alexandre Gramfort notifications@github.com wrote:
In mne/coreg.py #3383 (comment):
fs_home)
- env = os.environ.copy()
- env['SUBJECTS_DIR'] = subjects_dir
- env['SUBJECT'] = subject
- env['FREESURFER_HOME'] = fs_home
- env['PATH'] = os.path.join(fs_home, 'bin') + ':' + env['PATH']
- subj_path = os.path.join(subjects_dir, subject)
- if os.path.exists(os.path.join(subj_path, 'mri', 'T1.mgz')):
mri = 'T1.mgz'- else:
mri = 'T1'- run_subprocess('source $FREESURFER_HOME/FreeSurferEnv.sh; ' +
'mkheadsurf -subjid ' + subject + ' -srcvol ' + mri, I don't like this much as it means computation is done by the GUI while we should document how it should be done with mne command. If you don't agree with how the mne command does stuff the fix should be there.env=env, shell=True)—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub https://github.com/mne-tools/mne-python/pull/3383/files/5a207026f41c5c979f0480cc3294ceac3ef875fc#r69880037, or mute the thread https://github.com/notifications/unsubscribe/AAI5a9xUc4p948qh_gFaJxR5PSicOkNBks5qTMvKgaJpZM4JFP8_.
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.
Show an error message that asks the user to leave the GUI, run a command
for each subject in the command line,
yes
my 2c
279775b to
c3141a3
Compare
958ae0c to
c95b665
Compare
c95b665 to
1da57a2
Compare
(Not needed anymore because prepare_bem_model is now done with Python code)
|
@christianbrodbeck what do you think the right approach is for the average? I think the image you provided of fsaverage is a good example of my argument, the fiducials aren't lined up with a good point on the ear or the nasion, and I think that is a good thing (because of my earlier argument) |
|
I updated the screen shot at the top of the PR (see the check box in the top left field). @dgwakeman I don't like the idea of ignoring the checkbox for fsaverage and prevent users even if they intentionally want to display the high res head. I wonder whether there should be a second checkbox after the "high res head" button that says "use standard for fsaverage"? Although there is the question of whether fsaverage is actually the brain that the majority of average brain users use (if we use the name to detect it and if there is not a method to detect average brains in general). Otherwise I think it should just be documented that for fsaverage the high res head is less appropriate...? |
|
Sounds reasonable, I guess the other key would be to have that in the example for coregistering/scaling |
|
I suppose |
|
Separate PR would be better |
| "mne_prepare_bem_model tool will fail. Please install " | ||
| "MNE.") | ||
| warning(None, err, "MNE_ROOT Not Set") | ||
|
|
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 left over from #3332
|
This is ready from my end unless there are suggestions for modifying the functionality. Currently this adds a checkbox for using high res head shapes (see first post, top left of the GUI), and will just display an error message if the high res head shape can not be found. |
|
@christianbrodbeck I think @jona-sassenhagen had a few issues when trying to use the GUI, I assume those should be separate issues rather than fix them in this PR? |
|
Yes I think #3432 is separate, what were other issues? |
|
Not sure... maybe that was the only one. Didn't realize there was an issue open already. This LGTM, @jona-sassenhagen since you're in coreg mode can you give it a try? |
|
Not specific to this PR, but on my Mac, I get ... |
|
@jona-sassenhagen you should use QT backend, run |
However, that also happens on master. |
|
Hm that might be due to our catching the |
|
Although on conda you could create a virtualenv... |
|
Maybe not really worth investigating until I have a working pyqt. |
|
For me something like this works:
|
|
That's how I've set up the env I'm using right now (I'm not using py2 usually). The problem is a libpng conflict: gpilab/framework#3 I could in principle set up different versions of either dep, but that'd be effort ... |
|
Should we try to avoid silencing those import errors? |
Is this still an open question? What import errors do you mean? |
|
@Eric89GXL I meant the pattern, because for people that don't have Mayavi installed this hides the true reason the GUI fails, Instead displaying something like |
|
Yeah that sounds reasonable to me. Nest all mayavi and related imports if necessary |
|
Ok I will do that once the other GUI PRs are merged to avoid rebasing |
|
Which PR do you mean? #3463 is the only one marked MRG but currently needs a rebase |
|
@Eric89GXL Yes I meant #3463 and the current one this discussion is in. |
|
Okay agreed, let's fix the other issues from @jona-sassenhagen in another PR then |
|
Thanks @christianbrodbeck |



Uh oh!
There was an error while loading. Please reload this page.