MRG, ENH: Add volumetric atlas support#7639
Conversation
Codecov Report
@@ Coverage Diff @@
## master #7639 +/- ##
==========================================
+ Coverage 90.31% 90.35% +0.04%
==========================================
Files 455 455
Lines 83999 84427 +428
Branches 13302 13370 +68
==========================================
+ Hits 75860 76285 +425
- Misses 5270 5272 +2
- Partials 2869 2870 +1 |
|
Okay @agramfort this is ready for review/merge as well. Might be good for you to take a first pass, then once we're happy with the API ask others who would be interested to look |
|
The new tutorial image showing |
|
I was trying to read the volume stc which were computed previously using mne.read_source_estimate in mne.v0.21.dev0. |
|
@poojaprabhu9 I pushed a fix that should fix that bug hopefully |
|
I tried the same by installing mne.v0.21.dev0. |
|
you need to use this branch. Try:
pip install -U https://github.com/larsoner/mne-python/archive/atlas.zip
|
|
that helped, thanks. then i tried to extract the time course from the stc
i am encountering the unexpected error: How is that possible when i am using the same src to extract the time course as well as to compute the morphed stc? |
|
can you share a code snippet to replicate ?
… |
|
I tried to replicate the code here
|
|
You have to be careful about sphere_units, they changed between versions. You probably need to set this to mm, the default is now m. In general if you stick to using dev versions you need to follow changes or read the release notes very closely because deprecation cycles can be effectively days or weeks in duration instead of 6 months. |
that solved the second point. Then compute the extract_time_course. |
|
Yes right now, because everything is done in Freesurfer surface RAS coordinates ( Have you already transformed the HCPMMP1 parcellation to your subject's MRI space such that a given voxel in your HCPMMP1 volume corresponds to the same voxel in their |
|
Check this link: https://cjneurolab.org/2016/11/22/hcp-mmp1-0-volumetric-nifti-masks-in-native-structural-space/ |
|
So You don't have to worry about these differences. So in theory if you just save your |
|
... and personally I would probably update that script you used to output .mgz files with the vox2ras_tkr set properly. Then it would even work for non-fsaverage subjects. |
|
You mean to say I can use atlas in .nii format to extract time courses from stc? Or you mean I need to convert .nii to .mgz? Then try to extract the time course |
You almost certainly need to convert it to |
|
Hi there,
I am understanding Pooja wishes to extract volumic parcels using the
HCPMMP1 for our source analyses.
We are slowly advancing. Bear in mind you are not talking to coders but
simple scientists trying to make whatever receipe you guys mention work :)
I ran 45 min of a code to realize that "wm.mgz" was missing in the
fsaverage. It should be mentionned beforehand.
So before I continue solving error after bug sequentially: where can I get
a sense of the ingredients that are first needed to get the final receipe
to work?
…------------------------------------------------
Right now, I came up with a rather unsatiscatory recipe because I think a
lot of initial variables are missing:
[This procedure takes 45 min +]
To create HCPMMP volumetric parcels on NeuroSpin server:
1) copy "fsaverage" in the MRI folder of your study
2) copy "lh.HCPMMP1.annot" and "rh.HCPMMP1.annot" in /fsaverage/label/
https://cjneurolab.org/2016/11/22/hcp-mmp1-0-volumetric-nifti-masks-in-native-structural-space/
3) create a "subject_list.txt" simply listing "fsaverage"
4) type to initialize freesurfer:
freesurfer_init
5) type to temporarily set your default $SUBJECTS_DIR to your study:
export $SUBJECTS_DIR=/neurospin/meg/meg_tmp/mystudy/MRI
6) type to inialize fsl :
fsl_init
7) type to create the parcel into the folder HCPMMP1_parcellation:
bash create_subj_volume_parcellation.sh -L subject_list.txt -a HCPMMP1 -d
HCPMMP1_parcellation -s YES -t YES
---------------------------------------
Thanks a lot, much appreciated
Virginie van Wassenhove
*https://brainthemind.com/ <https://brainthemind.com/>*
On Thu, May 7, 2020 at 10:45 PM Eric Larson ***@***.***> wrote:
Or you mean I need to convert .nii to .mgz? Then try to extract the time
course
You almost certainly need to convert it to mgz. Even just doing mri_convert
/path/whatever.nii /path/whatever.mgz might be enough for things to work.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#7639 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ABYMUIVVOP7USMT4IOPLHADRQMMWJANCNFSM4MMTL6ZQ>
.
|
|
We can probably ship some HCPMMP1 + aseg volumes for |
|
... looking into this a bit, the solution they posted is a start but it's not exactly straightforward to get it working. I trimmed the script a bit just to use with fsaverage and output an mgz file. However, it does not output the actual region LUT that is to be used with the volume, so this needs to be created based on the math it actually does. And doing these things in Bash is not exactly straightforward. I think it would actually be easier to do most of this in Python with nibabel. All that we really need FreeSurfer for (I think) is to generate a aseg volume from the annotation: From there in Python we can:
Eventually this could be done for other subjects, too, for example by using For now, perhaps try using |
|
@poojaprabhu9 @virvw can you try this FreeSurfer command (after running Then run this gist, which will create Then in MNE you can do something like the following to extract label time courses: |
|
I was trying to use the above code but unfortunately i could not read the stc file (i updated the mne using, pip install https://api.github.com/repos/mne-tools/mne-python/zipball/master) because of this error. |
This might not have done anything, try doing it again with |
|
I tried upgrading by You can find the stc file here |
|
Can you upload the source space that you used? I can't try those functions without it |
|
just run this line |
|
Okay -- it's better to use the bem/brain to define the set of sources to keep rather than |
will try that for the further computations. |
|
@larsoner @poojaprabhu9 I am stuck with the gist for several reasons independent of the code itself |
|
The gist was ran removing the initial option "sort" because not available in our version. Note that the created file "FreeSurferColorLUT.txt" was found by the script "create_subj_volume_parcellation.sh" when placed in the same folder as the script and not in the "fsaverage/label/" Now I am encountering issue when running "create_subj_volume_parcellation.sh" since we are missing "wm.mgz" for fsaverage FreeSurfer/vv221713@is152869:/neurospin/meg/meg_tmp/2015_MiniManip_rsMEG/POLTI_Ignacio_RSretroTIME/MRI$ bash create_subj_volume_parcellation.sh -L subject_list.txt -a HCPMMP1 -d HCPMMP1_parcellation -s YES -t YES reading colortable from annotation file...
|
It will not work properly without that option. The regions will be mislabeled. It was added to
You should not run this at all anymore, just the two steps mentioned in the comment above:
This should create all the files for |
|
@larsoner considering thet the sort option is set to FALSE in your script,
does that matter at all?
If it does then I have to wait unless someone can run your script because I
can't update.
@pooja due to this issue, please neglect the files I just sent you which
will be mislabeled...
Virginie van Wassenhove
*https://brainthemind.com/ <https://brainthemind.com/>*
…On Sun, May 10, 2020 at 5:36 PM Eric Larson ***@***.***> wrote:
The gist was ran removing the initial option "sort" because not available
in our version.
It will not work properly without that option. The regions will be
mislabeled. It was added to master recently, so if you update it should
be available.
Note that the created file "FreeSurferColorLUT.txt" was found by the script
You should not run this at all anymore, just the two steps mentioned in
the comment above
<#7639 (comment)>
:
1. $ mri_aparc2aseg --s fsaverage --volmask --annot HCPMMP1
2. python hcpmmp_lut.py from here
<https://gist.github.com/larsoner/8e664205cd8285ca7c46211403ad12ce>
This should create all the files for fsaverage that you need to be able
to extract label time courses (i.e., run the Python code from this comment
<#7756 (comment)>
).
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#7639 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ABYMUIUX7BL7E64FCWPRE5TRQ3CZBANCNFSM4MMTL6ZQ>
.
|
That's the start of a multi-line string, looks okay to me. Did you try and and get some error?
In Also, if you plan to use the |
Everything is fine. It was a mistake from my side. |
|
Ok I think things are sorted out.... and it is now back in Pooja's hands...!
Virginie van Wassenhove
*https://brainthemind.com/ <https://brainthemind.com/>*
…On Sun, May 10, 2020 at 6:02 PM poojaprabhu9 ***@***.***> wrote:
That's the start of a multi-line string, looks okay to me. Did you try and
and get some error?
Everything is fine. It was a mistake from my side.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#7639 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ABYMUIWMFTBULKESGHXGYMLRQ3F25ANCNFSM4MMTL6ZQ>
.
|



Adds volume label support to
extract_label_time_course. Requires #7597 (and follow-up PRs).mne.read_freesurfer_lutas suggested by @vferat here to makesetup_volume_source_spacemore general and pave the way for more generic atlas supportsetup_volume_source_spacewith many labels by refactoring_make_volume_source_spacesetup_volume_source_spacewith all volume labels ofaseg.mgzcreates a complete source spaceextract_label_time_courseVolSourceEstimate support via atlasvol_stc.in_labelvolume atlas supportNext PRs:
srcin SourceMorph (DOC: morph generated from src does not work because fwd exlcude some vertices #7007)Closes #6155.