getPhotometricInterpretation error when using MultiframeSingleFile option in dicomwrite
Afficher commentaires plus anciens
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 commentaire
Sujit Sinha
le 23 Août 2024
I was facing the same problem with photometric interpretation which was solved after changing the line in dicom_prep_ImagePixel function
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Read and Write Image Data from Files dans Centre d'aide et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!