How does one set the PatientPosition and other spatial attributes when writing a dicom CT volume?
25 views (last 30 days)
Show older comments
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.5.1.4.1.1.2';
info.PixelSpacing = [1,1]; % x & y voxel size
info.SliceThickness =1; % optional
info.SpacingBetweenSlices = 1;
info.ImageOrientationPatient = [1,0,0,0,-1,0];
info.PatientPosition='HFS';
status=dicomwrite(ones(250,250,1,250),'out.DCM', info,'CreateMode','copy','ObjectType',...
'CT Image Storage','MultiframeSingleFile',1);
info=dicominfo('out.DCM');
Clearly, the write operation produced a DICOM file containing a PatientPosition attribute because,
info.PatientPosition
Why then, does dicomreadVolume complain?
V=dicomreadVolume('out.DCM');
4 Comments
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.
Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!