4D Image Conversion
Utilities for converting 4D medical images into a 3D time-series sequence.
.nrrd inputs (including Slicer .seq.nrrd heart sequences, whose
per-voxel vector dimension exceeds ITK Python’s wrapped Vector sizes) are read
with pynrrd; all other formats (NIfTI .nii.gz, MHA, …) are read with
itk.imread and must be true 4-dimensional images.
Module Reference
Convert a 3D or 4D image into a sequence of 3D images.
Reads a 3D or 4D medical image and, for the 4D case, splits it along the temporal axis into individual 3D ITK volumes. Origin, spacing, and direction are preserved in each per-frame volume. A pure 3D input becomes a one-element time series.
Three reader paths are used:
A directory path is treated as a DICOM series and read with
pydicom. The slices are grouped by temporal position (TemporalPositionIdentifierorTriggerTime); each group yields one 3D ITK image. Directories that contain a single phase produce a single 3D image..nrrdfiles: 4D Slicer.seq.nrrdheart sequences (whose per-voxel vector dimension exceeds ITK Python’s wrapped Vector sizes) go throughpynrrd. Plain 3D NRRDs fall back toitk.imread.Every other format goes through
itk.imreadand may be either 3D or 4D (e.g. NIfTI.nii.gzwithdim[0] == 3or4).
- class physiomotion4d.convert_image_4d_to_3d.ConvertImage4DTo3D(log_level=20)[source]
Split a 3D/4D ITK image into a list of 3D ITK images.
- load_image_4d(filename)[source]
Load a 3D or 4D image and populate
self.img_3dwith 3D frames.Dispatch rules:
A directory path is read as a DICOM series via
pydicom. Slices are grouped by temporal phase; each group becomes one 3D ITK image. A 3D-only directory produces a single 3D image..nrrdfiles usepynrrdfor true 4D Slicer.seq.nrrdinputs and fall back toitk.imreadfor plain 3D NRRDs.All other formats go through
itk.imread; the array may be 3D or 4D and is treated uniformly as a (1 or T)-frame sequence.
Navigation