Storing a 5D data in dicom files

5 次查看(过去 30 天)
Jast
Jast 2023-11-9
Hi,
I have a 5D data structure in matlab from an experimental ultrasound system. I have intensity values for X, Y, Z, Time and Frequency. I want to store this in a DICOM format for easy exchange with other applications. Ideally, I'd store the data in a 5D structure, and a DICOM viewer allows me to scrub through all the axes independently. But maybe I have to resort to 4D and separate files (X, Y, Z, T, and a file per frequency would be the natural ordering).
I struggle with getting dicomwrite to work. I tried various ways of setting the info struct of dicomwrite, but I still fail:
dicomtest = int16(rand( 256,256,2, 25));
info = dicominfo("CT-MONO2-16-ankle.dcm"); % Load a DICOM template file for metadata (you can create your own)
info.Rows = 256;
info.Columns = 256;
info.SamplesPerPixel = 2;
info.NumberOfFrames = 25;
dicomwrite( dicomtest, 'test.dcm', info )
I get the error
Error using images.internal.dicom.dicom_prep_ImagePixel>getPhotometricInterp
Cannot determine photometric interpretation.
Could anyone point me in the right direction on how to proceed? In the example given, I have voxel data of dimensions 256 in X, 256 in Y and 2 in Z, and 25 time frames. I have multiples of these 4D objects for various frequencies.
Thanks!
  2 个评论
Cris LaPierre
Cris LaPierre 2023-11-9
Not super familiar with dicoms and dicomwrite, so I'll just comment on the size of your input.
From the doc for dicomwrite, your input image X can be a 2D, 3D, or 4D array, but not 5D:
X DICOM image
m-by-n matrix | m-by-n-by-3 array | 4-D array
DICOM image, specified as one of these options:
  • An m-by-n matrix representing a single-frame grayscale image, or an indexed image.
  • An m-by-n-by-3 array representing a single-frame truecolor (RGB) image.
  • A 4-D array representing a multiframe image.
Cris LaPierre
Cris LaPierre 2023-11-9
编辑:Cris LaPierre 2023-11-9
As for your example code, I see 2 issues.
1. An int16 has integer values ranging from 0 to 65535. rand creates random, non integer numbers between 0 and 1. Your text image will only have 0s and 1s, then. Consider using randi instead.
2. The error is caused by the Z dimension. You must either have an intensity image (dim = 1), or an rgb image (dim = 3). MATLAB does not know what to do when this dim = 2
dicomtest = int16(randi(65535, 256,256,3, 25));
info = dicominfo("CT-MONO2-16-ankle.dcm"); % Load a DICOM template file for metadata (you can create your own)
info.Rows = 256;
info.Columns = 256;
info.SamplesPerPixel = 3;
info.NumberOfFrames = 25;
dicomwrite( dicomtest, 'test.dcm', info )
I am not sure what the correct way is to capture and store SamplesPerPixel. Is that your 2 different frequencies? Might need to create a separate dicom for each frequency.

请先登录,再进行评论。

回答(1 个)

Cris LaPierre
Cris LaPierre 2023-11-9
移动:Cris LaPierre 2023-11-9
It would appear that the DICOM standard specifies what values Samples Per Pixel can take. It appears that it can either be 1 (intensity images) or 3 (color images).

类别

Help CenterFile Exchange 中查找有关 DICOM Format 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by