Skip to content

Instantly share code, notes, and snippets.

@com3345
Created May 26, 2016 06:21
Show Gist options
  • Save com3345/87d66c957308af99271cb0758494746f to your computer and use it in GitHub Desktop.
Save com3345/87d66c957308af99271cb0758494746f to your computer and use it in GitHub Desktop.
from nilearn import datasets
from nilearn.input_data import NiftiLabelsMasker as NLM
# your rawdata filename
filename = './tfMRI_EMOTION_RL.nii.gz'
# download the atlas, which has two attributes: dataset.maps, dataset.labels
dataset = datasets.fetch_atlas_destrieux_2009()
# create a label masker object
masker = NLM(labels_img=dataset.maps, verbose=1)
# extract rois signals by its fit_transform method
# shape of the rois_signals is (timepoints, rois) so we use .T to obtain (rois, timepoints)
rois_signals = masker.fit_transform(filename).T
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment