
How to display images from nifti file format in Matlab?
    39 次查看(过去 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. 
1 个评论
  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 :

Hope that helps!
回答(1 个)
  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
 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
 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 Exchange 中查找有关 Neuroimaging 的更多信息
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!