-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup_and_run_2mm.sh
More file actions
90 lines (78 loc) · 3.37 KB
/
setup_and_run_2mm.sh
File metadata and controls
90 lines (78 loc) · 3.37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#!/usr/bin/env bash
# setup_and_run_2mm.sh
#
# Steps B–E for the full 2mm ModelArray run.
# Run this AFTER 0_register_acpc_to_mni.sh -s 02 has completed.
#
# Usage — all configured modalities:
# bash setup_and_run_2mm.sh
#
# Usage — one or more specific modalities:
# bash setup_and_run_2mm.sh od_dwimap
# bash setup_and_run_2mm.sh icvf_dwimap od_dwimap isovf_dwimap
#
# Usage (detached):
# nohup bash setup_and_run_2mm.sh > /data/local/134_AF19/derivatives/modelarray/noddi_2mm/setup_run.log 2>&1 &
#
# Each modality needs a matching config file at:
# configs/config_noddi_<modality>_gam_2mm.json
# Modalities without a config are skipped with a warning.
set -euo pipefail
MODELARRAY_DIR="/data/local/134_AF19/derivatives/modelarray"
NODDI2MM="$MODELARRAY_DIR/noddi_2mm"
PARTICIPANTS="$MODELARRAY_DIR/participants_longitudinal.tsv"
TEMPLATEFLOW="/data/local/templateflow"
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
# ── Modalities to process ──────────────────────────────────────────────────────
# Pass modality names as arguments, or list them all here as the default.
if [[ $# -gt 0 ]]; then
MODALITIES=("$@")
else
MODALITIES=(
icvf_dwimap
od_dwimap
isovf_dwimap
# Add further modalities here as you create their config files:
# direction_dwimap
# tf_dwimap
)
fi
ts() { echo "[$(date +%H:%M:%S)] $*"; }
# ── Step B: masks directory + group mask (once, shared across modalities) ──────
ts "Step B: creating masks dir and copying 2mm brain mask..."
mkdir -p "$NODDI2MM/masks"
cp "$TEMPLATEFLOW/tpl-MNI152NLin2009cAsym/tpl-MNI152NLin2009cAsym_res-02_desc-brain_mask.nii.gz" \
"$NODDI2MM/masks/group_mask.nii.gz"
# Also put it at the root (3_run_model.sh looks there)
cp "$NODDI2MM/masks/group_mask.nii.gz" "$NODDI2MM/group_mask.nii.gz"
ts " done — $(fslstats "$NODDI2MM/masks/group_mask.nii.gz" -V | awk '{print $1}') nonzero voxels"
# ── Steps C–E: repeated for each modality ─────────────────────────────────────
for MODALITY in "${MODALITIES[@]}"; do
ts "══════════════════════════════════════════════"
ts "Processing modality: $MODALITY"
ts "══════════════════════════════════════════════"
CONFIG="$SCRIPT_DIR/configs/config_noddi_${MODALITY}_gam_2mm.json"
if [[ ! -f "$CONFIG" ]]; then
ts " SKIP — no config found at: $CONFIG"
continue
fi
# Step C: cohort CSV
ts " Step C: generating cohort CSV..."
bash "$SCRIPT_DIR/1_generate_cohort_longitudinal.sh" \
-p "$PARTICIPANTS" \
-d "$NODDI2MM/$MODALITY" \
-m "$NODDI2MM/masks" \
-o "$NODDI2MM"
CSV="$NODDI2MM/cohort_${MODALITY}.csv"
ts " done — $(tail -n +2 "$CSV" | wc -l) rows in $CSV"
# Step D: convoxel → HDF5
ts " Step D: running convoxel (building HDF5)..."
bash "$SCRIPT_DIR/2_run_convoxel.sh" \
-c "$CSV"
ts " done — HDF5: $NODDI2MM/cohort_${MODALITY}.h5"
# Step E: model (GAM)
ts " Step E: running ModelArray GAM..."
bash "$SCRIPT_DIR/3_run_model.sh" "$CONFIG"
ts " done — see results in $NODDI2MM/results/"
done
ts "ALL DONE."