How to display images from nifti file format in Matlab?

216 ビュー (過去 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 Center および File ExchangeMRI についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by