Cortical graynet¶
For the cortical stream of processing, graynet relies on outputs from Freesurfer processing. If you processed your data (to produce thickness values), just resample them on fsaverage atlas and store it in a format readable by nibabel package.
The following steps should help you get started and going quickly:
- Ensure Freesurfer processing is complete
It is highly recommended that you perform quality control on the Freesurfer outputs before you use them for analysis. This QC is quite easy now using visualqc
Ensure you ran
recon-allwith-qcacheflag choosing atleast one FWHM value (10 is the default). If not already run, it is quick to rerun on existing Freesurfer processing.check How to run Freesurfer for more details.
If graynet is installed without error, you should have graynet command in your path. Just type graynet and you should see it display options and usage instructions, as presented in Command line interface page.
Suppose say
you already have Freesurfer processing done at
/work/project/freesurfer_reconallfor 5 subjects with identifiers are stored in subject_ids.txt (one per line)
you want to analyze network features based on cortical thickness values, which have been resampled on fsaverage surface (which is the default) at smoothing level of FWHM 10 (default)
use the
manhattanmethod to compute histogram distance between two cortical ROIs (assuming all subjects resampled to same atlas)and store the networks extracted in /work/project/graynet
You could achieve it all with a single command:
cd /work/project
graynet edges -s subject_ids.txt -f freesurfer_thickness -i /work/project/freesurfer_reconall -w manhattan -a fsaverage -p 10 -o /work/project/graynet
That’s it! By the time you can get your coffee or stretch your legs, you should have graynet processing done.
Suppose, you prefer to analyze ROIs as defined by a multimodal parcellation published in Glasser 2016 atlas and also curious to try multiple weight metrics - chebyshev and cosine, you can achieve it via the following command:
cd /work/project
graynet edges -s subject_ids.txt -f freesurfer_thickness -i /work/project/freesurfer_reconall -w manhattan chebyshev cosine -a Glasser2016 -p 10 -o /work/project/graynet
You could also study curvature and sulcal depth features by simply adding more features to the -f, such as freesurfer_curv and freesurfer_sulc.
However, if you have 100s of subjects or your atlas has a large number of ROIs (like the Glasser 2016 which has 360), this computation can take a long time. It is advisable to move the processing to a larger server or computer cluster, by delegating few subjects to a single job. You could leverage this script to process any large dataset at once (produce jobs for processing on a cluster).
If you have access to a computer cluster, you can submit the generated jobs to the cluster.
If you don’t have access to a cluster, you could still use the generated job/script files to run them locally - few at a time.
After processing is done, graynet 2.0 writes one run directory per parameter
combination. Each run directory contains canonical outputs such as
run_metadata.json and edges_raw.parquet. If you need older GraphML or
CSV exports, use the graynet export subcommands described in
Command line interface.
The output folder will be graynet within proc_dir you choose in the script - determined by this statement in the above script:
out_dir = pjoin(proc_dir, 'graynet', '{}_{}_fwhm{}_range{}_{}_nbins{}'.format(base_feature, atlas, fwhm, edge_range[0], edge_range[1], num_bins))
which after expansion looks something like based on your choices: /your_proc_dir/graynet/freesurfer_thickness_GLASSER2016_fwhm10_range0_5_nbins25/
Computing ROI-wise statistics¶
graynet also helps you compute ROI-wise statistics (individual, not
pair-wise) for visualization (median thickness in PCG), as well as to serve as
a baseline for network-level features. Use the roi-stats subcommand to do
this. Only one type of processing (ROI stats, or network-level features) can be
done at a time.
How to run Freesurfer¶
If you are new to Freesurfer, please:
follow this beginners guide
leverage various options available
include
-qcacheflag choosing atleast one FWHM value (10 is the default) - see Qcache recon-all flag.process the subjects till “recon-all is finished without error”
In typical scenarios (when T1 mri scans do not special processing to handle any artefacts), running Freesurfer would boil down to running command:
recon-all -all -sd /project/processed/freesurfer -subjid ABC_0001 -i /project/raw/ABC_0001/mri.nii -qcache
Qcache recon-all flag¶
The Qcache recon-all flag does the following:
resample data (e.g. thickness, curv, sulc) onto the average subject (called fsaverage)
smooth it at a range of FWHM (full-width/half-max) values, usually 0, 5, 10, 15, 20, and 25mm.
We encourage the use of default behaviour (simple inclusion of -qcache), which will smooth the surface data for thickness, curv, sulc, area and jacobian_white at 0, 5, 10, 15, 20, and 25 mm FWHM.
If you are interested in resampling the data on to a different atlas or process features outside Freesurfer structure, check https://surfer.nmr.mgh.harvard.edu/fswiki/qcache for more info.
The parcellation for the Glasser et al 2016 atlas has been resampled onto the fsaverage space already, courtesy of Kathryn Mills.
If you run into any issues, or have a feature you would like, please let me know here by opening an issue.