TheDocumentation 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.
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().
Filesystem path to a NIfTI file. Both uncompressed (
.nii) and gzip-compressed (.nii.gz) formats are supported.| Name | Type | Description |
|---|---|---|
data | numpy.ndarray | Voxel intensity array. Shape is (X, Y, Z) for a 3D volume or (X, Y, Z, T) for a 4D time series. |
img | nibabel.Nifti1Image | Full NiBabel image object. Provides .affine (4×4 voxel-to-world matrix) and .header. |
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.
4D array of shape
(X, Y, Z, T) as returned by load_nifti.Time frame index to extract. Defaults to
0 (the first frame).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.
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:
- Loads the Bruker dataset with
brkraw. - Extracts
SubjectIDandSessionIDto build a BIDS-compliant subject/session label (e.g.sub-B001_ses-01). - Iterates over all available scans and reconstructions, skipping derived ISA maps.
- Detects the modality (DCE, DWI, T1w, etc.) from sequence parameters.
- Saves a
.nii.gzfile and a companion.jsonsidecar with BIDS metadata. For DWI scans,.bvecand.bvalfiles are also written. - Writes a
conversion_report.logtooutput_dirif any errors occurred.
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.Destination root directory. Converted files are written under
output_dir/sourcedata/sub-XXX_ses-YYY/<category>/.When
True, any subject/session whose target directory already exists is silently skipped. Set to False to force reconversion of previously processed studies.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.
Time-domain fields (
RepetitionTime, EchoTime, InversionTime) are automatically converted from milliseconds (Bruker convention) to seconds (BIDS standard) in the JSON sidecar.