dke-questions > Reconstructing fa.nii from DT.mat and KT.mat
Showing 1-6 of 6 posts
Aug 28, 2015 08:08 PM | Christina Gancayco
Reconstructing fa.nii from DT.mat and KT.mat
Hello,
I was wondering how one would reconstruct the FA map from the diffusion and kurtosis tensor MAT files? I ran the DKE for several subjects but left the map interpolation on, and I was hoping reconstructing fa.nii would be faster than running the DKE again without map interpolation.
Thanks!
Christina
I was wondering how one would reconstruct the FA map from the diffusion and kurtosis tensor MAT files? I ran the DKE for several subjects but left the map interpolation on, and I was hoping reconstructing fa.nii would be faster than running the DKE again without map interpolation.
Thanks!
Christina
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)));
Sep 8, 2015 07:09 PM | Christina Gancayco
RE: Reconstructing fa.nii from DT.mat and KT.mat
Worked like a charm. Thanks!
May 23, 2017 06:05 PM | westkl
RE: Reconstructing fa.nii from DT.mat and KT.mat
Can you provide matrix definition similar to 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)];,
for the kurtosis tensor (KT)?
Thanks!
Kathryn
Thanks!
Kathryn
May 23, 2017 07:05 PM | Russell Glenn
RE: Reconstructing fa.nii from DT.mat and KT.mat
Hi Kathryn,
Sure. Each column is given by
W(:,i) = [W1111, W2222, W3333, W1112, W1113, W1222, W1333, W2223,W2333, W1122, W1133, W2233, W1123, W1223, W1233]^T, where W is the kurtosis tensor for the ith voxel.
Best,
Russell
Sure. Each column is given by
W(:,i) = [W1111, W2222, W3333, W1112, W1113, W1222, W1333, W2223,W2333, W1122, W1133, W2233, W1123, W1223, W1233]^T, where W is the kurtosis tensor for the ith voxel.
Best,
Russell