Freesurfer pipeline
FreesurferClinicalPipeline
__init__
Freesurfer clinical pipeline
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
subject
|
object
|
The subject object. |
required |
session
|
object
|
The session object. |
required |
output_path
|
str
|
The output path for the pipeline. |
required |
use_which_t1w
|
str
|
Use specific T1w file if multiple are available. Defaults to "". |
''
|
FreesurferPipeline
Bases: FreesurferStatsExtractorMixin
__init__
Freesurfer pipeline
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
subject
|
object
|
Subject object |
required |
session
|
object
|
Session object |
required |
output_path
|
str
|
Output path |
required |
use_which_t1w
|
str
|
Use specific T1w file if multiple are available. Defaults to "". |
''
|
recon_all
|
bool
|
Whether to run recon-all. Defaults to True. |
True
|
subregion_ha
|
bool
|
Whether to segment hippocampus and amygdala subregions. Defaults to False. |
False
|
subregion_thalamus
|
bool
|
Whether to segment thalamus subregions. Defaults to False. |
False
|
subregion_brainstem
|
bool
|
Whether to segment brainstem subregions. Defaults to False. |
False
|
subregion_hypothalamus
|
bool
|
Whether to segment hypothalamus subunits. Defaults to False. |
False
|
fsqc
|
bool
|
Whether to run FSQC. Defaults to False. |
False
|
stats2csv
|
bool
|
Whether to convert stats to CSV. Defaults to False. |
False
|
extract_from
|
str
|
Path to extract results from. Defaults to "". |
''
|
SynthSRPipeline
__init__
SynthSR pipeline
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
subject
|
object
|
The subject object containing BIDS information. |
required |
session
|
object
|
The session object containing BIDS information. |
required |
output_path
|
str
|
The output path for the pipeline results. |
required |
use_which_t1w
|
str
|
Use specific T1w file if multiple are available. Defaults to "". |
''
|
A more detailed description:
Freesurfer: Principle Methodological Considerations
Freesurfer Version
The current pipeline uses the Freesurfer 7-dev version (freesurfer-linux-ubuntu22_x86_64-dev-20240909-9ca95c6). Although we prefer using deep learning-based tools implemented in Freesurfer 8 for more accurate and robust processing, the 8 version requires a larger RAM. For our groups with limited computational resources, we opt for the 7-dev version and parallelize the processing of multiple subjects to optimize resource usage.
External Brain Mask
We found that the default brainmask generated by Freesurfer may not be optimal for all datasets. Therefore, we choose to use an external brain mask with mri_synthstrip to replace the brain extraction step. Notably, we take the --no-csf option in mri_synthstrip to avoid misclassifying the CSF as grey matter (see the figure below).

We compare the results using the external brain mask (mri_synthstrip with --no-csf) versus the default Freesurfer brain mask in Freesurfer 7-dev in n = 111 subjects.
Agreement between the two processing pipelines was evaluated using the intraclass correlation coefficient (ICC(3,1)), and Pearson correlation coefficient. Results are displayed in the figures below (cortical measures from 3 parcellations)
DK

DKT

a2009s

qcache
We add the -qcache option to the recon-all command to generate additional surface-based measures.
QC
We use fsqc by Deep-MI lab for Freesurfer QC.
Subfield Segmentation
The subfield segmentation part includes:
- hippocampus and amygdala
- thalamus
- brainstem
- hypothalamus
CSV Outputs
Although Freesurfer provides aparcstats2table and asegstats2table commands to generate CSV files, we implement our own CSV generation function to have more control over the output format. All .stats files are parsed to generate CSV files (also when subregions stats files are available) for cortical and subcortical measures except for *h.curv.stats.
Freesurfer: recon-all-clinical.sh
Some extra preprocessing steps were implemented to achieve output similar to recon-all, such as cortical morphology metrics. For detailed information on these steps, please refer to the source code.