dwidenoise influencing downstream mask registrations

Hello,

I used dwidenoise to denoise just the DWI images (using .nii.gz; there were no errors so I assume it ran just fine). All subsequent processing was done in FSL using topup, eddy_openmp, and flirt primarily.

Fractional anisotropy values were extracted for all subjects based on our white matter masks using flirt except for one subject. I used flirt to register masks in standard space (JHU atlas) to a combined subject and standard space we refer to as DTI space. One of the inputs to flirt was an transformation matrix of standard MNI 152 space to our DTI space, which had much larger values for this subject in particular. Further all the masks were the same file size and non appeared on the FSL image viewer, subsequently resulting in 0 FA values for each tract.

I reran this subject without denoising the the inverse transformation matrix appeared normal, resulting in normal masking and FA output.

If the problem lies with a possible effect of denoising on downstream transformation/registrations for this particular subject, any insight would be helpful since there were no errors to guide troubleshooting. Many thanks in advance.

Best,
Kevin

Here are my C scripts (I’ve bolded where the error occurs as well as the inverse transformation matrix):

Preprocessing (with denoising):

#!/bin/bash
diri=/space/kmsyn01/data/MRI_SDSU/orig
diro=/space/kmsyn01/projects/BINGE/DTI_Binge/analysis/Run_22

subj_list="B089"

for i in $subj_list
do
# subject directory
subj_diri=$diri/$i
subj_diro=$diro/$i

