Saving Axial Slicing from Sagittal DICOM MRI Images

9 次查看(过去 30 天)
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:
axial_broken.jpg
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.

回答(2 个)

Anjani kowsik Padmanabhuni
编辑:Anjani kowsik Padmanabhuni 2020-1-30
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 个评论
Yohanes Setiawan
Yohanes Setiawan 2020-2-6
Hi Anjani,
You can use Python for slicing the MRI into what you want. Maybe MATLAB has bugs for this. I work in Python with same code in Numpy and PyDicom and it has been worked! Then saved in into .jpg from Python.
After that, I continue with other work in MATLAB.
akshay Pillai
akshay Pillai 2020-12-3
@Anjani, @Yohanes, can you please share the python code you used if you were successful for this. Please and thank you.

请先登录,再进行评论。


ERDEM BALCI
ERDEM BALCI 2023-9-29
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.

类别

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