% The splic(x,y,z,t) function is used to open and view different slices of
% a .nii file. x, y and z are variables which define the point where the
% slices will be taken. The slices will be saggital, coronal and horizontal.
%All three slices are shown in a single figure. t stands for the path of
%the .nii file you wish to view. splic uses the load_nii function made
%available by Jimmy Shen in the "Tools for NIfTI and ANALYZE image",
%created on 23 Oct 2005. For the load_nii function to work properly, the
%entire path should be entered as t in the function.Otherwise, load_nii
%might not be able to find the file.
A=load_nii(t); % The .nii file is loaded and defined as A.
a=A.img; % The image of the function A is defined as a.
b=a(x,:,:); %Here, b is defined as the slice taken at all the points
%where the x values are equal to the user entered x.
c=a(:,y,:); %Here, c is defined as the slice taken at all the points
%where the y values are equal to the user entered y.
d=a(:,:,z); %Here, d is defined as the slice taken at all the points
%where the z values are equal to the user entered z.
b=squeeze(b); %All three must be aqueezed to remove possible 1 unit sides
c=squeeze(c); %that sould interfere with displaying b, c and d as images.
colormap(gray) %Colormap is set default to gray. This can be changed.
subplot (2,2,1), imagesc(b) %Here, all three images are plotted on a single
subplot (2,2,2), imagesc(c) %figure, and the colorbars are scaled for best
subplot (2,2,3), imagesc(d) %visuality. The first image defined by b will
%show the saggital section at the point. The second image, defined by c,
%will show the coronal section at the point. The final image, defined by d,
%will sho the horizontal section of the point.