Skip to content

Commit

Permalink
add neuromelanin column to manifest
Browse files Browse the repository at this point in the history
  • Loading branch information
michellewang committed Aug 30, 2024
1 parent 752dc9e commit 51bc2a4
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions nipoppy/workflow/tabular/generate_manifest.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import argparse
import datetime
import json
import re
import shutil
import warnings
from pathlib import Path
Expand Down Expand Up @@ -57,6 +58,10 @@
GLOBAL_CONFIG_VISITS = 'VISITS'
GLOBAL_CONFIG_TABULAR = 'TABULAR'

COL_NEUROMELANIN_MANIFEST = 'neuromelanin'
RE_NEUROMELANIN = '[nN][mM]' # neuromelanin pattern
COLS_MANIFEST = COLS_MANIFEST + [COL_NEUROMELANIN_MANIFEST]

DATATYPES = [DATATYPE_ANAT, DATATYPE_DWI, DATATYPE_FUNC]

# flags
Expand Down Expand Up @@ -218,9 +223,11 @@ def run(global_config_file: str, regenerate: bool, make_release: bool):

# create imaging datatype availability lists
seen_datatypes = set()
df_imaging = df_imaging.groupby([COL_SUBJECT_MANIFEST, COL_VISIT_MANIFEST, COL_SESSION_MANIFEST])[COL_DATATYPE_MANIFEST].aggregate(
lambda descriptions: get_datatype_list(descriptions, description_datatype_map, seen=seen_datatypes)
)
df_imaging[COL_NEUROMELANIN_MANIFEST] = df_imaging[COL_DATATYPE_MANIFEST]
df_imaging = df_imaging.groupby([COL_SUBJECT_MANIFEST, COL_VISIT_MANIFEST, COL_SESSION_MANIFEST])[[COL_DATATYPE_MANIFEST, COL_NEUROMELANIN_MANIFEST]].aggregate({
COL_DATATYPE_MANIFEST: lambda descriptions: get_datatype_list(descriptions, description_datatype_map, seen=seen_datatypes),
COL_NEUROMELANIN_MANIFEST: lambda descriptions: any([re.search(RE_NEUROMELANIN, description) for description in descriptions]),
})
df_imaging = df_imaging.reset_index()
print(f'\nFinal imaging dataframe shape: {df_imaging.shape}')

Expand Down

0 comments on commit 51bc2a4

Please sign in to comment.