Generate DICOM file sequence from Matlab

I am trying to generate a sequence of images as DICOM file from matlab, to be used later by other DICOM viewers.
The basic commands are
for j=1:20
image=uint8(2^8*rand(512,512));
dicomwrite(image, ['d:\test\c',num2str(j),'.dcm']);
end
I cannot import metadata from other DICOM files, to be used as a model.
Which parameters of metadata I should manually edit in order to have a sequence that could be seen as a 3D and/or slices by other DICOM viewer?
Because with DICOM viewer I sees the files as as a sequence of images, but I cannot make slices or 3d visualization

3 commentaires

Rik
Rik le 11 Sep 2019
I'm going to give you the answer you probably won't like: that depends. You should probably at least make sure the seriesUID is the same between the slices. What other fields you need to set yourself depends on your application (kind of images/your field) and on the software you're planning to use.
Massimo
Massimo le 11 Sep 2019
Modifié(e) : Massimo le 12 Sep 2019
Thank you for the answer.
The DICOM viewer is RadiAnt Dicom Viewer.
The images are exactly the ones in my example, and I want to see the slices in the three directions.
The updated commands would be
uid1 = dicomuid;
uid2 = dicomuid;
for k=1:20
image=uint8(2^8*rand(512,512));
info.InstanceNumber=k;
info.SeriesInstanceUID = uid1;
info.StudyInstanceUID=uid2;
dicomwrite(image, ['d:\test\c',num2str(k),'.dcm']);
end
I can see the images in RadiAnt as a sequence, but the slice (MPR Multi Planar Reconstruction) is not activated. I believe that I should add manually some parameters in the metadata . Which ones?
I don't have enough experience with radiant to be able to tell you. I do notice that you probably have a typo in your code:
info.InstanceNumber=i;%j is the loop iterator
I would advise you to avoid i and j as loop iterators, because they could potentially clash with the imaginary units 1i and 1j.

Connectez-vous pour commenter.

Réponses (1)

raym
raym le 26 Sep 2023
Yes this SeriesInstanceUID and StudyInstanceUID solved my problem.
I think to get 3D volume you may need other parameters like voxel 3D info.
info.SeriesNumber=SN;
info.AcquisitionNumber=SN;
info.StudyDate=today;
info.StudyID=num2str(SN);
info.PatientID=num2str(SN);
info.PatientPosition='HFS';
info.AccessionNumber=num2str(SN);
info.StudyDescription=['StudyMAT' num2str(SN)];
info.SeriesDescription=['StudyMAT' num2str(SN)];
info.Manufacturer='Matlab Convert';
info.SliceThickness=volscale(3);
info.PixelSpacing=volscale(1:2);
info.SliceLocation=0;
info.SeriesInstanceUID = uid1;
info.StudyInstanceUID = uid2;
info.InstanceNumber = slicenum;
info.SliceLocation = info.SliceLocation+volscale(3);

Catégories

En savoir plus sur DICOM Format dans Centre d'aide et File Exchange

Produits

Question posée :

le 11 Sep 2019

Réponse apportée :

le 26 Sep 2023

Community Treasure Hunt

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

Start Hunting!

Translated by