Dear SPMers,
I am trying to do global calculation for segmented c1 image of a subject . I am not getting the result. It is asking to define nan_out. How to define this function? Please see the script below which i used to do global calculation .(I have attached the same as text file) .
>> v = spm_vol (spm_select(Inf,'image'))
v =
fname: [1x94 char]
mat: [4x4 double]
dim: [256 256 146]
dt: [2 0]
pinfo: [3x1 double]
n: [1 1]
descrip: 'Tissue class 1'
private: [1x1 nifti]
>> if use_mask > 0,
V_mask = spm_vol(mask);
end
>> gl = zeros(length(V),2);
>> % make output numbers long floats, for precision
>> format long;
>> for i=1:size(gl,1),
Ntotal=0;
for z=1:V(i).dim(3),
img = spm_slice_vol(V(i),spm_matrix([0 0 z]),V(i).dim(1:2),0);
if use_mask > 0,
mask_img = spm_slice_vol(V_mask,spm_matrix([0 0 z]),V_mask.dim(1:2),0);
[X,N] = nan_out(img.*(mask_img>0));
else
[X,N] = nan_out(img);
end
Ntotal=Ntotal+N;
gl(i,1) = gl(i,1) + sum(X(:));
fprintf('.');
end;
voxvol = abs(det(V(1).mat))/100^3; % volume of a voxel, in litres
gl(i,2) = gl(i,1) * voxvol;
fprintf('\n');
outcount=['volume ' num2str(i) ' had ' num2str(Ntotal) ' NaN voxels\n'];
fprintf(outcount);
end;
??? Undefined command/function 'nan_out'.
>> v = spm_vol (spm_select(Inf,'image'))
v =
fname: [1x94 char]
mat: [4x4 double]
dim: [256 256 146]
dt: [2 0]
pinfo: [3x1 double]
n: [1 1]
descrip: 'Tissue class 1'
private: [1x1 nifti]
>> if use_mask > 0,
V_mask = spm_vol(mask);
end
>> gl = zeros(length(V),2);
>> % make output numbers long floats, for precision
>> format long;
>> for i=1:size(gl,1),
Ntotal=0;
for z=1:V(i).dim(3),
img = spm_slice_vol(V(i),spm_matrix([0 0 z]),V(i).dim(1:2),0);
if use_mask > 0,
mask_img = spm_slice_vol(V_mask,spm_matrix([0 0 z]),V_mask.dim(1:2),0);
[X,N] = nan_out(img.*(mask_img>0));
else
[X,N] = nan_out(img);
end
Ntotal=Ntotal+N;
gl(i,1) = gl(i,1) + sum(X(:));
fprintf('.');
end;
voxvol = abs(det(V(1).mat))/100^3; % volume of a voxel, in litres
gl(i,2) = gl(i,1) * voxvol;
fprintf('\n');
outcount=['volume ' num2str(i) ' had ' num2str(Ntotal) ' NaN voxels\n'];
fprintf(outcount);
end;
??? Undefined command/function 'nan_out'.
|