Last updated: 2020-10-22

Checks: 7 0

Knit directory: Viso-NODDI-in-CUD/

This reproducible R Markdown analysis was created with workflowr (version 1.6.2). The Checks tab describes the reproducibility checks that were applied when the results were created. The Past versions tab lists the development history.


Great! Since the R Markdown file has been committed to the Git repository, you know the exact version of the code that produced these results.

Great job! The global environment was empty. Objects defined in the global environment can affect the analysis in your R Markdown file in unknown ways. For reproduciblity it’s best to always run the code in an empty environment.

The command set.seed(20201022) was run prior to running the code in the R Markdown file. Setting a seed ensures that any results that rely on randomness, e.g. subsampling or permutations, are reproducible.

Great job! Recording the operating system, R version, and package versions is critical for reproducibility.

Nice! There were no cached chunks for this analysis, so you can be confident that you successfully produced the results during this run.

Great job! Using relative paths to the files within your workflowr project makes it easier to run your code on other machines.

Great! You are using Git for version control. Tracking code development and connecting the code version to the results is critical for reproducibility.

The results in this page were generated with repository version 372d376. See the Past versions tab to see a history of the changes made to the R Markdown and HTML files.

Note that you need to be careful to ensure that all relevant files for the analysis have been committed to Git prior to generating the results (you can use wflow_publish or wflow_git_commit). workflowr only checks the R Markdown file, but you know if there are other scripts or data files that it depends on. Below is the status of the Git repository when the results were generated:


Ignored files:
    Ignored:    .Rhistory
    Ignored:    .Rproj.user/

Unstaged changes:
    Deleted:    analysis/DTI-FWE.Rmd
    Deleted:    analysis/DTI-preprocessing.Rmd
    Deleted:    analysis/T1w-preprocessing.Rmd
    Modified:   analysis/_site.yml

Note that any generated files, e.g. HTML, png, CSS, etc., are not included in this status report because it is ok for generated content to have uncommitted changes.


These are the previous versions of the repository in which changes were made to the R Markdown (analysis/Workflow.Rmd) and HTML (docs/Workflow.html) files. If you’ve configured a remote Git repository (see ?wflow_git_remote), click on the hyperlinks in the table below to view the files as they were in that past version.

File Version Author Date Message
Rmd 372d376 JalilRT 2020-10-22 Publish the initial files for Viso-NODDI-in-CUD

To reproduce the results, please follow the following flow and using codes we provided.

T1-weighted preprocessing

#! /bin/bash

DIR=$PWD    #Base directory path
List=${DIR}/Subjects.txt    #List of Subjects

for Sub in `cat ${List}`
do
echo ${Sub}

T1_Nifti=${DIR}/NIFTIs/${Sub}/sub-${Sub}_T1w.nii.gz #Raw T1 structural data

mkdir -p ${DIR}/Freesurfer/${Sub}       
export SUBJECTS_DIR=${DIR}/Freesurfer
mkdir -p ${SUBJECTS_DIR}/${Sub}/mri/orig

rm ${SUBJECTS_DIR}/${Sub}/scripts/IsRunning.lh+rh

mri_convert ${T1_Nifti} ${SUBJECTS_DIR}/${Sub}/mri/orig/001.mgz     #converting nifti to mgz

cd ${SUBJECTS_DIR}
recon-all -all -s ${Sub}        #perform T1 preprocessing and Compute Parcellation of whole brain

mri_convert ${SUBJECTS_DIR}/mri/brain.mgz ${SUBJECTS_DIR}/mri/nifti/brain.nii.gz
mri_convert ${SUBJECTS_DIR}/mri/aparc+aseg.mgz ${SUBJECTS_DIR}/freeLabels.nii.gz

done

Diffusion weighted preprocessing

#! /bin/bash

FSLOUTPUTTYPE=NIFTI_GZ
export FSLOUTPUTTYPE

DIR=$PWD   #Base directory path
DTI_dir=${DIR}/NIFTIs       #Raw data Directory
index=${DIR}/Index.txt      #acqp indexor each DWI volume
acqp=${DIR}/aqcp_Param.txt  #DWI aqcusition parametes

