How to display images from nifti file format in Matlab?

175 次查看(过去 30 天)
I have a COVID-19 CT segmentation dataset where all images are in .nii file format. Each image file has mulitple slices (512*512*100). Using niftiread command Matlab i read the image file and now I want to visualizing each of the 100 slices one by one in Matlab.
The dataset is available on the site http://medicalsegmentation.com/covid19/
  1 个评论
Tanguy
Tanguy 2020-9-14
编辑:John Kelly 2023-12-7
imtool3D_td would perfectly fit your needs, and also display Mask with edit tools (ex: brush tool).
Simply run the following command after adding imtool3D_td to your Matlab path:
V = niftiread('niftifile.nii')
Mask = niftiread('mask.nii')
tool = imtool3D(V);
tool.setMask(Mask);
Use scrollwheel to go through slices.
You should get this :
Other examples on the github page or the help function of imtool3D.m Good luck
Hope that helps!

请先登录,再进行评论。

回答(1 个)

Emerson Nithiyaraj
Emerson Nithiyaraj 2020-5-20
After you read the Nifti file using niftiread, you could visualize each slice one by one using the below command,
V = niftiread('niftifile.nii');
c = V(:,:,n); %n is the slice number that you want to visualize.
imshow(c,[])
Or else there is an online tool ,Papaya: a pure JavaScript medical research image viewer, supporting DICOM and NIFTI formats, compatible across a range of web browsers. So this is like an radiologist assist tool where you could have a better understanding about the nifti file here rather than reading slices one by one using Matlab.
  2 个评论
Diannira Sasri Apsari
I need to display .nii file on specific slice but the output is blank. How to solve it?
This is my code
for j=3
V = niftiread('label0001.nii');
info = niftiinfo('label0001.nii');
refImage = V(:,:,j);
imshow(refImage,[])
title('Ground Truth Image');
end
Emerson Nithiyaraj
You have used 'j' as the slice number. So 'j' denotes the particular slice number that you want to display. For example if you want to display the 100th slice;
Try this code
V = niftiread('label0001.nii');
info = niftiinfo('label0001.nii');
j = 100;
refImage = V(:,:,j);
imshow(refImage,[])
If you want to display groundtruth try,
V = niftiread('label0001.nii');
info = niftiinfo('label0001.nii');
j = 100;
refImage = V(:,:,j);
imshow(refImage)
Still if you have problem, convert the data format of the particular slice to int16 or int8.
Please let me know the feedback.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 MRI 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by