Closed MadsJensen closed 7 years ago
ping @agramfort I do need this right now. What's the cleanest way to bypass the source space lookup?
@agramfort can't we simply create a fake label_veridx
list inside _gen_extract_label_time_course
or simply move the extraction to another private function we dispatch without the source space lookups in case the source_estimate instance method is called from a sub-stc?
we should just check that the vertices required are in the source space. And raise an exception otherwise.
@agramfort it's more complicated. The sign flipping functions require full source spaces and there are a couple of additional checks for source spaces ...
the sign flip should only require the normals of the label of interest. But I agree it might be a bit tricky...
@agramfort I see. Will look into it somewhen else ...
Any plans on getting this running? Any alternate route to get the label time series?
please share a code snippet using sample data that creates the issue
Do a recon-all on colin27 t1 image - http://www.bic.mni.mcgill.ca/ServicesAtlases/Colin27 then do
src = mne.setup_source_space('colin27', spacing='oct6', subjects_dir=<subject-dir>)
The following will not work if you run mne_watrershed_bem to get the surf files.
model = mne.make_bem_model('colin27',subjects_dir=<subject-dir>)
RuntimeError: Surface inner skull is not completely inside surface outer skull.
So just use the surf files from spm/canonical folder which is based on colin27. This is where the problem occurs.
Then do
bem_sol = mne.make_bem_solution(model)
fwd = mne.make_forward_solution(info, trans, src, bem_sol)
What happens is that when you are making the forward model some sources are removed because they are outside the inner skull surface. This makes the stc estimates incompatible with the source space. I am thinking that this problem may be resolved if you can get the mne_wartershed_bem to work on the colin27 T1 image such that mne.make_bem_model() doesn't return the error.
@ImmanuelSamuel removing the points is the correct thing. What is the problem? Can you show the error?
The error occurs when extracting labels time course. The function checks if the number of source estimates are the same as the number of sources in the source space. Since they are different because of the dropped sources while calculating the fwd solution there is an error that says "stc and source space are incompatible"
I thought that the make source space function used all the surfaces generated by recon-all and then generated the sources which would mean that most sources should be within the inner skull surface. I am having about 750 sources being removed of the 4096. That is a lot.
Two things:
Ah I see. I initially assumed that the algo only creates sources inside the brain in the first place and then removes the points outside that might occur due to some error. From what you are saying I am thinking the sources are first generated across the entire head mask and then points outside the brain mask is then removed.
I mentioned the error in my previous comment.
ValueError: stc not compatible with source space
in _gen_extract_label_time_course(stcs, labels, src, mode, allow_empty, verbose)
There is another error that occurs when I run make _bem_model on the colin27 recon-all folder
RuntimeError: Surface inner skull is not completely inside surface outer skull
Also if removing the sources is done typically as you mentioned. Why is there a check in _gen_extract_label_time_course.
The two numbers must be the same for the check to pass
Yeah, first you define your source space, which is based off the lh.white/rh.white. These are then adjusted when you calculate the forward model.
hmmm. yeah, it sounds like that function might be better off asking for the fwd model in that script, and then pull src from withing fwd solution file, so people don't run into that error.
I have only briefly looked into the code. Need this to work soon. Will open a PR if I can somehow get this to work. Just getting better at python (I am from the matlab world). Any ideas on the other error?
There is another error that occurs when I run make _bem_model on the colin27 recon-all folder RuntimeError: Surface inner skull is not completely inside surface outer skull
Use the BEM surfaces from the spm cannonical directory, don't generate your own. I did a lot of work to get it to work on that. Use them, it will save you time.
Yeah I already got SPM surfaces working. I was just thinking that if I have a group of subjects I can then make a surface of the average. If you have time to spare please give me a high-level overview of the things you did to get it working. I might try it later. Thanks.
huh? I don't understand?
You mentioned that you did a lot of work to get the colin27 surfaces. Can you briefly mention the steps you did to get it?
It was a lot of tweaking and using lots of different freesurfer tools. What are you trying to do?
Say I have a group of subjects' T1. If I can make a surface for the non-linear averaged T1 for the group wouldn't that make the source estimates better?
If you have the individual's MRIs you should use them.
If you mean you have a group of other people's MRIs and want to use them: No, it won't be better, there are costs to averaging and you get strange shapes, which cause their own problems. If you want proof, load Colin's pial surface in Freeview and compare it to the pial surface of fsaverage. You don't want those effects. hth d
Ah I see thanks for the explanation. Very insightful.
Make extract_label_time_course compatible with stcs without a full source space.
E.g.parsing label to apply_inverse_raw will result in stc with a not full source space making it hard to extract source time courses as extract_label_time_course will fail.
Goal. redo extract_label_time_course to accept stc without a full source space.
@agramfort