List=${DIR}/Subjects.txt

for Sub in `cat ${List}`
do
echo ${Sub}

mkdir -p ${DIR}/BedpostX/${Sub}
Sub_dir=${DIR}/BedpostX/${Sub}

cp -rf ${DTI_dir}/${Sub}/sub-${Sub}_dwi.nii.gz ${Sub_dir}/${Sub}_DWI.nii.gz
DWI=${Sub_dir}/${Sub}_DWI.nii.gz
bvc=${DTI_dir}/${Sub}/sub-${Sub}_dwi.bvec
bvl=${DTI_dir}/${Sub}/sub-${Sub}_dwi.bval

echo "Distortion Correction......"

mkdir -p ${Sub_dir}/${Sub}/dwi_volumes
mkdir -p ${Sub_dir}/${Sub}/epi-1_volumes

fslsplit ${Sub_dir}/${Sub}/sub-${Sub}_dwi.nii.gz ${Sub_dir}/${Sub}/dwi_volumes/sub-${Sub}_dwi_x -t 
fslsplit ${Sub_dir}/${Sub}/sub-${Sub}_run-01_epi.nii.gz ${Sub_dir}/${Sub}/epi-1_volumes/sub-${Sub}_run-01_epi_x -t 

cp -rf ${Sub_dir}/${Sub}/dwi_volumes/sub-${Sub}_dwi_x0000.nii.gz ${Sub_dir}/${Sub}/dwi_volumes/sub-${Sub}_no_diff_PA.nii.gz
cp -rf ${Sub_dir}/${Sub}/epi-1_volumes/sub-${Sub}_run-01_epi_x0000.nii.gz ${Sub_dir}/${Sub}/epi-1_volumes/sub-${Sub}_no_diff_AP.nii.gz

fslmerge -t ${Sub_dir}/${Sub}/${Sub}_PA-AP_no_diff.nii.gz ${Sub_dir}/${Sub}/dwi_volumes/sub-${Sub}_no_diff_PA.nii.gz ${Sub_dir}/${Sub}/epi-1_volumes/sub-${Sub}_no_diff_AP.nii.gz

topup --imain=${Sub_dir}/${Sub}/${Sub}_PA-AP_no_diff.nii.gz --datain=${Sub_dir}/${Sub}/aqcp_PAAP.txt --out=${Sub_dir}/${Sub}/${Sub}_PA-AP_no_diff_corrected_1 --iout=${Sub_dir}/${Sub}/${Sub}_PA-AP_no_diff_corrected
fslmaths ${Sub_dir}/${Sub}/${Sub}_PA-AP_no_diff_corrected -Tmean ${Sub_dir}/${Sub}/${Sub}_PA-AP_no_diff_corrected
bet ${Sub_dir}/${Sub}/${Sub}_PA-AP_no_diff_corrected ${Sub_dir}/${Sub}/${Sub}_PA-AP_no_diff_corrected_brain -f 0.45 -m -R

echo "Eddy-corraction and bvec rotation..."
eddy_openmp --imain=${Sub_dir}/${Sub}_SS --mask=${Sub_dir}/${Sub}/${Sub}_PA-AP_no_diff_corrected_brain_mask --acqp=${acqp} --index=${index} --topup=${Sub_dir}/${Sub}/${Sub}_PA-AP_no_diff_corrected_1 --bvecs=${bvc} --bvals=${bvl} --out=${Sub_dir}/${Sub}_eddy

echo "Brain Mask Creation..."
bet ${Sub_dir}/${Sub}_eddy ${Sub_dir}/brain_output -f 0.15 -m -F -R
fslmaths ${Sub_dir}/${Sub}_eddy -mul ${Sub_dir}/brain_output_mask ${Sub_dir}/${Sub}_eddy_SS

echo "Tensor Modeling..."
dtifit -k ${Sub_dir}/${Sub}_eddy_ss.nii.gz -o ${Sub_dir}/${Sub}_DWI -m ${Sub_dir}/brain_output_mask -r ${Sub_dir}/${Sub}_eddy.eddy_rotated_bvecs -b ${bvl}

