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 touint16over the whole series andRescaleSlopeandRescaleInterceptrecover 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.xruns along the rows,ydown 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 newSeriesInstanceUID.**fields – DICOM keywords and values set on every image, such as
SeriesDescription,SeriesNumber,EchoTimeorImageType; they are applied last.
- Returns:
One per image,
InstanceNumbercounting 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.