cd $subj_diri/
#cd DTI_64D_2MM_3_SMS2
cd 24*
mkdir $subj_diro
dcm2nii -o $subj_diro *.0001*
mv $subj_diro/*.nii.gz $subj_diro/dti.nii.gz
mv $subj_diro/*.bval $subj_diro/bvals
mv $subj_diro/*.bvec $subj_diro/bvecs

#cd ../DTI_64D_2MM_3_JUSTB0
cd ../27*
dcm2nii -o $subj_diro *.0001*
mv $subj_diro/*27*.nii.gz $subj_diro/bup.nii.gz
#cd ../DTI_64D_2MM_3_ROTB0
cd ../28*
dcm2nii -o $subj_diro *.0001*
mv $subj_diro/*28*.nii.gz $subj_diro/tdn.nii.gz
#cd ../T1_MPRAGE
cd ../02*
mri_convert *.0001* $subj_diro/mprage.nii.gz
# reorient procedures T1
cd $subj_diro/
fslswapdim mprage.nii.gz z -x -y mprage_reorient.nii.gz

# denoise dwi image
dwidenoise dti.nii.gz dti_denoised.nii.gz -noise noise.nii.gz
mrcalc dti.nii.gz dti_denoised.nii.gz -subtract res.nii.gz

# top up  + eddy current correction DTI dat
fslroi bup b0_bup 0 1
fslroi tdn b0_tdn 0 1
fslmerge -t b0 b0_bup b0_tdn 
printf "0 1 0 0.087\n0 -1 0 0.087" > acqparams.txt 
topup --imain=b0 --datain=acqparams.txt --config=b02b0.cnf --out=my_topup_results --iout=my_hifi_b0

fslmaths my_hifi_b0 -Tmean my_hifi_b0
bet my_hifi_b0 b0_brain -m 

indx=""
for ((i=1; i<=138; i+=1)); do indx="$indx 1"; done
echo $indx > index.txt

#copy dwi image dimensions in header to b0 mask
fslcpgeom dti_denoised.nii.gz b0_brain_mask.nii.gz -d

# eddy correction DTI data
eddy_openmp --imain=dti_denoised.nii.gz --mask=b0_brain_mask.nii.gz --bvecs=bvecs --bvals=bvals --acqp=acqparams.txt --index=index.txt --topup=my_topup_results --repol --cnr_maps --out=dti_eddy.nii.gz 

# reorient procedures dti data eddy corrected
cp $subj_diro/dti_eddy.nii.gz.eddy_rotated_bvecs $subj_diro/bvecs_rot
cp $diro/transpose.sh $subj_diro/transpose.sh
sh transpose.sh bvecs_rot > bvecs_rot_t
sh transpose.sh bvals > bvalst
paste -d" " bvecs_rot_t bvalst > $i.txt
tail -128 $i.txt > 128$i.tx

# bet DTI data
bet dti_eddy.nii.gz nodif_brain -f 0.3 -g 0 -n -m

# DTIfit data
dtifit --data=dti_eddy.nii.gz --out=dti --mask=nodif_brain_mask.nii.gz --bvecs=bvecs_rot --bvals=bvals
done

Processing/Mask Registrations:

#!/bin/bash

diro=/space/kmsyn01/projects/BINGE/DTI_Binge/analysis/Run_22/testing/nodenoise

subj_list="B089"
     
for i in $subj_list
do
# subject directory
subj_diro=$diro/$i
cd $subj_diro/

# bet T1
bet mprage_reorient.nii.gz mprage_reorient_brain -B -f 0.3 -g 0 -n -m

# take T1, mask it with brain
fslmaths mprage_reorient -mul mprage_reorient_brain_mask.nii.gz mprage_reorient_brain

# register FA to MPRAGE with mutual information cost function
flirt -cost mutualinfo -dof 12 -in dti_FA.nii.gz -ref mprage_reorient_brain.nii.gz -omat dti2mprage.mat

# register MPRAGE to MNI152_T1
flirt -in mprage_reorient_brain.nii.gz -ref /space/kmsyn01/pubsw/packages/fsl/fsl-4.0.0_64/data/standard/MNI152_T1_2mm_brain.nii.gz -omat mprage2std.mat

# combine transformation matrices
convert_xfm -omat dti2std.mat -concat mprage2std.mat dti2mprage.mat

# create inverse (MNI space to subject's diffusion space)
convert_xfm -omat **std2dti.mat** -inverse dti2std.mat

mkdir ROI_tracts
**for n in {1..16}; do flirt -in /space/kmsyn01/projects/BINGE/DTI_Binge/analysis/masks/masks_run22/numbered/tract$n.nii.gz -ref dti_FA.nii.gz -applyxfm -init std2dti.mat -out ROI_tracts/tract$n.nii.gz**; 
fslmaths ROI_tracts/tract$n.nii.gz -thr 0.5 -bin ROI_tracts/tract$n.nii.gz; #new, any voxel in new space that overlaps by 50% will be included in new binary mask
fslmeants -i dti_FA -m ROI_tracts/tract$n.nii.gz -o ROI_FA_val.txt 
cat ROI_FA_val.txt >> ROI_FA_val_new.txt
done

mkdir ROI_tracts_MD
for n in {1..16}; do flirt -in /space/kmsyn01/projects/BINGE/DTI_Binge/analysis/masks/masks_run22/numbered/tract$n.nii.gz -ref dti_MD.nii.gz -applyxfm -init std2dti.mat -out ROI_tracts_MD/tract$n.nii.gz;
fslmaths ROI_tracts_MD/tract$n.nii.gz -thr 0.5 -bin ROI_tracts_MD/tract$n.nii.gz;
fslmeants -i dti_MD -m ROI_tracts_MD/tract$n.nii.gz -o ROI_MD_val.txt
cat ROI_MD_val.txt >> ROI_MD_val_new.txt
done

mkdir ROI_tracts_AD
for n in {1..16}; do flirt -in /space/kmsyn01/projects/BINGE/DTI_Binge/analysis/masks/masks_run22/numbered/tract$n.nii.gz -ref dti_L1.nii.gz -applyxfm -init std2dti.mat -out ROI_tracts_AD/tract$n.nii.gz;
fslmaths ROI_tracts_AD/tract$n.nii.gz -thr 0.5 -bin ROI_tracts_AD/tract$n.nii.gz;
fslmeants -i dti_L1 -m ROI_tracts_AD/tract$n.nii.gz -o ROI_AD_val.txt
cat ROI_AD_val.txt >> ROI_AD_val_new.txt
done

mkdir ROI_tracts_L2
for n in {1..16}; do flirt -in /space/kmsyn01/projects/BINGE/DTI_Binge/analysis/masks/masks_run22/numbered/tract$n.nii.gz -ref dti_L2.nii.gz -applyxfm -init std2dti.mat -out ROI_tracts_L2/tract$n.nii.gz;
fslmaths ROI_tracts_L2/tract$n.nii.gz -thr 0.5 -bin ROI_tracts_L2/tract$n.nii.gz;
fslmeants -i dti_L2 -m ROI_tracts_L2/tract$n.nii.gz -o ROI_L2_val.txt
cat ROI_L2_val.txt >> ROI_L2_val_new.txt
done

mkdir ROI_tracts_L3
for n in {1..16}; do flirt -in /space/kmsyn01/projects/BINGE/DTI_Binge/analysis/masks/masks_run22/numbered/tract$n.nii.gz -ref dti_L3.nii.gz -applyxfm -init std2dti.mat -out ROI_tracts_L3/tract$n.nii.gz;
fslmaths ROI_tracts_L3/tract$n.nii.gz -thr 0.5 -bin ROI_tracts_L3/tract$n.nii.gz;
fslmeants -i dti_L3 -m ROI_tracts_L3/tract$n.nii.gz -o ROI_L3_val.txt
cat ROI_L3_val.txt >> ROI_L3_val_new.txt
done

done

Dear Kevin,

We will need more information to figure out what’s going on. All I can say for now, is that the issue seems to arise in the FA to MPRAGE registration, i.e.:

Have you looked at the file dti_FA.nii.gz, with and without denoising? Do you notice a clear change in contrast, or an artefact of some sort? Could you perhaps post a screenshot?

If the FA map looks normal, the problem is with FSL Flirt, which is not part of MRtrix and therefore not something we can offer support for.

If there is an issue with the FA map after denoising, my first guess would be that there are negative image intensity values in the output of dwidenoise. This is not wrong but violates the usual assumption of magnitude-reconstructed dMRI data, so it might trip up certain external software packages. Would you mind double checking what the FA looks like when calculated with MRtrix (dwi2tensor dti_eddy.nii.gz -fslgrad bvecs_rot bvals_rot -mask nodif_brain_mask.nii.gz - | tensor2metric - -fa dti_FA_mrtrix.nii.gz)?

Cheers,
Daan