cp -rf ${bvl} ${Sub_dir}/${Sub}/sub-${Sub}_dwi_eddy_SS.bval 
cp -rf ${Sub_dir}/${Sub}_eddy.eddy_rotated_bvecs ${Sub_dir}/${Sub}/sub-${Sub}_dwi_eddy_SS.bvec 

Diffusion FWE analysis

#! /bin/bash


DIR=$PWD

mkdir ${DIR}/freeROI_FW_1
mkdir ${DIR}/jhuTract_FW_1
mkdir ${DIR}/jhuWM_FW_1
mkdir ${DIR}/JHUroi_FW_1

List=${DIR}/Subjects.txt    #List of Subjects

for Sub in `cat ${List}`
do
echo ${i}

fslstats -t ${DIR}/${i}/${i}_DWI_NoddiFit_fiso -M >> ${DIR}/OpenNeuro_FW_mean.txt       #Compute mean FW for Wholebrain
fslstats -t ${DIR}/${i}/${i}_DWI_NoddiFit_ficvf -M >> ${DIR}/OpenNeuro_ficv_mean.txt    #Compute mean icvf for Wholebrain
fslstats -t ${DIR}/${i}/${i}_DWI_NoddiFit_odi -M >> ${DIR}/OpenNeuro_odi_mean.txt       #Compute mean odi for Wholebrain


echo "extract FW for Structural Rois" 

antsRegistrationSyN.sh -f ${DIR}/${i}/FWE_DTI/${i}_DWI_FA.nii.gz -m ${DIR}/Freesurfer/${Sub}/mri/nifti/brain.nii.gz -t s -o ${DIR}/${i}/FWE_DTI/${i}_DWI2T1 -n 8    #Compute Registration between DWI and Structural bain
antsApplyTransforms -i ${DIR}/Freesurfer/${Sub}/freeLabels.nii.gz -r ${DIR}/${i}/FWE_DTI/${i}_DWI_FA.nii.gz -o ${DIR}/${i}/FWE_DTI/${i}_T12DWI.nii.gz -t [${DIR}/${i}/FWE_DTI/${i}_DWI2T10GenericAffine.mat, 0] -t  ${DIR}/${i}/FWE_DTI/${i}_DWI2T11Warp.nii.gz -n NearestNeighbor  


list=/home/scmia/Documents/OpenNeuro/86_labels.txt  # list of Desikan Structural brain rois (68 cortical + 18 sub cortical)
mkdir ${DIR}/${i}/labelMASKS_DWI
for j in `cat ${list}`;do
echo $j
fslmaths ${DIR}/${i}/FWE_DTI/${i}_T12DWI.nii.gz -uthr ${j} -thr ${j} ${DIR}/${i}/labelMASKS_DWI/${j}_mask_dwi.nii.gz
fslstats -t ${DIR}/${i}/${i}_DWI_NoddiFit_fiso -k ${DIR}/${i}/labelMASKS_DWI/${j}_mask_dwi.nii.gz -M >> ${DIR}/freeROI_FW_1/${j}_FW.txt     #Compute mean FW for structure rois
done
fslstats -t ${DIR}/${i}/${i}_DWI_NoddiFit_fiso -k ${DIR}/${i}/labelMASKS_DWI/CC_mask_dwi.nii.gz -M >> ${DIR}/freeROI_FW_1/CC_FW.txt

echo "extract FW for JHU Rois" 

antsRegistrationSyN.sh -f ${DIR}/${i}/FWE_DTI/${i}_DWI_FA.nii.gz -m ${FSLDIR}/data/atlases/JHU/JHU-ICBM-FA-1mm.nii.gz -t s -o ${DIR}/${i}/FWE_DTI/${i}_DWI2JHU -n 8     # comupute registration between 

antsApplyTransforms -i ${FSLDIR}/data/atlases/JHU/JHU-ICBM-tracts-maxprob-thr25-1mm.nii.gz -r ${DIR}/${i}/FWE_DTI/${i}_DWI_FA.nii.gz -o ${DIR}/${i}/FWE_DTI/${i}_JHU2DWI.nii.gz -t [${DIR}/${i}/FWE_DTI/${i}_DWI2JHU0GenericAffine.mat, 0] -t  ${DIR}/${i}/FWE_DTI/${i}_DWI2JHU1Warp.nii.gz -n NearestNeighbor      #apply registration to JHU tract atlas

