Saving Axial Slicing from Sagittal DICOM MRI Images
9 views (last 30 days)
Show older comments
I have MRI DICOM with default in sagittal. Below my code:
First, I load DICOM files and add them in array 3D:
file = dir('*.dcm');
NF = length(file);
images = cell(NF,1);
%NF is number of slices
for k = 1 : NF
images{k} = dicomread(file(k).name);
img2d = images{k};
img3d(:,:,k) = img2d;
end
Second, I take the first row of img3d to generate Axial slicing as below:
[row,col,slice] = size(img3d);
for i = 1:slice
gambar{i} = img3d(i,:,:);
end
Then, in command window I try to get the display image from gambar{100}
coba1=gambar{100} %this will have size 1x256x166 int16
coba2=permute(coba1,[1 3 2]) %this will have size 1x166x256 int16
coba3 = reshape(coba2,[],size(coba1,2),1) %this will have size 166x256 int16
coba4=coba3' %to get 256x166 int16
coba5 = uint8(255*mat2gray(coba4)) %convert it to 256x166 uint8
imshow(coba5) %display image from coba5
I get this picture:
My question is: Why it's broken? Am I wrong to generate Axial from defaul sagittal MRI?
Please help me. Iam new in medical image processing.
Thank you.
0 Comments
Answers (2)
Anjani kowsik Padmanabhuni
on 30 Jan 2020
Edited: Anjani kowsik Padmanabhuni
on 30 Jan 2020
Hi Yohanes Setiawan , i am also facing the same problem. did you get the solution for this? if yes, .can you please share the solution.
Thank you in advance.
2 Comments
akshay Pillai
on 3 Dec 2020
@Anjani, @Yohanes, can you please share the python code you used if you were successful for this. Please and thank you.
ERDEM BALCI
on 29 Sep 2023
The problem is that when reading dicom files, you must import them according to their tags. The order of the files is not according to their numbers. For example, the names of my files are IM0, IM1.. When you do it according to your code, it becomes intermittent.
filenames = dir('IM*');
file=filenames;
NF = length(file);
images = cell(NF,1);
.....
But
filenames = dir('IM*');
file=natsortfiles(filenames); % https://www.mathworks.com/matlabcentral/fileexchange/47434-natural-order-filename-sort
NF = length(file);
images = cell(NF,1);
......
However, in my case the order is compatible but it is not always the case. That's why the Instance Number in the dicom header is important for the section order.
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!