io.to_dicom

Contents

io.to_dicom#

bartorch.io.to_dicom()#

Convert a real image to the datasets of one DICOM MR image series.

Parameters:
  • image (torch.Tensor or numpy.ndarray) – Real, (*leading, z, y, x) or (y, x). Each (y, x) plane is an image; leading axes are numbered through after the slices. Floating-point values are quantised to uint16 over the whole series and RescaleSlope and RescaleIntercept recover them; integer values are stored as they are.

  • affine (torch.Tensor or numpy.ndarray) – (4, 4), from voxel indices (x, y, z) to RAS coordinates in millimetres. x runs along the rows, y down the columns.

  • header (ismrmrd.xsd.ismrmrdHeader or pydicom.Dataset, default=None) – Where the patient, study, frame-of-reference and equipment fields come from: the MRD header of the scan, or a dataset of it such as Images.header. The series always gets a new SeriesInstanceUID.

  • **fields – DICOM keywords and values set on every image, such as SeriesDescription, SeriesNumber, EchoTime or ImageType; they are applied last.

Returns:

One per image, InstanceNumber counting from 1.

Return type:

list of pydicom.Dataset

Raises:

TypeError – If the image is complex: write its magnitude, phase, real or imaginary part as a series of its own.