Skip to content

Commit

Permalink
Merge pull request #85 from sct-pipeline/t2w_resample
Browse files Browse the repository at this point in the history
Resample images to desired resolution
  • Loading branch information
PaulBautin authored Nov 15, 2020
2 parents c7e6cee + bb4e11f commit 1eb258e
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 9 deletions.
4 changes: 4 additions & 0 deletions config_script_t2.yml → config_script.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,12 @@ rescaling:
- 0.95
- 0.94
- 0.93

# Contrasts on which to perform the analysis. Available values are: 't1', 't2'
contrast: "t2"
# Resampling resolution in mm. Native resolutions for the spine-generic project are 1mm isotropic for T1w images and 0.8mm isotropic for T2w images.
interp_t1: "1x1x1"
interp_t2: "0.8x0.8x0.8"

# csa_atrophy_stat.py
# -------------------
Expand Down
4 changes: 2 additions & 2 deletions config_sct_run_batch.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# config file for sct_run_batch
path_data: /scratch/pabaua/data-multi-subject-p
path_output: /scratch/pabaua/results_csa_t2_2
path_output: /scratch/pabaua/results_csa_t2
script: /home/pabaua/csa-atrophy/process_data.sh
script_args: /home/pabaua/csa-atrophy/config_script_t2.yml
script_args: /home/pabaua/csa-atrophy/config_script.yml
jobs: -1
batch_log: sct_run_batch_log.txt
continue_on_error: 1
Expand Down
17 changes: 10 additions & 7 deletions process_data.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ n_transfo=$(yaml_parser -o n_transfo -i $config_script)
rescaling=$(yaml_parser -o rescaling -i $config_script)
R_COEFS=$(echo $rescaling | tr '[]' ' ' | tr ',' ' ' | tr "'" ' ')
contrast=$(yaml_parser -o contrast -i $config_script)
interp_t1=$(yaml_parser -o interp_t1 -i $config_script)
interp_t2=$(yaml_parser -o interp_t2 -i $config_script)

# FUNCTIONS
# ==============================================================================
Expand Down Expand Up @@ -78,10 +80,11 @@ segment_if_does_not_exist(){
local qc=$3
# Update global variable with segmentation file name
FILESEG="${file}_seg"
FILESEGMANUAL="${path_derivatives}/${FILESEG}-manual.nii.gz"
FILESEGMANUAL="${path_derivatives}/${FILESEG}-manual"
if [ -e $FILESEGMANUAL ]; then
echo "Found! Using manual segmentation."
rsync -avzh $FILESEGMANUAL ${FILESEG}.nii.gz
sct_resample -i ${FILESEGMANUAL}.nii.gz -mm $interp -x nn -o ${FILESEGMANUAL}_r.nii.gz
rsync -avzh ${FILESEGMANUAL}_r.nii.gz ${FILESEG}.nii.gz
sct_qc -i ${file}.nii.gz -s ${FILESEG}.nii.gz -p sct_deepseg_sc $qc
else
# Segment spinal cord
Expand Down Expand Up @@ -111,12 +114,12 @@ rm -r dwi
#=======================================================================
cd anat
# Reorient to RPI and resample file
if [ $contrast == "t2" ]; then
contrast_str="T2w"
interp="0.8x0.8x0.8"
elif [ $contrast == "t1" ]; then
if [ $contrast == "t1" ]; then
contrast_str="T1w"
interp="1x1x1"
interp=$interp_t1
elif [ $contrast == "t2" ]; then
contrast_str="T2w"
interp=$interp_t2
fi
file=${SUBJECT}_${contrast_str}
# Reorient image to RPI
Expand Down

0 comments on commit 1eb258e

Please sign in to comment.