cast() convert image to struct
2 views (last 30 days)
Show older comments
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.
0 Comments
Answers (1)
Raunak Gupta
on 28 Apr 2020
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.
0 Comments
See Also
Categories
Find more on DICOM Format in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!