NIfTI-FitT1 is a voxel-wise inversion recovery MRI fitting pipeline written in Python. It loads a 4D NIfTI image plus a YAML configuration file, fits the inversion recovery model to every valid voxel using nonlinear least squares, and saves T1 and S0 maps as 3D NIfTI files.
- Python 3.11 or compatible Python 3 environment
- The packages listed in
requirements.txt
Create and activate a virtual environment, then install the dependencies:
python -m venv .venv
.\.venv\Scripts\Activate.ps1
python -m pip install -r requirements.txtRun the simulator from the project root:
python simulate_data.pyThis creates:
fake_data.nii.gzconfig.yaml
The generated configuration references the synthetic dataset and writes outputs into the output directory.
Execute the pipeline with the generated configuration:
python -m src.pipeline --config config.yamlIf the run succeeds, the pipeline writes:
output/T1_map.nii.gzoutput/S0_map.nii.gz
Execute the test suite from the project root:
pytestThe test suite covers:
- The inversion recovery equation in
src/models.py - Fitter behavior for invalid voxel data in
src/fitters.py - An integration path that fits synthetic inversion recovery data and checks parameter recovery
The config.yaml file must contain:
input_nifti: path/to/4d_image.nii.gz
inversion_times:
- 100.0
- 400.0
- 1000.0
- 2000.0
output_dir: output
mask_threshold: 50.0.
|-- README.md
|-- requirements.txt
|-- simulate_data.py
`-- src
|-- __init__.py
|-- config.py
|-- fitters.py
|-- models.py
`-- pipeline.py
`-- tests
|-- conftest.py
|-- test_fitters.py
|-- test_integration.py
`-- test_models.py