From 7a19fed150d9c188670a345d65aae34580cb6ec2 Mon Sep 17 00:00:00 2001 From: Rohan Banerjee Date: Mon, 28 Nov 2022 01:49:11 -0500 Subject: [PATCH 1/6] adding preprocessing script --- preprocessing/preprocess.sh | 85 +++++++++++++++++++++++++++++++++++++ 1 file changed, 85 insertions(+) create mode 100644 preprocessing/preprocess.sh diff --git a/preprocessing/preprocess.sh b/preprocessing/preprocess.sh new file mode 100644 index 0000000..439113c --- /dev/null +++ b/preprocessing/preprocess.sh @@ -0,0 +1,85 @@ +#!/bin/bash +# +# Process data. +# For T1 : From raw images, proceeds to resampling and reorientation to RPI. +# +# Crop all images. +# Generates soft segmentations. +# Usage: +# ./process_data.sh +# +# +# Authors: Rohan Banerjee + +# The following global variables are retrieved from the caller sct_run_batch +# but could be overwritten by uncommenting the lines below: +# PATH_DATA_PROCESSED="~/data_processed" +# PATH_RESULTS="~/results" +# PATH_LOG="~/log" +# PATH_QC="~/qc" + +# Uncomment for full verbose +set -x + +# Exit if user presses CTRL+C (Linux) or CMD+C (OSX) +trap "echo Caught Keyboard Interrupt within script. Exiting now.; exit" INT + +# Print retrieved variables from sct_run_batch to the log (to allow easier debug) +echo “Retrieved variables from from the caller sct_run_batch:” +echo “PATH_DATA: ${PATH_DATA}” +echo “PATH_DATA_PROCESSED: ${PATH_DATA_PROCESSED}” +echo “PATH_RESULTS: ${PATH_RESULTS}” +echo “PATH_LOG: ${PATH_LOG}” +echo “PATH_QC: ${PATH_QC}” + +# Retrieve input params +SUBJECT=$1 + +# echo SUBJECT + +# Save script path +PATH_SCRIPT=$PWD + +get starting time: +start=`date +%s` + +# SCRIPT STARTS HERE +# ============================================================================== +# Display useful info for the log, such as SCT version, RAM and CPU cores available +sct_check_dependencies -short + +# Go to folder where data will be copied and processed +cd $PATH_DATA_PROCESSED + + +Copy list of participants in processed data folder +if [[ ! -f "participants.tsv" ]]; then + rsync -avzh $PATH_DATA/participants.tsv . +fi + +if [[ ! -f "participants.json" ]]; then + rsync -avzh $PATH_DATA/participants.json . +fi + +if [[ ! -f "README.md" ]]; then + rsync -avzh $PATH_DATA/README.md . +fi + +if [[ ! -f "dataset_description.tsv" ]]; then + rsync -avzh $PATH_DATA/dataset_description . +fi + +# Copy source images +rsync -avzh $PATH_DATA/$SUBJECT . + +#copy derivatives +rsync -avzh $PATH_DATA/derivatives . + +# Script starts here +cd ${SUBJECT}/func +file_bold=${SUBJECT}_task-rest_bold +file_bold_seg=${PATH_DATA}/derivatives/labels/${SUBJECT}/func/${SUBJECT}_task-rest_bold_seg-manual + +sct_register_multimodal -i ${file_bold}.nii.gz -d ${file_bold_seg}.nii.gz -o ${file_bold}_to_${file_bold}_reg.nii.gz -identity 0 +rm warp_${SUBJECT}_task-rest_bold_seg-manual2${SUBJECT}_task-rest_bold.nii.gz warp_${SUBJECT}_task-rest_bold2${SUBJECT}_task-rest_bold_seg-manual.nii.gz ${SUBJECT}_task-rest_bold.nii.gz +mv ${file_bold}_to_${file_bold}_reg.nii.gz ${file_bold}.nii.gz From 5a41bf56fb0c94b622b1a5f3fc1765fcd55a70ed Mon Sep 17 00:00:00 2001 From: Rohan Banerjee Date: Fri, 6 Jan 2023 13:07:44 -0500 Subject: [PATCH 2/6] Update preprocess.sh --- preprocessing/preprocess.sh | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/preprocessing/preprocess.sh b/preprocessing/preprocess.sh index 439113c..90089a9 100644 --- a/preprocessing/preprocess.sh +++ b/preprocessing/preprocess.sh @@ -1,12 +1,13 @@ #!/bin/bash # +#!/bin/bash +# # Process data. # For T1 : From raw images, proceeds to resampling and reorientation to RPI. # -# Crop all images. -# Generates soft segmentations. +# Resizes the images as per the corresponding ground truth dimensions # Usage: -# ./process_data.sh +# preprocess_data.sh # # # Authors: Rohan Banerjee From 0f9e0af4757e737d7787f2ccb1f12e4b6f356e20 Mon Sep 17 00:00:00 2001 From: Rohan Banerjee Date: Fri, 6 Jan 2023 13:08:03 -0500 Subject: [PATCH 3/6] Update preprocess.sh --- preprocessing/preprocess.sh | 3 --- 1 file changed, 3 deletions(-) diff --git a/preprocessing/preprocess.sh b/preprocessing/preprocess.sh index 90089a9..6ecba52 100644 --- a/preprocessing/preprocess.sh +++ b/preprocessing/preprocess.sh @@ -1,9 +1,6 @@ #!/bin/bash # #!/bin/bash -# -# Process data. -# For T1 : From raw images, proceeds to resampling and reorientation to RPI. # # Resizes the images as per the corresponding ground truth dimensions # Usage: From ab343fac765c8735b6117ec2ab0638be90d2140d Mon Sep 17 00:00:00 2001 From: Rohan Banerjee Date: Fri, 6 Jan 2023 16:28:04 -0500 Subject: [PATCH 4/6] added qc_generation script --- .gitignore | 1 + {preprocessing => scripts}/preprocess.sh | 8 ++-- scripts/qc_generation.sh | 56 ++++++++++++++++++++++++ 3 files changed, 62 insertions(+), 3 deletions(-) create mode 100644 .gitignore rename {preprocessing => scripts}/preprocess.sh (92%) create mode 100644 scripts/qc_generation.sh diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..79b5594 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +**/.DS_Store diff --git a/preprocessing/preprocess.sh b/scripts/preprocess.sh similarity index 92% rename from preprocessing/preprocess.sh rename to scripts/preprocess.sh index 6ecba52..439113c 100644 --- a/preprocessing/preprocess.sh +++ b/scripts/preprocess.sh @@ -1,10 +1,12 @@ #!/bin/bash # -#!/bin/bash +# Process data. +# For T1 : From raw images, proceeds to resampling and reorientation to RPI. # -# Resizes the images as per the corresponding ground truth dimensions +# Crop all images. +# Generates soft segmentations. # Usage: -# preprocess_data.sh +# ./process_data.sh # # # Authors: Rohan Banerjee diff --git a/scripts/qc_generation.sh b/scripts/qc_generation.sh new file mode 100644 index 0000000..c1fa652 --- /dev/null +++ b/scripts/qc_generation.sh @@ -0,0 +1,56 @@ +#!/bin/bash +# +# +# Functionality: Generates qc reports for already existing images and their corresponding segmentations/labels +# Usage: +# sct_run_batch -script qc_generation.sh +# Output: The index.html in the qc folder will have the qc reports for all the subjects in the data. +# +# Authors: Rohan Banerjee + +# The following global variables are retrieved from the caller sct_run_batch +# but could be overwritten by uncommenting the lines below: +# PATH_DATA_PROCESSED="~/data_processed" +# PATH_RESULTS="~/results" +# PATH_LOG="~/log" +# PATH_QC="~/qc" + +# Uncomment for full verbose +set -x + +# Exit if user presses CTRL+C (Linux) or CMD+C (OSX) +trap "echo Caught Keyboard Interrupt within script. Exiting now.; exit" INT + +# Print retrieved variables from sct_run_batch to the log (to allow easier debug) +echo “Retrieved variables from from the caller sct_run_batch:” +echo “PATH_DATA: ${PATH_DATA}” +echo “PATH_DATA_PROCESSED: ${PATH_DATA_PROCESSED}” +echo “PATH_RESULTS: ${PATH_RESULTS}” +echo “PATH_LOG: ${PATH_LOG}” +echo “PATH_QC: ${PATH_QC}” + +# Retrieve input params +SUBJECT=$1 + +# echo SUBJECT + +# Save script path +PATH_SCRIPT=$PWD + +get starting time: +start=`date +%s` + +# SCRIPT STARTS HERE +# ============================================================================== +# Display useful info for the log, such as SCT version, RAM and CPU cores available +sct_check_dependencies -short + +cd ${SUBJECT}/func +file_bold=${PATH_DATA}/${SUBJECT}/func/${SUBJECT}_task-rest_bold.nii.gz +file_bold_seg=${PATH_DATA}/derivatives/labels/${SUBJECT}/func/${SUBJECT}_task-rest_bold_seg-manual.nii.gz + +echo "file_bold: ${file_bold}" + +sct_qc -i ${file_bold} -s ${file_bold_seg} -p sct_propseg -qc qc -qc-subject ${SUBJECT} + + From 08fe1729497806e01f46bce0fa19dad3a62fe98c Mon Sep 17 00:00:00 2001 From: Rohan Banerjee Date: Fri, 6 Jan 2023 16:31:08 -0500 Subject: [PATCH 5/6] updated preprocess.sh --- scripts/preprocess.sh | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/scripts/preprocess.sh b/scripts/preprocess.sh index 439113c..abe5d6c 100644 --- a/scripts/preprocess.sh +++ b/scripts/preprocess.sh @@ -1,12 +1,6 @@ #!/bin/bash -# -# Process data. -# For T1 : From raw images, proceeds to resampling and reorientation to RPI. -# -# Crop all images. -# Generates soft segmentations. -# Usage: -# ./process_data.sh +# Functionality: Resizes the images as per the dimensions of the segmentations +# Usage: preprocess_data.sh # # # Authors: Rohan Banerjee From 992587da7401e440aed78aeed578b76a509b041e Mon Sep 17 00:00:00 2001 From: Rohan Banerjee Date: Fri, 6 Jan 2023 18:55:02 -0500 Subject: [PATCH 6/6] Update README.md --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 5ecf0ad..c115dd2 100644 --- a/README.md +++ b/README.md @@ -14,13 +14,13 @@ git clone https://github.com/ivadomed/model_seg_csf_epi.git ## Get the data -- git@data.neuro.polymtl.ca:datasets/data_gre-epi +- git@data.neuro.polymtl.ca:datasets/mni-bmpd ### Example calls to get the data ~~~ -git clone git@data.neuro.polymtl.ca:datasets/data_gre-epi -cd data_gre-epi +git clone git@data.neuro.polymtl.ca:datasets/mni-bmpd +cd mni-bmpd git annex get . cd .. ~~~