Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/Rubick65/dcemapper/llms.txt

Use this file to discover all available pages before exploring further.

The src.io module provides two submodules for reading MRI data into DCEMapper: nifti_io handles loading NIfTI files directly into NumPy arrays, and bruker_conversion automates batch conversion of raw Bruker scanner output into BIDS-compatible NIfTI files. Together they form the entry point for all data ingestion in the pipeline.

nifti_io

load_nifti(path)

Loads a NIfTI image from disk and returns its voxel data as a NumPy array alongside the full NiBabel image object. Internally, load_nifti first validates the path via is_valid_nifti, then calls nibabel.load and extracts the floating-point data array with get_fdata().
path
string
required
Filesystem path to a NIfTI file. Both uncompressed (.nii) and gzip-compressed (.nii.gz) formats are supported.
Returns
NameTypeDescription
datanumpy.ndarrayVoxel intensity array. Shape is (X, Y, Z) for a 3D volume or (X, Y, Z, T) for a 4D time series.
imgnibabel.Nifti1ImageFull NiBabel image object. Provides .affine (4×4 voxel-to-world matrix) and .header.
from src.io.nifti_io import load_nifti

data, img = load_nifti("path/to/dce_data.nii.gz")
print(data.shape)   # e.g. (128, 128, 20, 50) for a 4D DCE volume
print(img.affine)   # 4x4 affine transformation matrix

get_nifti_slices(data, current_t=0)

Extracts all axial slices from a 4D NIfTI array at a specified time frame, returning them as a list of transposed 2D arrays ready for display.
data
numpy.ndarray
required
4D array of shape (X, Y, Z, T) as returned by load_nifti.
current_t
int
default:"0"
Time frame index to extract. Defaults to 0 (the first frame).
Returns A list of 2D numpy.ndarray objects, one per Z slice. Each element is data[:, :, z, current_t].T, so the orientation matches screen coordinates directly.
from src.io.nifti_io import load_nifti, get_nifti_slices

data, img = load_nifti("dce_data.nii.gz")
slices = get_nifti_slices(data, current_t=5)
print(len(slices))   # number of slices (Z dimension)

bruker_conversion

convert_studies_from_bruker(input_dir, output_dir, skip_existing=True)

Scans a directory for Bruker studies (raw subject folders or ZIP archives), identifies each scan’s modality, and converts them to NIfTI format organised in a BIDS-like folder structure under output_dir/sourcedata/. For each study, the function:
  1. Loads the Bruker dataset with brkraw.
  2. Extracts SubjectID and SessionID to build a BIDS-compliant subject/session label (e.g. sub-B001_ses-01).
  3. Iterates over all available scans and reconstructions, skipping derived ISA maps.
  4. Detects the modality (DCE, DWI, T1w, etc.) from sequence parameters.
  5. Saves a .nii.gz file and a companion .json sidecar with BIDS metadata. For DWI scans, .bvec and .bval files are also written.
  6. Writes a conversion_report.log to output_dir if any errors occurred.
input_dir
string
required
Path to the directory containing Bruker study folders or ZIP files. The function searches recursively for any path containing a subject file or a valid .zip archive.
output_dir
string
required
Destination root directory. Converted files are written under output_dir/sourcedata/sub-XXX_ses-YYY/<category>/.
skip_existing
boolean
default:"true"
When True, any subject/session whose target directory already exists is silently skipped. Set to False to force reconversion of previously processed studies.
Returns None. All output is written to disk. A conversion_report.log file is created in output_dir only when one or more scans fail to convert.
from src.io.bruker_conversion import convert_studies_from_bruker

convert_studies_from_bruker(
    input_dir="/data/bruker_studies",
    output_dir="/data/nifti_output",
    skip_existing=True
)
Time-domain fields (RepetitionTime, EchoTime, InversionTime) are automatically converted from milliseconds (Bruker convention) to seconds (BIDS standard) in the JSON sidecar.

Build docs developers (and LLMs) love