Skip to content

MRG, FIX: Backward compat read for vol stc#7756

Merged
agramfort merged 1 commit intomne-tools:masterfrom
larsoner:stc
May 9, 2020
Merged

MRG, FIX: Backward compat read for vol stc#7756
agramfort merged 1 commit intomne-tools:masterfrom
larsoner:stc

Conversation

@larsoner
Copy link
Copy Markdown
Member

@larsoner larsoner commented May 8, 2020

Fixes reading STCs written with old versions of MNE.

@larsoner larsoner self-assigned this May 8, 2020
@larsoner
Copy link
Copy Markdown
Member Author

larsoner commented May 8, 2020

@poojaprabhu9 on this PR I can run this:

import os.path as op
import mne
stc = mne.read_source_estimate('morphed_lgamma_power-stc.h5')
mri_dir = op.join(mne.get_config('SUBJECTS_DIR'), 'fsaverage', 'mri')
lut, _ = mne.read_freesurfer_lut(op.join(mri_dir, 'HCPMMP1ColorLUT.txt'))
labels = mne.read_labels_from_annot('fsaverage', 'HCPMMP1', 'both')
# limit to just the HCPMMP labels with this, or omit it to keep subcortical:
lut = {label.name: lut[label.name] for label in labels}
atlas = op.join(mri_dir, 'HCPMMP1+aseg.mgz')
src = mne.setup_volume_source_space(
    'fsaverage', pos=5., sphere=(0, 0, 0, 90), sphere_units='mm',
    verbose=True)
# This one is better
label_tc = mne.extract_label_time_course(stc, (atlas, lut), src)
stc_label = stc.in_label(1001, atlas, src)

And get:

>>> stc_label
<VolSourceEstimate  |  15 vertices, subject : fsaverage1, tmin : -1200.0 (ms), tmax : 1200.0 (ms), tstep : 5.0 (ms), data shape : (15, 481)>
>>> label_tc.shape
(362, 481)

@poojaprabhu9
Copy link
Copy Markdown

That's nice.
I am not able to read stc file to do this, even after upgrading mne dev version.
Could you please send the HCPMMP1+aseg.mgz, HCPMMP1_combined+aseg.mgz, and LUT files of both.

@larsoner
Copy link
Copy Markdown
Member Author

larsoner commented May 8, 2020

I am not able to read stc file to do this, even after upgrading mne dev version.

This PR has not been merged, you'll need to install the larsoner/stc branch to see if it fixes things

Could you please send the HCPMMP1+aseg.mgz, HCPMMP1_combined+aseg.mgz, and LUT files of both.

It would be better if you could try to follow the instructions linked in this comment to make sure the instructions actually work

@poojaprabhu9
Copy link
Copy Markdown

poojaprabhu9 commented May 8, 2020

It would be better if you could try to follow the instructions linked in this comment to make sure the instructions actually work

I was trying the hcpmmp_lut.py

header = """
# Below is the color table for the cortical labels of the seg volume
# created by mri_aparc2aseg in which the aseg cortex label is replaced
# by the labels in the %s aparc.
#No.    Label Name:                         R   G   B   A
""" % (parc,)

I think there is something missing in this line.

@agramfort agramfort merged commit 60b2b24 into mne-tools:master May 9, 2020
@larsoner larsoner deleted the stc branch May 9, 2020 13:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants