Skip to content

Commit

Permalink
Handle FastSurfer in addition to FreeSurfer files in outlier module
Browse files Browse the repository at this point in the history
  • Loading branch information
kdiers committed Mar 5, 2024
1 parent aa9db65 commit b5fb6cb
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 13 deletions.
3 changes: 2 additions & 1 deletion fsqc/fsqcMain.py
Original file line number Diff line number Diff line change
Expand Up @@ -1454,7 +1454,7 @@ def _check_packages():

def _do_fsqc(argsDict):
"""
Run the FastSurferQC submodules.
Run the fsqc submodules.
Parameters
----------
Expand Down Expand Up @@ -2298,6 +2298,7 @@ def _do_fsqc(argsDict):
hypothalamus=argsDict["hypothalamus"],
hippocampus=argsDict["hippocampus"],
hippocampus_label=argsDict["hippocampus_label"],
fastsurfer=argsDict["fastsurfer"],
)

# create a dictionary from outlier module output
Expand Down
40 changes: 28 additions & 12 deletions fsqc/outlierDetection.py
Original file line number Diff line number Diff line change
Expand Up @@ -794,12 +794,12 @@ def readHippocampusStats(path_hippocampus_stats, hemi, prefix):

def outlierTable():
"""
Read hippocampal volume files. Also works for amygdala volume files.
Provides upper and lower bounds for volumes of several brain structures.
Returns
-------
dict
A dictionary containing hippocampal volume information.
A dictionary containing upper and lower bounds for several brain structures.
"""
# define

Expand Down Expand Up @@ -893,6 +893,7 @@ def outlierDetection(
hypothalamus=False,
hippocampus=False,
hippocampus_label=None,
fastsurfer=False,
):
"""
Evaluate outliers in aseg.stats, [lr]h.aparc, and optional hypothalamic/hippocampal values.
Expand All @@ -915,11 +916,17 @@ def outlierDetection(
Flag to include hippocampal values in the analysis.
hippocampus_label : str or None, optional
Label to identify the hippocampus (e.g., "Hippocampus").
fastsurfer : bool, optional
Flag to use FastSurfer instead of FreeSurfer output files.
Returns
-------
None
This function returns nothing but saves results in the specified output directory.
tuple
A tuple containing three dictionaries:
- outlierSampleNonparNum
- outlierSampleParamNum
- outlierNormsNum
"""
# imports

Expand All @@ -936,27 +943,36 @@ def outlierDetection(
all_regions_keys = list()

for subject in subjects:
# aseg

# aseg
path_aseg_stats = os.path.join(subjects_dir, subject, "stats", "aseg.stats")
aseg_stats = readAsegStats(path_aseg_stats)
regions[subject] = aseg_stats.copy()
all_regions_keys.extend(list(aseg_stats.keys()))

# aparc

path_aparc_stats = os.path.join(
subjects_dir, subject, "stats", "lh.aparc.stats"
)
if fastsurfer is True:
path_aparc_stats = os.path.join(
subjects_dir, subject, "stats", "lh.aparc.DKTatlas.mapped.stats"
)
else:
path_aparc_stats = os.path.join(
subjects_dir, subject, "stats", "lh.aparc.stats"
)
aparc_header, aparc_stats, aparc_thickness = readAparcStats(
path_aparc_stats, hemi="lh"
)
regions[subject].update(aparc_thickness)
all_regions_keys.extend(list(aparc_thickness.keys()))

path_aparc_stats = os.path.join(
subjects_dir, subject, "stats", "rh.aparc.stats"
)
if fastsurfer is True:
path_aparc_stats = os.path.join(
subjects_dir, subject, "stats", "rh.aparc.DKTatlas.mapped.stats"
)
else:
path_aparc_stats = os.path.join(
subjects_dir, subject, "stats", "rh.aparc.stats"
)
aparc_header, aparc_stats, aparc_thickness = readAparcStats(
path_aparc_stats, hemi="rh"
)
Expand Down

0 comments on commit b5fb6cb

Please sign in to comment.