Commit ce355fce authored by Matthew K Defenderfer's avatar Matthew K Defenderfer
Browse files

Add README and example scripts

parent e8f5e10e
This project stores preprocessing and processing code for performing NODDI analysis (Zhang et al. 2011) at the PRL, URL, and LPZ in macular degeneration participants. Included are scripts setting up preprocessing using a basic FSL pipeline including topup and eddy. b0 images come from the diffusion scans themselves as opposed to SpinEcho fieldmaps. The NODDI toolbox used is version 1.01 that has been modified to remove status bar graphics and allow the pipeline to be run completely from the command line without needing the MATLAB GUI.
Scripts of interest are diff_preprocess.m that does basic file management and sets up the bash script to perform topup and eddy as well as noddi_MASTER that sets up the bash script to run NODDI.
Example preprocessing, NODDI processing, and registration scripts can be found in example-bash-scripts for one subject.
......@@ -11,7 +11,7 @@ A bash script will be written and will perform both topup and eddy on each
pair of scans.
%}
% make the given directories
% make the raw and FSL directories for the given subject. On
if ~exist(fullfile(subdir,subj,'raw','dir98'),'dir')
mkdir(fullfile(subdir,subj,'raw','dir98'))
end
......
#!/bin/bash
#SBATCH --partition=medium
#SBATCH --time=24:00:00
#SBATCH --ntasks=5
#SBATCH --mem-per-cpu=8G
#SBATCH --output=/data/user/mdefende/datasets/MDP-diff/jobs/sub-MDP001-dwi-FSL-preproc.txt
module load FSL/6.0.3
# Extract b0 images from AP and PA scans for both dir98 and dir99. Save in FSL directory
fslroi /data/user/mdefende/datasets/MDP-diff/subs/sub-MDP001/raw/dir98/sub-MDP001_acq-98_dir-AP_run-01_dwi.nii.gz /data/user/mdefende/datasets/MDP-diff/subs/sub-MDP001/FSL/dir98/AP_b0 0 1
fslroi /data/user/mdefende/datasets/MDP-diff/subs/sub-MDP001/raw/dir98/sub-MDP001_acq-98_dir-PA_run-01_dwi.nii.gz /data/user/mdefende/datasets/MDP-diff/subs/sub-MDP001/FSL/dir98/PA_b0 0 1
fslmerge -t /data/user/mdefende/datasets/MDP-diff/subs/sub-MDP001/FSL/dir98/both_b0 /data/user/mdefende/datasets/MDP-diff/subs/sub-MDP001/FSL/dir98/AP_b0 /data/user/mdefende/datasets/MDP-diff/subs/sub-MDP001/FSL/dir98/PA_b0
fslroi /data/user/mdefende/datasets/MDP-diff/subs/sub-MDP001/raw/dir99/sub-MDP001_acq-99_dir-AP_run-01_dwi.nii.gz /data/user/mdefende/datasets/MDP-diff/subs/sub-MDP001/FSL/dir99/AP_b0 0 1
fslroi /data/user/mdefende/datasets/MDP-diff/subs/sub-MDP001/raw/dir99/sub-MDP001_acq-99_dir-PA_run-01_dwi.nii.gz /data/user/mdefende/datasets/MDP-diff/subs/sub-MDP001/FSL/dir99/PA_b0 0 1
fslmerge -t /data/user/mdefende/datasets/MDP-diff/subs/sub-MDP001/FSL/dir99/both_b0 /data/user/mdefende/datasets/MDP-diff/subs/sub-MDP001/FSL/dir99/AP_b0 /data/user/mdefende/datasets/MDP-diff/subs/sub-MDP001/FSL/dir99/PA_b0
# Create the acqparams.txt files
printf "0 -1 0 0.112 \n0 1 0 0.112" > /data/user/mdefende/datasets/MDP-diff/subs/sub-MDP001/FSL/dir98/acqparams.txt
printf "0 -1 0 0.112 \n0 1 0 0.112" > /data/user/mdefende/datasets/MDP-diff/subs/sub-MDP001/FSL/dir99/acqparams.txt
# run topup for both dir98 and dir99
topup --imain=/data/user/mdefende/datasets/MDP-diff/subs/sub-MDP001/FSL/dir98/both_b0 --datain=/data/user/mdefende/datasets/MDP-diff/subs/sub-MDP001/FSL/dir98/acqparams.txt --config=b02b0.cnf --out=/data/user/mdefende/datasets/MDP-diff/subs/sub-MDP001/FSL/dir98/topup_AP_PA_b0 --iout=/data/user/mdefende/datasets/MDP-diff/subs/sub-MDP001/FSL/dir98/unwarp_b0 --fout=/data/user/mdefende/datasets/MDP-diff/subs/sub-MDP001/FSL/dir98/fout
topup --imain=/data/user/mdefende/datasets/MDP-diff/subs/sub-MDP001/FSL/dir99/both_b0 --datain=/data/user/mdefende/datasets/MDP-diff/subs/sub-MDP001/FSL/dir99/acqparams.txt --config=b02b0.cnf --out=/data/user/mdefende/datasets/MDP-diff/subs/sub-MDP001/FSL/dir99/topup_AP_PA_b0 --iout=/data/user/mdefende/datasets/MDP-diff/subs/sub-MDP001/FSL/dir99/unwarp_b0 --fout=/data/user/mdefende/datasets/MDP-diff/subs/sub-MDP001/FSL/dir99/fout
# Perform brain extraction for both dir98 and dir99
fslmaths /data/user/mdefende/datasets/MDP-diff/subs/sub-MDP001/FSL/dir98/unwarp_b0 -Tmean /data/user/mdefende/datasets/MDP-diff/subs/sub-MDP001/FSL/dir98/unwarp_b0
bet /data/user/mdefende/datasets/MDP-diff/subs/sub-MDP001/FSL/dir98/unwarp_b0 /data/user/mdefende/datasets/MDP-diff/subs/sub-MDP001/FSL/dir98/unwarp_b0_brain -m
fslmaths /data/user/mdefende/datasets/MDP-diff/subs/sub-MDP001/FSL/dir99/unwarp_b0 -Tmean /data/user/mdefende/datasets/MDP-diff/subs/sub-MDP001/FSL/dir99/unwarp_b0
bet /data/user/mdefende/datasets/MDP-diff/subs/sub-MDP001/FSL/dir99/unwarp_b0 /data/user/mdefende/datasets/MDP-diff/subs/sub-MDP001/FSL/dir99/unwarp_b0_brain -m
# Merge raw PA to raw AP
fslmerge -t /data/user/mdefende/datasets/MDP-diff/subs/sub-MDP001/FSL/dir98/sub-MDP001-AP_PA_dir98_raw /data/user/mdefende/datasets/MDP-diff/subs/sub-MDP001/raw/dir98/sub-MDP001_acq-98_dir-AP_run-01_dwi.nii.gz /data/user/mdefende/datasets/MDP-diff/subs/sub-MDP001/raw/dir98/sub-MDP001_acq-98_dir-PA_run-01_dwi.nii.gz
fslmerge -t /data/user/mdefende/datasets/MDP-diff/subs/sub-MDP001/FSL/dir99/sub-MDP001-AP_PA_dir99_raw /data/user/mdefende/datasets/MDP-diff/subs/sub-MDP001/raw/dir99/sub-MDP001_acq-99_dir-AP_run-01_dwi.nii.gz /data/user/mdefende/datasets/MDP-diff/subs/sub-MDP001/raw/dir99/sub-MDP001_acq-99_dir-PA_run-01_dwi.nii.gz
# Merge AP and PA bvals files
paste -d ' ' /data/user/mdefende/datasets/MDP-diff/subs/sub-MDP001/raw/dir98/sub-MDP001_acq-98_dir-AP_run-01_dwi.bval /data/user/mdefende/datasets/MDP-diff/subs/sub-MDP001/raw/dir98/sub-MDP001_acq-98_dir-PA_run-01_dwi.bval > /data/user/mdefende/datasets/MDP-diff/subs/sub-MDP001/FSL/dir98/AP_PA_dir98.bval
paste -d ' ' /data/user/mdefende/datasets/MDP-diff/subs/sub-MDP001/raw/dir99/sub-MDP001_acq-99_dir-AP_run-01_dwi.bval /data/user/mdefende/datasets/MDP-diff/subs/sub-MDP001/raw/dir99/sub-MDP001_acq-99_dir-PA_run-01_dwi.bval > /data/user/mdefende/datasets/MDP-diff/subs/sub-MDP001/FSL/dir99/AP_PA_dir99.bval
# Merge AP and PA bvecs files
paste -d ' ' /data/user/mdefende/datasets/MDP-diff/subs/sub-MDP001/raw/dir98/sub-MDP001_acq-98_dir-AP_run-01_dwi.bvec /data/user/mdefende/datasets/MDP-diff/subs/sub-MDP001/raw/dir98/sub-MDP001_acq-98_dir-PA_run-01_dwi.bvec > /data/user/mdefende/datasets/MDP-diff/subs/sub-MDP001/FSL/dir98/AP_PA_dir98.bvec
paste -d ' ' /data/user/mdefende/datasets/MDP-diff/subs/sub-MDP001/raw/dir99/sub-MDP001_acq-99_dir-AP_run-01_dwi.bvec /data/user/mdefende/datasets/MDP-diff/subs/sub-MDP001/raw/dir99/sub-MDP001_acq-99_dir-PA_run-01_dwi.bvec > /data/user/mdefende/datasets/MDP-diff/subs/sub-MDP001/FSL/dir99/AP_PA_dir99.bvec
# Run eddy on dir98 and dir99 scans
eddy_openmp --imain=/data/user/mdefende/datasets/MDP-diff/subs/sub-MDP001/FSL/dir98/sub-MDP001-AP_PA_dir98_raw --mask=/data/user/mdefende/datasets/MDP-diff/subs/sub-MDP001/FSL/dir98/unwarp_b0_brain_mask --acqp=/data/user/mdefende/datasets/MDP-diff/subs/sub-MDP001/FSL/dir98/acqparams.txt --index=/data/user/mdefende/datasets/MDP-diff/subs/sub-MDP001/FSL/dir98/index.txt --bvecs=/data/user/mdefende/datasets/MDP-diff/subs/sub-MDP001/FSL/dir98/AP_PA_dir98.bvec --bvals=/data/user/mdefende/datasets/MDP-diff/subs/sub-MDP001/FSL/dir98/AP_PA_dir98.bval --topup=/data/user/mdefende/datasets/MDP-diff/subs/sub-MDP001/FSL/dir98/topup_AP_PA_b0 --out=/data/user/mdefende/datasets/MDP-diff/subs/sub-MDP001/FSL/dir98/sub-MDP001-AP_PA_dir98_raw --flm=quadratic
eddy_openmp --imain=/data/user/mdefende/datasets/MDP-diff/subs/sub-MDP001/FSL/dir99/sub-MDP001-AP_PA_dir99_raw --mask=/data/user/mdefende/datasets/MDP-diff/subs/sub-MDP001/FSL/dir99/unwarp_b0_brain_mask --acqp=/data/user/mdefende/datasets/MDP-diff/subs/sub-MDP001/FSL/dir99/acqparams.txt --index=/data/user/mdefende/datasets/MDP-diff/subs/sub-MDP001/FSL/dir99/index.txt --bvecs=/data/user/mdefende/datasets/MDP-diff/subs/sub-MDP001/FSL/dir99/AP_PA_dir99.bvec --bvals=/data/user/mdefende/datasets/MDP-diff/subs/sub-MDP001/FSL/dir99/AP_PA_dir99.bval --topup=/data/user/mdefende/datasets/MDP-diff/subs/sub-MDP001/FSL/dir99/topup_AP_PA_b0 --out=/data/user/mdefende/datasets/MDP-diff/subs/sub-MDP001/FSL/dir99/sub-MDP001-AP_PA_dir99_raw --flm=quadratic
#!/bin/bash
#SBATCH --partition=express
#SBATCH --time=2:00:00
#SBATCH --ntasks=1
#SBATCH --mem-per-cpu=8G
#SBATCH --output=/data/user/mdefende/datasets/MDP-diff/jobs/register/sub-MDP001-reg.txt
module load FreeSurfer/6.0.0-centos6_x86_64
SUBJECTS_DIR=/data/user/mdefende/datasets/MDP/subs
bbregister --s sub-MDP001 --mov /data/user/mdefende/datasets/MDP-diff/subs/sub-MDP001/FSL/dir98/unwarp_b0.nii.gz --dti --reg /data/user/mdefende/datasets/MDP-diff/subs/sub-MDP001/register/dir98_reg.dat --init-fsl
bbregister --s sub-MDP001 --mov /data/user/mdefende/datasets/MDP-diff/subs/sub-MDP001/FSL/dir99/unwarp_b0.nii.gz --dti --reg /data/user/mdefende/datasets/MDP-diff/subs/sub-MDP001/register/dir99_reg.dat --init-fsl
mri_vol2surf --src /data/user/mdefende/datasets/MDP-diff/subs/sub-MDP001/NODDI/dir98/sub-MDP001_diff_1.1e-9_odi.nii --out /data/user/mdefende/datasets/MDP-diff/subs/sub-MDP001/lh.sub-MDP001_dir98_diff_1.1e-9_odi.mgz --srcreg /data/user/mdefende/datasets/MDP-diff/subs/sub-MDP001/register/dir98_reg.dat --hemi lh
mri_vol2surf --src /data/user/mdefende/datasets/MDP-diff/subs/sub-MDP001/NODDI/dir98/sub-MDP001_diff_1.1e-9_odi.nii --out /data/user/mdefende/datasets/MDP-diff/subs/sub-MDP001/rh.sub-MDP001_dir98_diff_1.1e-9_odi.mgz --srcreg /data/user/mdefende/datasets/MDP-diff/subs/sub-MDP001/register/dir98_reg.dat --hemi rh
mri_vol2surf --src /data/user/mdefende/datasets/MDP-diff/subs/sub-MDP001/NODDI/dir98/sub-MDP001_diff_1.6e-9_odi.nii --out /data/user/mdefende/datasets/MDP-diff/subs/sub-MDP001/lh.sub-MDP001_dir98_diff_1.6e-9_odi.mgz --srcreg /data/user/mdefende/datasets/MDP-diff/subs/sub-MDP001/register/dir98_reg.dat --hemi lh
mri_vol2surf --src /data/user/mdefende/datasets/MDP-diff/subs/sub-MDP001/NODDI/dir98/sub-MDP001_diff_1.6e-9_odi.nii --out /data/user/mdefende/datasets/MDP-diff/subs/sub-MDP001/rh.sub-MDP001_dir98_diff_1.6e-9_odi.mgz --srcreg /data/user/mdefende/datasets/MDP-diff/subs/sub-MDP001/register/dir98_reg.dat --hemi rh
mri_vol2surf --src /data/user/mdefende/datasets/MDP-diff/subs/sub-MDP001/NODDI/dir99/sub-MDP001_diff_1.1e-9_odi.nii --out /data/user/mdefende/datasets/MDP-diff/subs/sub-MDP001/lh.sub-MDP001_dir99_diff_1.1e-9_odi.mgz --srcreg /data/user/mdefende/datasets/MDP-diff/subs/sub-MDP001/register/dir99_reg.dat --hemi lh
mri_vol2surf --src /data/user/mdefende/datasets/MDP-diff/subs/sub-MDP001/NODDI/dir99/sub-MDP001_diff_1.1e-9_odi.nii --out /data/user/mdefende/datasets/MDP-diff/subs/sub-MDP001/rh.sub-MDP001_dir99_diff_1.1e-9_odi.mgz --srcreg /data/user/mdefende/datasets/MDP-diff/subs/sub-MDP001/register/dir99_reg.dat --hemi rh
mri_vol2surf --src /data/user/mdefende/datasets/MDP-diff/subs/sub-MDP001/NODDI/dir99/sub-MDP001_diff_1.6e-9_odi.nii --out /data/user/mdefende/datasets/MDP-diff/subs/sub-MDP001/lh.sub-MDP001_dir99_diff_1.6e-9_odi.mgz --srcreg /data/user/mdefende/datasets/MDP-diff/subs/sub-MDP001/register/dir99_reg.dat --hemi lh
mri_vol2surf --src /data/user/mdefende/datasets/MDP-diff/subs/sub-MDP001/NODDI/dir99/sub-MDP001_diff_1.6e-9_odi.nii --out /data/user/mdefende/datasets/MDP-diff/subs/sub-MDP001/rh.sub-MDP001_dir99_diff_1.6e-9_odi.mgz --srcreg /data/user/mdefende/datasets/MDP-diff/subs/sub-MDP001/register/dir99_reg.dat --hemi rh
mri_vol2surf --src /data/user/mdefende/datasets/MDP-diff/subs/sub-MDP001/NODDI/dir98/sub-MDP001_diff_1.1e-9_ficvf.nii --out /data/user/mdefende/datasets/MDP-diff/subs/sub-MDP001/lh.sub-MDP001_dir98_diff_1.1e-9_ficvf.mgz --srcreg /data/user/mdefende/datasets/MDP-diff/subs/sub-MDP001/register/dir98_reg.dat --hemi lh
mri_vol2surf --src /data/user/mdefende/datasets/MDP-diff/subs/sub-MDP001/NODDI/dir98/sub-MDP001_diff_1.1e-9_ficvf.nii --out /data/user/mdefende/datasets/MDP-diff/subs/sub-MDP001/rh.sub-MDP001_dir98_diff_1.1e-9_ficvf.mgz --srcreg /data/user/mdefende/datasets/MDP-diff/subs/sub-MDP001/register/dir98_reg.dat --hemi rh
mri_vol2surf --src /data/user/mdefende/datasets/MDP-diff/subs/sub-MDP001/NODDI/dir98/sub-MDP001_diff_1.6e-9_ficvf.nii --out /data/user/mdefende/datasets/MDP-diff/subs/sub-MDP001/lh.sub-MDP001_dir98_diff_1.6e-9_ficvf.mgz --srcreg /data/user/mdefende/datasets/MDP-diff/subs/sub-MDP001/register/dir98_reg.dat --hemi lh
mri_vol2surf --src /data/user/mdefende/datasets/MDP-diff/subs/sub-MDP001/NODDI/dir98/sub-MDP001_diff_1.6e-9_ficvf.nii --out /data/user/mdefende/datasets/MDP-diff/subs/sub-MDP001/rh.sub-MDP001_dir98_diff_1.6e-9_ficvf.mgz --srcreg /data/user/mdefende/datasets/MDP-diff/subs/sub-MDP001/register/dir98_reg.dat --hemi rh
mri_vol2surf --src /data/user/mdefende/datasets/MDP-diff/subs/sub-MDP001/NODDI/dir99/sub-MDP001_diff_1.1e-9_ficvf.nii --out /data/user/mdefende/datasets/MDP-diff/subs/sub-MDP001/lh.sub-MDP001_dir99_diff_1.1e-9_ficvf.mgz --srcreg /data/user/mdefende/datasets/MDP-diff/subs/sub-MDP001/register/dir99_reg.dat --hemi lh
mri_vol2surf --src /data/user/mdefende/datasets/MDP-diff/subs/sub-MDP001/NODDI/dir99/sub-MDP001_diff_1.1e-9_ficvf.nii --out /data/user/mdefende/datasets/MDP-diff/subs/sub-MDP001/rh.sub-MDP001_dir99_diff_1.1e-9_ficvf.mgz --srcreg /data/user/mdefende/datasets/MDP-diff/subs/sub-MDP001/register/dir99_reg.dat --hemi rh
mri_vol2surf --src /data/user/mdefende/datasets/MDP-diff/subs/sub-MDP001/NODDI/dir99/sub-MDP001_diff_1.6e-9_ficvf.nii --out /data/user/mdefende/datasets/MDP-diff/subs/sub-MDP001/lh.sub-MDP001_dir99_diff_1.6e-9_ficvf.mgz --srcreg /data/user/mdefende/datasets/MDP-diff/subs/sub-MDP001/register/dir99_reg.dat --hemi lh
mri_vol2surf --src /data/user/mdefende/datasets/MDP-diff/subs/sub-MDP001/NODDI/dir99/sub-MDP001_diff_1.6e-9_ficvf.nii --out /data/user/mdefende/datasets/MDP-diff/subs/sub-MDP001/rh.sub-MDP001_dir99_diff_1.6e-9_ficvf.mgz --srcreg /data/user/mdefende/datasets/MDP-diff/subs/sub-MDP001/register/dir99_reg.dat --hemi rh
#!/bin/bash
#SBATCH --partition=long
#SBATCH --time=72:00:00
#SBATCH --ntasks=1
#SBATCH --cpus-per-task=8
#SBATCH --mem-per-cpu=8G
#SBATCH --output=/data/user/mdefende/datasets/MDP-diff/jobs/noddi/sub-MDP001_dir98_1.1e-9.txt
module load rc/matlab/R2019a
module load FreeSurfer/6.0.0-centos6_x86_64
mri_convert /data/user/mdefende/datasets/MDP-diff/subs/sub-MDP001/FSL/dir98/sub-MDP001-AP_PA_dir98_eddy.nii.gz /data/user/mdefende/datasets/MDP-diff/subs/sub-MDP001/FSL/dir98/sub-MDP001-AP_PA_dir98_eddy -ot nifti1
mri_convert /data/user/mdefende/datasets/MDP-diff/subs/sub-MDP001/FSL/dir98/unwarp_b0_brain_mask.nii.gz /data/user/mdefende/datasets/MDP-diff/subs/sub-MDP001/FSL/dir98/unwarp_b0_brain_mask -ot nifti1
matlab -nodisplay -r "addpath(genpath('/data/user/mdefende/Projects/prl-noddi/code'));CreateROI('/data/user/mdefende/datasets/MDP-diff/subs/sub-MDP001/FSL/dir98/sub-MDP001-AP_PA_dir98_eddy.hdr','/data/user/mdefende/datasets/MDP-diff/subs/sub-MDP001/FSL/dir98/unwarp_b0_brain_mask.hdr','/data/user/mdefende/datasets/MDP-diff/subs/sub-MDP001/FSL/dir98/sub-MDP001-AP_PA_dir98_eddy_NODDI_roi.mat');protocol = FSL2Protocol('/data/user/mdefende/datasets/MDP-diff/subs/sub-MDP001/FSL/dir98/AP_PA_dir98.bval','/data/user/mdefende/datasets/MDP-diff/subs/sub-MDP001/FSL/dir98/sub-MDP001-AP_PA_dir98_eddy.eddy_rotated_bvecs',5);noddi = MakeModel('WatsonSHStickTortIsoV_B0',1.1e-9); batch_fitting('/data/user/mdefende/datasets/MDP-diff/subs/sub-MDP001/FSL/dir98/sub-MDP001-AP_PA_dir98_eddy_NODDI_roi.mat',protocol,noddi,'/data/user/mdefende/datasets/MDP-diff/subs/sub-MDP001/FSL/dir98/NODDI_fitted_params_diff_1.1e-9.mat',8);"
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment