Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Cover

RCLM

Languages: English | 日本語 (Japanese)

Python 3.11+ Under review

RCLM: Region / ROI Change-conditioned Longitudinal Morphing
Subject-specific simulation of future brain MRI from a baseline T1 scan.


Overview

RCLM is an inference-only package. Given a skull-stripped baseline T1 and clinical conditions (sex, age, elapsed years, and optionally ROI volume change ratios), it predicts a future brain MRI via a latent deformation field.

Typical workflow:

  1. Skull-strip the T1 (recommended: OpenMAP-T1)
  2. Register to MNI (template/MNI_FULL.nii.gz) with src/register.py or --register if needed
  3. Place weights under model/ (rclm.pth, args.json)
  4. Run src/inference.py with --sex, --age, --years (and optional --vcr-*)
  5. Find the simulated future MRI under the output folder

Input requirements

RCLM expects skull-stripped T1-weighted MRI. We recommend running OpenMAP-T1 for skull stripping (and related preprocessing) before RCLM.

Images must also be aligned to the MNI template (template/MNI_FULL.nii.gz). Registration is required for native-space inputs; this repository provides ANTsPy TRSAA registration via src/register.py and the --register flag.


Requirements

  • Python 3.11+
  • PyTorch 2.2+ (installed by uv sync; install separately when using pip)
  • nibabel, numpy, scipy, tqdm
  • Optional: ANTsPy (antspyx) for MNI registration

Installation

With uv (recommended)

# macOS / Linux
curl -LsSf https://astral.sh/uv/install.sh | sh

cd RCLM
uv sync

For MNI registration (ANTsPy):

uv sync --extra register

With pip (alternative)

python -m venv .venv
source .venv/bin/activate
# https://pytorch.org/
pip install -r requirements.txt
pip install torch
pip install "antspyx>=0.6.3"   # optional, for registration

Model / template files

model/
  rclm.pth         # pretrained weights
  args.json        # inference hyperparameters

template/
  MNI_FULL.nii.gz  # MNI template (required for registration)

Usage

--sex, --age, and --years are required. If no --vcr-* options are set, RCLM runs without VCR conditioning (rates = 0, flag = 0). To enable VCR, set all four --vcr-* options.

uv run python src/inference.py -i input -o output -m model \
  --sex F --age 70 --years 5

Condition vector

Index Content
0 Sex (F=0 / M=1)
1 Age / 100
2 Elapsed years / max_delta_years (≈ 14.54 from training)
3–6 ICV-relative volume change rates for LateralVentricle, Amyg, Hippo, SylvianFissureExt
7 VCR availability flag (1 when used, 0 otherwise)

Volume change ratio (VCR):

$$ r = \frac{v_{\mathrm{target}} - v_{\mathrm{source}}}{\max(|v_{\mathrm{source}}|, \varepsilon)} $$

where $v$ is ICV-normalized relative volume. Per-ROI --vcr-* values are total change over --years (not annual rates). All four --vcr-* options must be set to enable VCR conditioning; omitting all of them runs without VCR.

Volume change ratio (VCR)

Set all ROIs (required for VCR-on):

uv run python src/inference.py -i input -o output -m model \
  --sex F --age 70 --years 5 \
  --vcr-lateral-ventricle 0.2 \
  --vcr-amyg -0.05 \
  --vcr-hippo -0.04 \
  --vcr-sylvian 0.15

Disable VCR (omit all --vcr-*, or use --no-roi-change):

uv run python src/inference.py -i input -o output -m model \
  --sex F --age 70 --years 5 --no-roi-change

MNI registration (ANTsPy TRSAA)

trsaa corresponds to ANTsPy type_of_transform="TRSAA" (Translation → Rigid → Similarity → Affine → Affine).

uv sync --extra register

# Registration only
uv run python src/register.py -i input_native -o output

# Register, then run RCLM
uv run python src/inference.py -i input_native -o output -m model \
  --sex F --age 70 --years 5 --register

Optional registration flags: -t / --mni, --reg-iterations, --save-transforms, --verbose.


CLI reference

src/inference.py

Argument Description
-i Input folder or a single NIfTI
-o Output folder
-m Model folder (rclm.pth, args.json)
--sex Sex F/M or 0/1 (required)
--age Baseline age in years (required)
--years Elapsed years to the simulated target (required)
--vcr-lateral-ventricle Total VCR for LateralVentricle (all four --vcr-* required for VCR-on)
--vcr-amyg Total VCR for Amyg
--vcr-hippo Total VCR for Hippo
--vcr-sylvian Total VCR for SylvianFissureExt
--no-roi-change Disable VCR conditioning
--register TRSAA-register to MNI before inference
--mni Template path for --register (default: template/MNI_FULL.nii.gz)
--save-disp Also save *_disp.npy
--device cuda / mps / cpu (default: auto)
--output-voxel-size X Y Z Output spacing in mm (default: 1 1 1)

src/register.py

Argument Description
-i Input folder or a single NIfTI
-o Output folder
-t / --mni Explicit MNI template path (default: template/MNI_FULL.nii.gz)
--template-dir Folder containing MNI_FULL.nii.gz (default: template/)
--reg-iterations A B C TRSAA reg_iterations (default: 40 20 0)
--save-transforms Copy ANTs forward transforms next to the output
--verbose Verbose ANTs logging

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages