Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adding preprocessing script #2

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
**/.DS_Store
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ git clone https://github.com/ivadomed/model_seg_csf_epi.git

## Get the data

- [email protected]:datasets/data_gre-epi
- [email protected]:datasets/mni-bmpd

### Example calls to get the data

~~~
git clone [email protected]:datasets/data_gre-epi
cd data_gre-epi
git clone [email protected]:datasets/mni-bmpd
cd mni-bmpd
git annex get .
cd ..
~~~
Expand Down
79 changes: 79 additions & 0 deletions scripts/preprocess.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
#!/bin/bash
# Functionality: Resizes the images as per the dimensions of the segmentations
# Usage: preprocess_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
56 changes: 56 additions & 0 deletions scripts/qc_generation.sh
Original file line number Diff line number Diff line change
@@ -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}