antsApplyTransforms -i ${FSLDIR}/data/atlases/JHU/JHU-ICBM-labels-1mm.nii.gz -r ${DIR}/${i}/FWE_DTI/${i}_DWI_FA.nii.gz -o ${DIR}/${i}/FWE_DTI/${i}_JHUlabels2DWI.nii.gz -t [${DIR}/${i}/FWE_DTI/${i}_DWI2JHU0GenericAffine.mat, 0] -t  ${DIR}/${i}/FWE_DTI/${i}_DWI2JHU1Warp.nii.gz -n NearestNeighbor      #apply registration to JHU wm atlas

mkdir ${DIR}/${i}/FWE_DTI/JHU_dwi
for k in {1..20} ; do
echo ${k}
fslmaths ${DIR}/${i}/FWE_DTI/${i}_JHU2DWI.nii.gz -uthr ${k} -thr ${k} ${DIR}/${i}/FWE_DTI/JHU_dwi/${k}_jhu2dwi_tract.nii.gz     #Extract JHU tract rois individual 
fslstats -t ${DIR}/${i}/${i}_DWI_NoddiFit_fiso -k ${DIR}/${i}/FWE_DTI/JHU_dwi/${k}_jhu2dwi_tract.nii.gz -M >> ${DIR}/jhuTract_FW_1/${k}_tract_FW.txt    #Compute mean FW for JHU tract rois
done

mkdir ${DIR}/${i}/FWE_DTI/JHU_WM_dwi
for k in {1..48} ; do
echo ${k}
fslmaths ${DIR}/${i}/FWE_DTI/${i}_JHUlabels2DWI.nii.gz -uthr ${k} -thr ${k} ${DIR}/${i}/FWE_DTI/JHU_WM_dwi/${k}_jhuWM2dwi_tract.nii.gz  #Extract JHU wm rois individual 
fslstats -t ${DIR}/${i}/${i}_DWI_NoddiFit_fiso -k ${DIR}/${i}/FWE_DTI/JHU_WM_dwi/${k}_jhuWM2dwi_tract.nii.gz -M >> ${DIR}/jhuWM_FW_1/${k}_WMroi_FW.txt      #Compute mean FW for JHU wm rois
done

done

sessionInfo()
R version 3.6.3 (2020-02-29)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 20.04.1 LTS

Matrix products: default
BLAS:   /usr/lib/x86_64-linux-gnu/blas/libblas.so.3.9.0
LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.9.0

locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C              
 [3] LC_TIME=es_MX.UTF-8        LC_COLLATE=en_US.UTF-8    
 [5] LC_MONETARY=es_MX.UTF-8    LC_MESSAGES=en_US.UTF-8   
 [7] LC_PAPER=es_MX.UTF-8       LC_NAME=C                 
 [9] LC_ADDRESS=C               LC_TELEPHONE=C            
[11] LC_MEASUREMENT=es_MX.UTF-8 LC_IDENTIFICATION=C       

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] workflowr_1.6.2

loaded via a namespace (and not attached):
 [1] Rcpp_1.0.5       rstudioapi_0.11  whisker_0.4      knitr_1.30      
 [5] magrittr_1.5     R6_2.4.1         rlang_0.4.8      stringr_1.4.0   
 [9] tools_3.6.3      xfun_0.18        git2r_0.27.1     htmltools_0.5.0 
[13] ellipsis_0.3.1   rprojroot_1.3-2  yaml_2.2.1       digest_0.6.26   
[17] tibble_3.0.4     lifecycle_0.2.0  crayon_1.3.4     later_1.1.0.1   
[21] vctrs_0.3.4      promises_1.1.1   fs_1.5.0         glue_1.4.2      
[25] evaluate_0.14    rmarkdown_2.5    stringi_1.5.3    compiler_3.6.3  
[29] pillar_1.4.6     backports_1.1.10 httpuv_1.5.4     pkgconfig_2.0.3