getPhotometricInterpretation error when using MultiframeSingleFile option in dicomwrite
12 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
James Scuffham
am 26 Jul. 2012
Kommentiert: Sujit Sinha
am 23 Aug. 2024
I have a 3D array in Matlab (64x64x64) representing a modified SPECT image. I am trying to write this to a single DICOM file using the new "MultiframeSingleFile" option in dicomwrite. My syntax is as follows:
dicomwrite(X, 'test.dcm', info, 'CreateMode', 'Copy', 'MultiframeSingleFile', 'true');
Here, "info" is the metadata from the original SPECT dataset, with a few modified tags (UIDs, SeriesDescription, etc). However, when I run this I get the following chain of errors:
Error using dicom_prep_ImagePixel>getPhotometricInterp (line 116)
Cannot determine photometric interpretation.
Error in dicom_prep_ImagePixel (line 10)
metadata.(dicom_name_lookup('0028', '0004', dictionary)) =
getPhotometricInterp(X, map, txfr);
Error in dicom_copy_IOD (line 32)
metadata = dicom_prep_ImagePixel(metadata, X, map, options.txfr,
dictionary);
Error in dicomwrite>write_message (line 268)
[attrs, status] = dicom_copy_IOD(X, map, ...
Error in dicomwrite (line 200)
[status, options] = write_message(X, filename, map, metadata,
options);
I tried explicitly defining:
info.PhotometricInterpretation = 'MONOCHROME2';
...but this doesn't help. If I take out the MultiframeSingleFile option, put the dicomwrite function in a for loop, and write each slice of the data as a separate file, it works correctly.
Digging into the various private Matlab functions responsible for the error, it seems that the Photometric Interpretation is defined inside the dicom_prep_ImagePixel function, and depends on the 3rd dimension of the data being written. If size(X,3) == 1, the photometric interpretation is set to "MONOCHROME2". If size(X,3) == 3, it is set to one of the various colour scales. This seems obviously wrong, since the 3rd dimension in my data is image slices and does not represent colour map data. This therefore seems to be a bug in the implementation of the MultiframeSingleFile option in dicomwrite. I therefore tried hard-coding the PhotometricInterpretation in dicom_prep_ImagePixel (line 10):
%metadata.(dicom_name_lookup('0028', '0004', dictionary)) = getPhotometricInterp(X, map, txfr);
metadata.(dicom_name_lookup('0028', '0004', dictionary)) = 'MONOCHROME2';
With this modification, the data saves without error, and can be re-read into Matlab correctly.
Has anyone else experienced this problem? Am I correct in thinking that this is a bug, or am I doing something else wrong?
1 Kommentar
Sujit Sinha
am 23 Aug. 2024
I was facing the same problem with photometric interpretation which was solved after changing the line in dicom_prep_ImagePixel function
Akzeptierte Antwort
James Scuffham
am 30 Jul. 2012
2 Kommentare
Brett Shoelson
am 27 Jun. 2013
[a,b,c] = size(X); dicomwrite(reshape(X,[a,b,1,c], info, 'CreateMode', 'Copy', ...'MultiframeSingleFile', true);
Note the change of 'true' to true (no quotes...it's a logical flag, not a string.)
Cheers,
Brett
Ramaprasad Kulkarni
am 20 Okt. 2013
In fact the MultiframeSingleFile option is not required since the option 'true' is default (unless you want to specify it for best practices).
Weitere Antworten (0)
Siehe auch
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!