Saving Axial Slicing from Sagittal DICOM MRI Images

9 visualizaciones (últimos 30 días)
Yohanes Setiawan
Yohanes Setiawan el 11 de Sept. de 2019
Respondida: ERDEM BALCI el 29 de Sept. de 2023
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.

Respuestas (2)

Anjani kowsik Padmanabhuni
Anjani kowsik Padmanabhuni el 30 de En. de 2020
Editada: Anjani kowsik Padmanabhuni el 30 de En. de 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 comentarios
Yohanes Setiawan
Yohanes Setiawan el 6 de Feb. de 2020
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 el 3 de Dic. de 2020
@Anjani, @Yohanes, can you please share the python code you used if you were successful for this. Please and thank you.

Iniciar sesión para comentar.


ERDEM BALCI
ERDEM BALCI el 29 de Sept. de 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.

Categorías

Más información sobre DICOM Format en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by