Week of 2026-04-20

BIDS, preprocessing & BME-X

Published

April 20, 2026

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:

  1. layout.get(subject="sub-002") returned 0 files - pybids expects subject ID without the sub- prefix. Fixed by passing --subject_id 002.
  2. Age lookup was failing silently. Root cause: /utils/bids.py (the file actually imported at runtime via from utils.bids import *) contained a buggy regex ^anat* instead of anat/.* for matching filenames in scans.tsv. Fixed by mounting a corrected version: -v /data/syn7T/code/bids_fixed.py:/utils/bids.py.
  3. Pipeline was running on CPU only despite GPU availability. Fixed by adding --gpus all to 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 /results

Output 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:

  1. SynthStrip brain extraction on all 7T T1w → derivatives/synthstrip/
  2. ANTs SyN coregistration: 3T T1w → brain-extracted 7T T1w → derivatives/coreg/
  3. Apply transforms to 3T T2w/FLAIR
  4. BME-X on coregistered 3T images → derivatives/bmex/
  5. 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 T1w
  • batch_coreg_3T_to_7T.sh - ANTs SyN coregistration 3T → 7T
  • batch_apply_coreg.sh - apply transforms to T2w/FLAIR
  • bids_fixed.py - patched /utils/bids.py with 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.log

Open 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:

    1. Resample all 3T inputs to 0.85mm isotropic before the pipeline - standardizes comparison space but involves upsampling for some scans
    1. Accept subject-level variability and account for it analytically

Awaiting input from Irene and Mary before proceeding with full batch BME-X run.