cast() convert image to struct

1 次查看(过去 30 天)
Hai Phan
Hai Phan 2020-4-23
Hi,
I have nifti image with size (198 x 208 x 1 x 50), Bytes(8236800), Class(Single). And I wanted to change the class to Int16 using the function cast() here is my code :
V = niftiread('la_2ch.nii.gz'); % Read the nifti image
whos V % print size and data type of image
Z=cast(V,'int16'); % Convert the single-precision float data type to UInt16
% because this is one of the compatible format for the
% input of dicomwrite.
A=dicomwrite(Z,'la_2ch.dcm_Int16');% Writing to Dicom
whos A
And this the the result for A
Name Size Bytes Class Attributes
A 1x1 1508 struct
How do I use cast() and still get the size (198x208x1x50) and class (int16) so I can display 50 frames in DICOM instead of having one single image which I don't know its meaning.

回答(1 个)

Raunak Gupta
Raunak Gupta 2020-4-28
Hi,
The A returned after using dicomwrite tell about the metadata that is used to generate the dicom file. As you can see by running
whos V
it returns a (198 x 208 x 1 x 50) int16 matrix which is exactly what is required. Also, by running the dicomwrite command you can see 'la_2ch.dcm_Int16' file created in current working folder. The image that is converted to int16 is Z and not A which is mere metadata file.

类别

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