How does one set the PatientPosition and other spatial attributes when writing a dicom CT volume?

17 views (last 30 days)
Matt J
Matt J on 25 Jan 2022
Commented: Rik on 26 Jan 2022
I am trying to write DICOMs of a CT volume in both single- and multi-file form. To check that the result is readable, I try reading the file(s) back in with dicomreadVolume(). Below is one such attempt.
info.StudyDescription = 'Description';
info.SOPClassUID = '1.2.840.10008.';
info.PixelSpacing = [1,1]; % x & y voxel size
info.SliceThickness =1; % optional
info.SpacingBetweenSlices = 1;
info.ImageOrientationPatient = [1,0,0,0,-1,0];
status=dicomwrite(ones(250,250,1,250),'out.DCM', info,'CreateMode','copy','ObjectType',...
'CT Image Storage','MultiframeSingleFile',1);
Warning: The 'SOPClassUID' and 'ObjectType' parameters are ignored when 'CreateMode' is 'copy'.
Clearly, the write operation produced a DICOM file containing a PatientPosition attribute because,
ans = 'HFS'
Why then, does dicomreadVolume complain?
Error using images.internal.dicom.getSeriesDetails>throwMissingPatientPosition (line 140)
File "out.DCM" must contain the attribute 'PatientPosition'.

Error in images.internal.dicom.getSeriesDetails (line 29)

Error in dicomreadVolume (line 101)
[seriesFilenames, spatialInfo, sliceDim] = images.internal.dicom.getSeriesDetails(filenames);
Rik on 26 Jan 2022
I just followed the execution to a few lines before the error is thrown. The code tries to determine these two values. I haven't googled them to see if they are actual DICOM attributes, or just internal Matlab ones. At any rate, those two are empty, leading to the error you see. The strange thing is that the object in the workspace of that function actually does contain the PatientPosition. So the error message is incorrect. I can't tell if this is a bug or not.

Sign in to comment.

Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by