getPhotome​tricInterp​retation error when using MultiframeSingleFile option in dicomwrite

25 vues (au cours des 30 derniers jours)
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?

Réponse acceptée

James Scuffham
James Scuffham le 30 Juil 2012
After looking into this some more, I have found the very obvious answer.
Matlab stores DICOM data in a 4D array; the first two dimensions are rows and columns, the third dimension is "colour", and the fourth dimension represents slices.
At some point in my code, I had done:
squeeze(X)
to remove the singleton third dimension. Re-writing the dicomwrite code as follows solves the problem:
dicomwrite(reshape(X,[64 64 1 64]), info, 'CreateMode', 'Copy', 'MultiframeSingleFile', 'true');
  2 commentaires
Brett Shoelson
Brett Shoelson le 27 Juin 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
Ramaprasad Kulkarni le 20 Oct 2013
In fact the MultiframeSingleFile option is not required since the option 'true' is default (unless you want to specify it for best practices).

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Introduction to Installation and Licensing dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by