Skip to content

dwifslpreproc

Jared Tanner edited this page May 27, 2024 · 22 revisions

These commands depended on the scanner/sequence. The Philips PA sequence required the mrgrid (reslicing to match geometry) command. The Prisma scans did not require this step.

All b values = 100 were manually changed in the bval files to 101. EDDY has problems with b=100. It's possible 100.01 might work but that has not been verified. Alternatively, the b=100 shells could be removed. The commands below are an example run for one participant's data at one time point.

This processing was tested most recently on a machine with an nvidia GPU running CUDA 12.0 and FSL 6.0.6.2. The eddy_cuda10.2 binaries called by the dwifslpreproc script successfully ran.

mrconvert COLON02_POST_dwi.nii.gz -fslgrad COLON02_POST_dwi.bvec COLON02_POST_dwi.bval dwi.mif

dwidenoise dwi.mif dwi_den.mif -noise noise.mif

mrdegibbs dwi_den.mif dwi_den_deg.mif

dwiextract dwi_den_deg.mif - -bzero | mrmath - mean mean_b0_AP.mif -axis 3

fslroi COLON02_POST_dwi_PA.nii.gz dwi_b0_PA.nii.gz 0 1

mrconvert dwi_b0_PA.nii.gz -fslgrad dwi_b0_PA.bvec dwi_b0_PA.bval dwi_b0_PA.mif #dwi_b0_PA.bvec and .bval files were copies of the dwi bvec and bvals that were edited to just include 0 0 0 and 0, respectively (with the bvec file having one column of three 0 values and not one row).

mrgrid dwi_b0_PA.mif regrid -template mean_b0_AP.mif b0_PA_resampled.mif #only necessary if the dimensions don't match exactly. Not an issue with our Siemens data.

mrcat mean_b0_AP.mif b0_PA_resampled.mif -axis 3 b0_pair.mif

dwifslpreproc dwi_den_deg.mif dwi_preproc.mif -nocleanup -pe_dir AP -rpe_pair -se_epi b0_pair.mif -eddy_options " --slm=linear --data_is_shelled" #--slm=linear might be needed when fewer than 60 directions. Our data have more than that but each shell has fewer than 60 directions so I kept this command in. I'm not sure what difference it makes not having it.

dwibiascorrect ants dwi_preproc.mif dwi_preproc_unbiased.mif -bias bias.mif

dwi2mask dwi_preproc_unbiased.mif mask.mif

mrview dwi_preproc_unbiased.mif

mrconvert dwi_preproc_unbiased.mif dwi_preproc_unbiased.nii.gz -export_grad_fsl dwi_preproc_unbiased.bvec dwi_preproc_unbiased.bval

Running this on the cluster requires additional steps

To run in an interactive session (not necessarily recommended but done for testing)

srun -p gpu --nodes=1 --gpus=a100:1 --time=05:00:00 --mem=6gb --pty -u bash -i #This requests one of the A100 GPUs with 6GB RAM for 5 hours

module load cuda gcc/5.2.0 ants fsl/6.0.6 mrtrix

#The order is important because if fsl is loaded too early we end up with an error. Loading fsl later in the list produced this message, which is what we want: "Lmod is automatically replacing "R/4.0" with "fsl/6.0.6". If you load fsl earlier, R/4.0 replaces fsl and that will result in nothing working. I'm not sure why this behavior occurs.

Running this from a SLURM script would include the following in the header

#SBATCH --partition=gpu

#SBATCH --gpus=a100:1

For freewater calculations it is best to use b values ≤ 1000. If you have multishell data with higher b values, you can extract the ones you want using this FSL tool following this sample command:

select_dwi_vols dwi_preproc_unbiased.nii.gz dwi_preproc_unbiased.bval dwi_preproc_unbiased_subset 0 -b 101 -b 400 -b 700 -b 1000 -obv dwi_preproc_unbiased.bvec