dbdicom.Record.export_as_npy#
- Record.export_as_npy(path: str, dims: tuple | None = None)[source]#
Export record in numpy’s NPY format to an external directory.
- Parameters:
Example
Create a 4D series:
>>> series = db.ones((128, 128, 10, 5))
Export the series as npy, with each slice in a separate file:
>>> path = 'path\to\empty\folder' >>> series.export_as_npy(path)
This will create 50 npy files in the folder, one for each image. To save the entire volume in a single file, specify the dimensions of the volume:
>>> dims = ('SliceLocation', 'AcquisitionTime') >>> series.export_as_npy(path, dims)
This will create a single npy 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()
.