Week of 2026-04-20
BIDS, preprocessing & BME-X
Goals for the week
- get BME-X working on syn7T test subject
syn7T
Goal: Get BME-X pipeline operational on the Linux HPC.
BIDS restructuring. The raw data was organized with acquisition labels (acq-3T, acq-7T) rather than session folders, which BME-X requires. Wrote code/restructure_bids.sh to rename all files and create proper ses-3T/ and ses-7T/ session folders for all 52 subjects. Also created per-subject scans.tsv files with age_years column, required by BME-X for age-dependent model selection.
raw_nifti/sub-002/
├── ses-3T/
│ ├── anat/
│ │ ├── sub-002_ses-3T_T1w.nii.gz
│ │ └── sub-002_ses-3T_T2w.nii.gz
│ └── sub-002_ses-3T_scans.tsv
└── ses-7T/
├── anat/
│ ├── sub-002_ses-7T_T1w.nii.gz
│ └── sub-002_ses-7T_T2w.nii.gz
└── sub-002_ses-7T_scans.tsv
BME-X debugging. Several issues encountered and resolved:
layout.get(subject="sub-002")returned 0 files - pybids expects subject ID without thesub-prefix. Fixed by passing--subject_id 002.- Age lookup was failing silently. Root cause:
/utils/bids.py(the file actually imported at runtime viafrom utils.bids import *) contained a buggy regex^anat*instead ofanat/.*for matching filenames inscans.tsv. Fixed by mounting a corrected version:-v /data/syn7T/code/bids_fixed.py:/utils/bids.py. - Pipeline was running on CPU only despite GPU availability. Fixed by adding
--gpus allto the docker run command.
Working docker command:
docker run --rm --gpus all \
-v /data/syn7T/data/raw_nifti:/data \
-v /data/syn7T/data/derivatives/bmex:/results \
-v /data/syn7T/code/bids_fixed.py:/utils/bids.py \
yuesun814/bme-x:v1.0.5 \
--bids_root /data \
--subject_id 002 \
--session_id 3T \
--output_dir /resultsOutput verified visually for sub-002 ses-3T T1w. QI = 0.847.
Pipeline planning. For a valid quantitative comparison (SSIM, VIF) between BME-X enhanced 3T and actual 7T, images need to be in the same space and have matched brain extraction. Decided on the following pipeline order:
- SynthStrip brain extraction on all 7T T1w →
derivatives/synthstrip/ - ANTs SyN coregistration: 3T T1w → brain-extracted 7T T1w →
derivatives/coreg/ - Apply transforms to 3T T2w/FLAIR
- BME-X on coregistered 3T images →
derivatives/bmex/ - SSIM/VIF comparison
Scripts written and located in code/:
restructure_bids.sh- BIDS session restructuring (per-subject)batch_synthstrip_7T.sh- SynthStrip brain extraction on all 7T T1wbatch_coreg_3T_to_7T.sh- ANTs SyN coregistration 3T → 7Tbatch_apply_coreg.sh- apply transforms to T2w/FLAIRbids_fixed.py- patched/utils/bids.pywith corrected regex for BME-X
SynthStrip completed on all 52 subjects’ 7T T1w images (~10 min total). Outputs in derivatives/synthstrip/.
ANTs coregistration kicked off overnight (PID 3854907). Monitor via:
tail -f /data/syn7T/code/logs/coreg.logOpen question - input resolution standardization. 3T T1w voxel sizes vary considerably (0.41-1.33mm, median ~0.86mm isotropic) while 7T T1w is consistent at ~0.85mm isotropic. BME-X outputs at input resolution, so SSIM/VIF comparisons across subjects will be confounded by resolution differences. Options:
- Resample all 3T inputs to 0.85mm isotropic before the pipeline - standardizes comparison space but involves upsampling for some scans
- Accept subject-level variability and account for it analytically
Awaiting input from Irene and Mary before proceeding with full batch BME-X run.