-
Notifications
You must be signed in to change notification settings - Fork 26
Connectivity preprocessing
Currently, this tool supports functional connectivity between cortical labels (fMRI/MEG) or invasive electrodes. There are two preprocessing steps that are needed for creating the connectivity files for display: First, you need to preprocess the given modality (fMRI/MEG/electrodes) input files. Second, process the output of the first step for creating the connectivity files necessary for display.
Given the low time resolution, only resting state data is supported for functional connectivity. To analyze the resting state fMRI data, you need to call the fMRI preprocessing as the following:
python -m src.preproc.fMRI -s subject-name -a atlas-name -f analyze_resting_state --fmri_file_template fmri-file-template
This call will load an fMRI file according to the given a template for each hemisphere, and calculate a time series for each label according to the given atlas (atlas-name). This function assumes that the data was already projected on the cortical surface. If this isn't the case, you should first project it, by calling the fMRI preprocessing as described here. You just need to add the -f project_volume_to_surface flag to the call, to run only the projection function. For example, let's say you've already processed your fMRI data with FsFast, and as result, you got two files, subject-name.siemens.sm6.fsaverage.rh.nii.gz and subjext-name.siemens.sm6.fsaverage.rh.nii.gz where subject-name is the name of your subject. First, you need to copy those files to the links/fMRI/subject-name/ folder. The fmri-file-template is {subject}.siemens.sm6.{morph_to_subject}.{hemi}.{format}. The code will put subject-name in {subject} and rh and lh in {hemi}. The default value for the format is 'nii.gz'. In case you want to set a different format, you should use the --input_format flag. The {morph_to_subject} is used in case the data was projected to a template brain, fsaverage, like in the current example. In such a case, you'll need to use the flag --morph_labels_to_subject. You can also use wildcards in the fmri-file-template. For example: "{subject}*{morph_to_subject}.{hemi}*.{format}". That will work only if there is only one file matching this template. If your files are named 'subject-name.siemens.sm6.fsaverage.rh.b0dc.nii.gz' for example, this template will catch it. The default measure to calculate a time series for each label is just taking the mean of all the label's vertices. The other option is 'PCA', where the first principal component is taken. To change this option you'll need to use the --resting_state_measure flag. The default atlas-name is aparc.DKTatlas40, as explained here. To summarize, in the current example the call is the following:
python -m src.preproc.fMRI -s subject-name -a atlas-name -f analyze_resting_state --fmri_file_template "{subject}\*{morph_to_subject}.{hemi}\*.{format}" --morph_labels_to_subject fsaverage
If you wish to call this function in code, look at the function analyze_resting_state in src.preproc.examples.fMRI, or call it directly:
python -m src.preproc.examples.fMRI -s subject-name -a atlas-name -f analyze_resting_state
Remember that if you are using the aparc.DKTatlas40 atlas, you don't need to use the -a flag.