Saving Axial Slicing from Sagittal DICOM MRI Images

16 ビュー (過去 30 日間)
Yohanes Setiawan
Yohanes Setiawan 2019 年 9 月 11 日
回答済み: ERDEM BALCI 2023 年 9 月 29 日
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 日
編集済み: 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 Center および File ExchangeMedical Physics についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by