-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c561889
commit 9b31e13
Showing
7 changed files
with
347 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
.idea/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
#!/bin/bash | ||
# | ||
# Pipeline for spinal cord tumor data. | ||
# | ||
# Generate sc segmentation, preprocess data before training. | ||
# | ||
# Note: All images have .nii extension. | ||
# | ||
# Usage: | ||
# sct_run_batch <FILEPARAM> process_data.sh | ||
# | ||
# Author: Andreanne Lemay | ||
|
||
# Uncomment for full verbose | ||
# set -v | ||
|
||
# Immediately exit if error | ||
set -e | ||
|
||
# Exit if user presses CTRL+C (Linux) or CMD+C (OSX) | ||
trap "echo Caught Keyboard Interrupt within script. Exiting now.; exit" INT | ||
|
||
# Retrieve input params | ||
SUBJECT=$1 | ||
FILEPARAM=$2 | ||
|
||
# SCRIPT STARTS HERE | ||
# ============================================================================== | ||
# shellcheck disable=SC1090 | ||
source $FILEPARAM | ||
# Go to results folder, where most of the outputs will be located | ||
cd $PATH_RESULTS | ||
# Copy source images and segmentations | ||
mkdir -p data/derivatives/labels | ||
cd data | ||
|
||
cp -r $PATH_DATA/$SUBJECT . | ||
cp -r $PATH_DATA/derivatives/labels/$SUBJECT $PATH_RESULTS/data/derivatives/labels | ||
|
||
# Go to data folder | ||
cd $PATH_RESULTS/data/$SUBJECT/anat/ | ||
## Setup file names | ||
file_t2w=${SUBJECT}_T2w | ||
file_t1w=${SUBJECT}_T1w | ||
|
||
path_t1w=`pwd`/${file_t1w}.nii.gz | ||
|
||
# Oversample to avoid losing slice info when cropping | ||
sct_resample -i ${file_t2w}.nii.gz -vox 512x512x100 -x spline -o ${file_t2w}.nii.gz; | ||
|
||
sct_get_centerline -i ${file_t2w}.nii.gz -c t2; | ||
sct_create_mask -i ${file_t2w}.nii.gz -p centerline,${file_t2w}_centerline.nii.gz; | ||
sct_crop_image -i ${file_t2w}.nii.gz -m mask_${file_t2w}.nii.gz -o ${file_t2w}.nii.gz; | ||
cropped_img=`pwd`/${file_t2w}.nii.gz; | ||
|
||
|
||
if [ -f ${path_t1w} ]; then | ||
sct_resample -i ${file_t1w}.nii.gz -vox 512x512x100 -x spline -o ${file_t1w}.nii.gz; | ||
sct_crop_image -i ${file_t1w}.nii.gz -ref ${cropped_img} -o ${file_t1w}.nii.gz; | ||
sct_resample -i ${file_t1w}.nii.gz -vox 96x512x16 -x spline -o ${file_t1w}.nii.gz; | ||
fi | ||
|
||
cd $PATH_RESULTS/data/derivatives/labels/$SUBJECT/anat/ | ||
|
||
file_t2w_seg=${SUBJECT}_T2w_seg-tumor | ||
file_t1w_seg=${SUBJECT}_T1w_seg-tumor | ||
|
||
if [ -f ${path_t1w} ]; then | ||
sct_resample -i ${file_t1w_seg}.nii.gz -vox 512x512x100 -x linear -o ${file_t1w_seg}.nii.gz; | ||
sct_crop_image -i ${file_t1w_seg}.nii.gz -ref ${cropped_img} -o ${file_t1w_seg}.nii.gz; | ||
sct_resample -i ${file_t1w_seg}.nii.gz -vox 96x512x16 -x linear -o ${file_t1w_seg}.nii.gz; | ||
sct_maths -i ${file_t1w_seg}.nii.gz -o ${file_t1w_seg}.nii.gz -bin 0.9 | ||
sct_image -i ${file_t1w_seg}.nii.gz -setorient AIL; | ||
fi | ||
|
||
sct_resample -i ${file_t2w_seg}.nii.gz -vox 512x512x100 -x linear -o ${file_t2w_seg}.nii.gz; | ||
sct_crop_image -i ${file_t2w_seg}.nii.gz -ref ${cropped_img} -o ${file_t2w_seg}.nii.gz; | ||
sct_resample -i ${file_t2w_seg}.nii.gz -vox 96x512x16 -x linear -o ${file_t2w_seg}.nii.gz; | ||
sct_maths -i ${file_t2w_seg}.nii.gz -o ${file_t2w_seg}.nii.gz -bin 0.9; | ||
sct_image -i ${file_t2w_seg}.nii.gz -setorient AIL; | ||
|
||
cd $PATH_RESULTS/data/$SUBJECT/anat/ | ||
sct_resample -i ${file_t2w}.nii.gz -vox 96x512x16 -x spline -o ${file_t2w}.nii.gz; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
#!/bin/bash | ||
# | ||
# Pipeline for spinal cord tumor data. | ||
# | ||
# Generate sc segmentation, preprocess data before training. | ||
# | ||
# Note: All images have .nii extension. | ||
# | ||
# Usage: | ||
# sct_run_batch <FILEPARAM> process_data.sh | ||
# | ||
# Author: Andreanne Lemay | ||
|
||
# Uncomment for full verbose | ||
# set -v | ||
|
||
# Immediately exit if error | ||
set -e | ||
|
||
# Exit if user presses CTRL+C (Linux) or CMD+C (OSX) | ||
trap "echo Caught Keyboard Interrupt within script. Exiting now.; exit" INT | ||
|
||
# Retrieve input params | ||
SUBJECT=$1 | ||
FILEPARAM=$2 | ||
|
||
# SCRIPT STARTS HERE | ||
# ============================================================================== | ||
# shellcheck disable=SC1090 | ||
source $FILEPARAM | ||
# Go to results folder, where most of the outputs will be located | ||
cd $PATH_RESULTS | ||
# Copy source images and segmentations | ||
mkdir -p data/derivatives/labels | ||
cd data | ||
|
||
cp -r $PATH_DATA/$SUBJECT . | ||
cp -r $PATH_DATA/derivatives/labels/$SUBJECT $PATH_RESULTS/data/derivatives/labels | ||
|
||
# Go to data labels folder | ||
cd $PATH_RESULTS/data/derivatives/labels/$SUBJECT/anat/ | ||
|
||
file_t2w_seg=${SUBJECT}_T2w_seg-tumor | ||
file_t1w_seg=${SUBJECT}_T1w_seg-tumor | ||
file_t1w_edema=${SUBJECT}_T1w_edema | ||
file_t1w_cavity=${SUBJECT}_T1w_cavity | ||
file_t2w_edema=${SUBJECT}_T2w_edema | ||
file_t2w_cavity=${SUBJECT}_T2w_cavity | ||
|
||
sct_maths -i ${file_t2w_seg}.nii.gz -o ${file_t2w_seg}.nii.gz -bin 0.9; | ||
sct_image -i ${file_t2w_seg}.nii.gz -setorient AIL; | ||
|
||
sct_maths -i ${file_t1w_seg}.nii.gz -o ${file_t1w_seg}.nii.gz -bin 0.9; | ||
sct_image -i ${file_t1w_seg}.nii.gz -setorient AIL; | ||
|
||
path_edema=`pwd`/${file_t1w_edema}.nii.gz | ||
if [ -f ${path_edema} ]; then | ||
sct_maths -i ${file_t2w_seg}.nii.gz -o ${file_t2w_seg}.nii.gz -bin 0.9; | ||
sct_image -i ${file_t2w_seg}.nii.gz -setorient AIL; | ||
|
||
sct_maths -i ${file_t1w_seg}.nii.gz -o ${file_t1w_seg}.nii.gz -bin 0.9; | ||
sct_image -i ${file_t1w_seg}.nii.gz -setorient AIL; | ||
|
||
sct_maths -i ${file_t2w_seg}.nii.gz -o ${file_t2w_seg}.nii.gz -add ${file_t2w_edema}.nii.gz; | ||
sct_maths -i ${file_t1w_edema}.nii.gz -o ${file_t1w_edema}.nii.gz -add ${file_t1w_edema}.nii.gz; | ||
fi | ||
|
||
path_cavity=`pwd`/${file_t1w_cavity}.nii.gz | ||
if [ -f ${path_cavity} ]; then | ||
sct_maths -i ${file_t2w_seg}.nii.gz -o ${file_t2w_seg}.nii.gz -bin 0.9; | ||
sct_image -i ${file_t2w_seg}.nii.gz -setorient AIL; | ||
|
||
sct_maths -i ${file_t1w_seg}.nii.gz -o ${file_t1w_seg}.nii.gz -bin 0.9; | ||
sct_image -i ${file_t1w_seg}.nii.gz -setorient AIL; | ||
|
||
sct_maths -i ${file_t2w_seg}.nii.gz -o ${file_t2w_seg}.nii.gz -add ${file_t2w_cavity}.nii.gz; | ||
sct_maths -i ${file_t1w_seg}.nii.gz -o ${file_t1w_seg}.nii.gz -add ${file_t1w_cavity}.nii.gz; | ||
fi | ||
|
||
sct_maths -i ${file_t2w_seg}.nii.gz -o ${file_t2w_seg}.nii.gz -bin 0.9; | ||
sct_maths -i ${file_t1w_seg}.nii.gz -o ${file_t1w_seg}.nii.gz -bin 0.9; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
#!/bin/bash | ||
# | ||
# Pipeline for spinal cord tumor data. | ||
# | ||
# Generate sc segmentation, preprocess data before training. | ||
# | ||
# Note: All images have .nii extension. | ||
# | ||
# Usage: | ||
# sct_run_batch <FILEPARAM> process_data.sh | ||
# | ||
# Author: Andreanne Lemay | ||
|
||
# Uncomment for full verbose | ||
# set -v | ||
|
||
# Immediately exit if error | ||
set -e | ||
|
||
# Exit if user presses CTRL+C (Linux) or CMD+C (OSX) | ||
trap "echo Caught Keyboard Interrupt within script. Exiting now.; exit" INT | ||
|
||
# Retrieve input params | ||
SUBJECT=$1 | ||
FILEPARAM=$2 | ||
|
||
# SCRIPT STARTS HERE | ||
# ============================================================================== | ||
# shellcheck disable=SC1090 | ||
source $FILEPARAM | ||
# Go to results folder, where most of the outputs will be located | ||
cd $PATH_RESULTS | ||
# Copy source images and segmentations | ||
mkdir -p data/derivatives/labels | ||
cd data | ||
|
||
cp -r $PATH_DATA/$SUBJECT . | ||
cp -r $PATH_DATA/derivatives/labels/$SUBJECT $PATH_RESULTS/data/derivatives/labels | ||
|
||
# Go to data folder | ||
cd $PATH_RESULTS/data/$SUBJECT/anat/ | ||
## Setup file names | ||
file_t2w=${SUBJECT}_T2w | ||
file_t1w=${SUBJECT}_T1w | ||
path_t1w=`pwd`/${file_t1w}.nii.gz | ||
|
||
if [ -f ${path_t1w} ]; then | ||
sct_register_multimodal -i ${file_t1w}.nii.gz -d ${file_t2w}.nii.gz -x spline | ||
mv ${file_t2w}_reg.nii.gz ${file_t2w}.nii.gz | ||
mv ${file_t1w}_reg.nii.gz ${file_t1w}.nii.gz | ||
warp_T2w2T1w=`pwd`/warp_${file_t2w}2${file_t1w}.nii.gz | ||
warp_T1w2T2w=`pwd`/warp_${file_t1w}2${file_t2w}.nii.gz | ||
fi | ||
|
||
cd $PATH_RESULTS/data/derivatives/labels/$SUBJECT/anat/ | ||
|
||
file_t2w_seg=${SUBJECT}_T2w_seg-tumor | ||
file_t1w_seg=${SUBJECT}_T1w_seg-tumor | ||
|
||
if [ -f ${path_t1w} ]; then | ||
sct_apply_transfo -i ${file_t1w_seg}.nii.gz -d ${file_t2w_seg}.nii.gz -w ${warp_T1w2T2w} -o ${file_t1w_seg}.nii.gz -x linear | ||
sct_apply_transfo -i ${file_t2w_seg}.nii.gz -d ${file_t1w_seg}.nii.gz -w ${warp_T2w2T1w} -o ${file_t2w_seg}.nii.gz -x linear | ||
fi |
Oops, something went wrong.