How to display images from nifti file format in Matlab?

조회 수: 213 (최근 30일)
Matthew Worker
Matthew Worker 2020년 5월 20일
편집: John Kelly 2023년 12월 7일
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
Diannira Sasri Apsari 2020년 9월 3일
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
Emerson Nithiyaraj 2020년 9월 4일
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