Thanks for your help
Can I use the program (attached) to get the jacobian determinant?
Thank you
function y2j
% Read a deformation field image and write a Jacobian determinant image
% Jon Koller 12 Dec 2008
%
Ptemp = spm_select(1,'any','Select a deformation image...','','','y.*');
% Ptemp = spm_select;
P = [repmat(Ptemp,3,1), [',1,1';',1,2';',1,3']];
V = spm_vol(P);
Def = cell(3,1);
Def{1} = spm_load_float(V(1));
Def{2} = spm_load_float(V(2));
Def{3} = spm_load_float(V(3));
mat = V(1).mat;
save_def(Def,mat,Ptemp)
return;
function save_def(Def,mat,fname)
% Save a deformation field as an image
dim = [size(Def{1},1) size(Def{1},2) size(Def{1},3) 1 3];
dtype = 'FLOAT32-BE';
off = 0;
scale = 1;
inter = 0;
dat = file_array(fname,dim,dtype,off,scale,inter);
% Write Jacobian determinants
[pth,nme,ext,num] = spm_fileparts(fname);
jfname = fullfile(pth,['j' nme '.nii']);
dt = spm_def2det(Def{:},mat);
dat = file_array(jfname,dim(1:3),dtype,off,scale,inter);
N = nifti;
N.dat = dat;
N.mat = mat;
N.mat0 = mat;
N.mat_intent = 'Aligned';
N.mat0_intent = 'Aligned';
N.intent.code = 'NONE';
N.intent.name = 'Det';
N.descrip = 'Jacobian Determinant';
create(N);
N.dat(:,:,:) = dt;
disp(['Jacobian determinant image written to ', jfname]);
return;
|