CLI¶
MLArray includes a small command-line interface for common tasks such as inspecting file headers and converting between MLArray and existing image formats. This is especially useful when you want to quickly verify metadata, debug a dataset, or batch-convert files without writing Python code.
The CLI currently focuses on core workflows (header inspection and conversion). Support for converting a wider range of image formats will be added over time.
mlarray_header¶
Print the metadata header from a .mla file.
This command is useful for quickly checking spatial metadata, stored schemas, and other file-level information without loading the full array into memory.
mlarray_header sample.mla
mlarray_convert¶
Convert between MLArray and NIfTI/NRRD files.
This provides an easy way to move medical imaging data into or out of an MLArray-based workflow.
When converting from NIfTI/NRRD to MLArray, the source header is copied into meta.source.
When converting from NIfTI/NRRD to MLArray, meta.spatial.coord_system is
propagated conservatively:
- For NRRD input, the converter looks for explicit NRRD space metadata in the
header (
space, falling back toNRRD_spacefrom the SimpleITK path). It mapsright-anterior-superiortoRAS,left-posterior-superiortoLPS, and preserves other explicit NRRD space strings verbatim. If no explicit space metadata is available,coord_systemis left unset. - For NIfTI input, the converter sets
coord_systemtoLPS. This is based on the currentMedVol -> SimpleITK/ITKimport path: the imported geometry is represented in the ITK physical-space convention, and MedVol only reindexes axes to match NumPy array layout. It is not a statement that raw NIfTI qform/sform metadata is preserved verbatim.
When converting from MLArray to NIfTI/NRRD, only meta.source is copied into
the output header. Spatial metadata (spacing, origin, and direction) is
written explicitly from meta.spatial.
- For NRRD output,
coord_system="RAS"andcoord_system="LPS"are written as the corresponding NRRDspacestrings. A small set of already-valid NRRD space strings is also preserved. Unsupported arbitrarycoord_systemstrings are not written as NRRDspacemetadata. - For NIfTI output, geometry is preserved through the existing affine-related
path, but
coord_systemis not exported as an explicit NIfTI metadata field because the current conversion path does not expose a reliable direct representation for it.
mlarray_convert sample.nii.gz output.mla
mlarray_convert sample.mla output.nrrd