dke-questions
dke-questions > RE: Reconstructing fa.nii from DT.mat and KT.mat
Aug 29, 2015 06:08 PM | Russell Glenn - Medical University of South Carolina
RE: Reconstructing fa.nii from DT.mat and KT.mat
Hi Christina,
You just need to calculate the fa parameter for each column of the DT.mat matrix and then reconstruct the image. One potential solution if you have MATLAB is to download spm8 and then run the script below. Alternatively, you may reconstruct the diffusion tensor for each voxel; dt = [DT(1,i) DT(4,i) DT(5,i);DT(4,i) DT(2,i) DT(6,i);DT(5,i) DT(6,i) DT(3,i)];, and then get the eigenvalues and solve the conventional equation. Hope that helps...
Best,
Russell
%fn_img: file path 'template' image (.nii) (eg b0 3D or 4D)
%fn_dt: file path to DT.mat (.mat)
%fn_fa: file path to new fa image to write (.nii)
hdr = spm_vol(fn_img);
load(fn_dt)
idx = sqrt(sum(DT.^2))>0;
fa = zeros(1,prod(hdr(1).dim(1:3)));
fa(idx) = sqrt(3.*sum([DT(1:3,idx)-repmat(sum(DT(1:3,idx))./3,3,1);repmat(DT(4:6,idx),2,1)].^2)./...
sum([DT(1:3,idx);repmat(DT(4:6,idx),2,1)].^2)./2);
hdr(1).fname = fn_fa;
hdr(1).dt = [16 0];
spm_write_vol(hdr(1),reshape(fa,hdr(1).dim(1:3)));
You just need to calculate the fa parameter for each column of the DT.mat matrix and then reconstruct the image. One potential solution if you have MATLAB is to download spm8 and then run the script below. Alternatively, you may reconstruct the diffusion tensor for each voxel; dt = [DT(1,i) DT(4,i) DT(5,i);DT(4,i) DT(2,i) DT(6,i);DT(5,i) DT(6,i) DT(3,i)];, and then get the eigenvalues and solve the conventional equation. Hope that helps...
Best,
Russell
%fn_img: file path 'template' image (.nii) (eg b0 3D or 4D)
%fn_dt: file path to DT.mat (.mat)
%fn_fa: file path to new fa image to write (.nii)
hdr = spm_vol(fn_img);
load(fn_dt)
idx = sqrt(sum(DT.^2))>0;
fa = zeros(1,prod(hdr(1).dim(1:3)));
fa(idx) = sqrt(3.*sum([DT(1:3,idx)-repmat(sum(DT(1:3,idx))./3,3,1);repmat(DT(4:6,idx),2,1)].^2)./...
sum([DT(1:3,idx);repmat(DT(4:6,idx),2,1)].^2)./2);
hdr(1).fname = fn_fa;
hdr(1).dt = [16 0];
spm_write_vol(hdr(1),reshape(fa,hdr(1).dim(1:3)));
Threaded View
Title | Author | Date |
---|---|---|
Christina Gancayco | Aug 28, 2015 | |
Russell Glenn | Aug 29, 2015 | |
westkl | May 23, 2017 | |
Russell Glenn | May 23, 2017 | |
westkl | May 24, 2017 | |
Christina Gancayco | Sep 8, 2015 | |