dbdicom.Record.export_as_nifti#

Record.export_as_nifti(path: str, dims: tuple | None = None)[source]#

Export record in NIFTI format to an external directory.

Parameters:
  • path (str) – path to export directory.

  • dims (tuple, optional) – when set, volumes are extracted along the given dimensions and exported in single files. If dims is not set, each image will be exported in its own file.

Example

Create a 4D series and export as NIFTI:

>>> series = db.ones((128, 128, 10, 5))
>>> path = 'path\to\empty\folder'
>>> series.export_as_nifti(path)

This should create a single folder in the directory, populated with 50 NIFTI files.

In order to export the entire series in a single volume, provide the dimensions along which the volume is to be taken:

>>> dims = ('SliceLocation', 'AcquisitionTime')
>>> series.export_as_nifti(path, dims=dims)

This will now create a single nifti file.

Note: in this case the dimensions must be specified as slice location and acquisition time because these are the default dimensions used by series creation functions like ones().