fsqc.outlierDetection

This module provides a function to evaluate potential outliers in the aseg.stats, aparc.stats, and hypothalamic and hippocampal values (if present).

fsqc.outlierDetection.outlierDetection(subjects, subjects_dir, output_dir, outlierDict, min_no_subjects=10, hypothalamus=False, hippocampus=False, hippocampus_label=None, fastsurfer=False)[source]

Evaluate outliers in aseg.stats, [lr]h.aparc, and optional hypothalamic/hippocampal values.

Parameters:
subjectslist

List of subject IDs.

subjects_dirstr

Path to the FreeSurfer subjects directory.

output_dirstr

Path to the output directory for saving results.

outlierDictdict

Dictionary containing outlier thresholds for different measures.

min_no_subjectsint, optional

Minimum number of subjects required for analysis.

hypothalamusbool, optional

Flag to include hypothalamic values in the analysis.

hippocampusbool, optional

Flag to include hippocampal values in the analysis.

hippocampus_labelstr or None, optional

Label to identify the hippocampus (e.g., “Hippocampus”).

fastsurferbool, optional

Flag to use FastSurfer instead of FreeSurfer output files.

Returns:
tuple

A tuple containing three dictionaries:

  • outlierSampleNonparNum

  • outlierSampleParamNum

  • outlierNormsNum

fsqc.outlierDetection.outlierTable()[source]

Provide upper and lower bounds for volumes of several brain structures.

Returns:
dict

A dictionary containing upper and lower bounds for several brain structures.

fsqc.outlierDetection.readAparcStats(path_aparc_stats, hemi)[source]

Read FreeSurfer aparc.stats files.

Parameters:
path_aparc_statsstr

Path to the aparc.stats file.

hemistr

Hemisphere designation (‘lh’ for left, ‘rh’ for right).

Returns:
tuple

A tuple containing three dictionaries:

  • Header information for the aparc.stats file.

  • Detailed measures for different anatomical regions.

  • Thickness values for each region.

fsqc.outlierDetection.readAsegStats(path_aseg_stats)[source]

Read FreeSurfer aseg.stats files.

Parameters:
path_aseg_statsstr

Path to the aseg.stats file.

Returns:
dict

A dictionary containing FreeSurfer aseg measures.

fsqc.outlierDetection.readHippocampusStats(path_hippocampus_stats, hemi, prefix)[source]

Read hippocampal or amygdala volume files.

Parameters:
path_hippocampus_statsstr

Path to the volume file.

hemistr

Hemisphere identifier (e.g., ‘lh’ or ‘rh’).

prefixstr

Prefix for column names.

Returns:
dict

Dictionary containing volume values with column names.

fsqc.outlierDetection.readHypothalamusStats(path_hypothalamus_stats)[source]

Read hypothalamic volume files.

Parameters:
path_hypothalamus_statsstr

Path to the hypothalamic volume file.

Returns:
dict

A dictionary containing hypothalamic volume information.