-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Files/Structure for the new testing dataset
- Loading branch information
1 parent
cb4b4b3
commit 26eeacc
Showing
39 changed files
with
419 additions
and
0 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 @@ | ||
sub-01 0.75 0.01 run-01_scans |
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,3 @@ | ||
sub-01_run-01_T2w axial | ||
sub-01_run-02_T2w coronal | ||
sub-01_run-03_T2w sagittal |
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,72 @@ | ||
#!/bin/sh | ||
# usage: | ||
# sh generic_script_to_run_superresolution.sh /path/to/batch_list.txt | ||
|
||
# Get the directory where the script is stored, | ||
# which is supposed to be in the code folder of the dataset root directory) | ||
SCRIPT_DIR="$(dirname "$0")" | ||
|
||
#Get absolute path | ||
SCRIPT_DIR="$(readlink -f $SCRIPT_DIR)" | ||
|
||
DATASET_DIR="$(dirname "${SCRIPT_DIR}")" | ||
|
||
echo "Dataset directory : $DATASET_DIR" | ||
|
||
#from each line of the subject_parameters.txt given as input | ||
while read -r line | ||
do | ||
#Extract PATIENT, LAMBDA_TV and DELTA_T and the scan list sub-01_run-01_scans.txt | ||
set -- $line | ||
PATIENT=$1 | ||
LAMBDA_TV=$2 | ||
DELTA_T=$3 | ||
SCANS_LIST="${PATIENT}_${4}.txt" | ||
|
||
echo "> Process subject ${PATIENT} with lambda_tv = ${LAMBDA_TV} and delta_t = ${DELTA_T}" | ||
|
||
PATIENT_DIR="$DATASET_DIR/${PATIENT}" | ||
echo " ... Subject directory : ${PATIENT_DIR}" | ||
|
||
# Create the output directory for results (if not existing). | ||
# run-XX is used to identify different list of scans: | ||
# sub-01_run-01_scans.txt, sub-01_run-02_scans.txt, ..., sub-01_run-XX_scans.txt | ||
# here I am just using sub-01_run-01_scans.txt but you can think as I am looping over | ||
# the different calls while reading the batch_list.txt file, | ||
# you could similarly loop over different list of scans. | ||
# The final superesolution is saved in derivatives/mialsrtk_tv-${LAMBDA_TV}_dt-${DELTA_T}_run-01/$PATIENT/anat folder | ||
# All intermediate outputs are saved in a tmp folder (see below). | ||
|
||
RESULTS="derivatives/mialsrtk_tv-${LAMBDA_TV}_dt-${DELTA_T}_run-01/$PATIENT" | ||
echo " ... Reconstruction tmp directory: ${DATASET_DIR}/${RESULTS}" | ||
if [ ! -d "${DATASET_DIR}/${RESULTS}" ]; then | ||
mkdir -p "${DATASET_DIR}/${RESULTS}"; | ||
echo " * Folder ${DATASET_DIR}/${RESULTS} created" | ||
fi | ||
if [ ! -d "${DATASET_DIR}/${RESULTS}/tmp" ]; then | ||
mkdir -p "${DATASET_DIR}/${RESULTS}/tmp"; | ||
echo " * Folder ${DATASET_DIR}/${RESULTS}/tmp created" | ||
fi | ||
if [ ! -d "${DATASET_DIR}/${RESULTS}/anat" ]; then | ||
mkdir -p "${DATASET_DIR}/${RESULTS}/anat"; | ||
echo " * Folder ${DATASET_DIR}/${RESULTS}/anat created" | ||
fi | ||
|
||
PATIENT_MASK_DIR="derivatives/manual_masks/$PATIENT" | ||
|
||
|
||
# Run the super-resolution pipeline | ||
|
||
docker run --rm -u $(id -u):$(id -g) \ | ||
-v $DATASET_DIR:/fetaldata \ | ||
--entrypoint /fetaldata/code/superresolution_pipeline.sh \ | ||
--env PATIENT="$PATIENT" \ | ||
--env DELTA_T="$DELTA_T" \ | ||
--env LAMBDA_TV="$LAMBDA_TV "\ | ||
--env PATIENT_DIR="/fetaldata/${PATIENT}" \ | ||
--env PATIENT_MASK_DIR="/fetaldata/${PATIENT_MASK_DIR}/anat" \ | ||
--env RESULTS="/fetaldata/${RESULTS}/tmp" \ | ||
-t sebastientourbier/mialsuperresolutiontoolkit:v1.1.0 \ | ||
"/fetaldata/code/${SCANS_LIST}" | ||
|
||
done < "$1" |
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,316 @@ | ||
#!/bin/sh | ||
#! Script: Brain image reconstruction / Brain superresolution image using BTK | ||
# Run with log saved: sh reconstruction.sh > reconstruction_original_images.log | ||
#Tune the number of cores used by the OpenMP library for multi-threading purposes | ||
export OMP_NUM_THREADS=$(grep -c ^processor /proc/cpuinfo 2>/dev/null || sysctl -n hw.ncpu) | ||
|
||
echo | ||
echo "-----------------------------------------------" | ||
echo | ||
|
||
echo "Starting superresolution pipeline for patient $PATIENT " | ||
|
||
echo | ||
echo "-----------------------------------------------" | ||
echo | ||
|
||
#LAMBDA_TV=0.25 #0.75 | ||
#DELTA_T=0.1 | ||
LOOPS=10 | ||
RAD_DILATION=1 | ||
START_ITER=1 | ||
MAX_ITER=1 | ||
|
||
|
||
echo | ||
echo "Automated brain localization and extraction parameters" | ||
echo | ||
echo "Type of brain mask : ${maskType}" | ||
echo | ||
echo "Super-resolution parameters" | ||
echo | ||
echo "LAMBDA_TV : ${LAMBDA_TV}" | ||
echo "DELTA_T : ${DELTA_T}" | ||
echo "LOOPS : ${LOOPS}" | ||
echo | ||
echo "Brain mask refinement parameters" | ||
echo | ||
echo "Number of loops : ${DELTA_T}" | ||
echo "Morphological dilation radius : ${RAD_DILATION}" | ||
echo | ||
echo "-----------------------------------------------" | ||
echo | ||
|
||
echo "Initialization..." | ||
|
||
START1=$(date +%s) | ||
|
||
echo | ||
echo "-----------------------------------------------" | ||
echo | ||
|
||
echo "OMP # of cores set to ${OMP_NUM_THREADS}!" | ||
echo | ||
|
||
#export BIN_DIR="/usr/local/bin" | ||
printf "BIN_DIR=${BIN_DIR} \n" | ||
|
||
SCANS="${1}" | ||
echo "List of scans : $SCANS" | ||
|
||
|
||
echo "Everything set!" | ||
echo | ||
echo "-----------------------------------------------" | ||
echo | ||
|
||
echo | ||
echo "-----------------------------------------------" | ||
echo | ||
echo "Should do brain localization and extraction here, but need to make a selection of the best scans with the best brain masks before reconstruction." | ||
echo | ||
echo "-----------------------------------------------" | ||
echo | ||
|
||
|
||
VOLS=0 | ||
while read -r line | ||
do | ||
VOLS=$((VOLS+1)) | ||
done < "$SCANS" | ||
|
||
echo | ||
echo "-----------------------------------------------" | ||
echo | ||
echo "Number of scans : ${VOLS}" | ||
echo | ||
echo "-----------------------------------------------" | ||
echo | ||
|
||
##Iteration of motion estimation / reconstruction / brain mask refinement | ||
ITER="${START_ITER}" | ||
#for (( ITER=$START_ITER; ITER<=$MAX_ITER; ITER++ )) | ||
while [ "$ITER" -le "$MAX_ITER" ] | ||
do | ||
echo "Performing iteration # ${ITER}" | ||
|
||
cmdIntensity="mialsrtkIntensityStandardization" | ||
cmdIntensityNLM="mialsrtkIntensityStandardization" | ||
cmdHistogramNormalization="python ${BIN_DIR}/mialsrtkHistogramNormalization.py" | ||
cmdHistogramNormalizationNLM="python ${BIN_DIR}/mialsrtkHistogramNormalization.py" | ||
|
||
if [ "$ITER" -eq "1" ]; | ||
then | ||
|
||
while read -r line | ||
do | ||
set -- $line | ||
stack=$1 | ||
orientation=$2 | ||
|
||
echo "Process stack $stack with $orientation orientation..." | ||
|
||
#Reorient the image | ||
mialsrtkOrientImage -i ${PATIENT_DIR}/${stack}.nii.gz -o $RESULTS/${stack}_reo_iteration_${ITER}.nii.gz -O "$orientation" | ||
mialsrtkOrientImage -i ${PATIENT_MASK_DIR}/${stack}_desc-brain_mask.nii.gz -o $RESULTS/${stack}_desc-brain_mask_reo_iteration_${ITER}.nii.gz -O "$orientation" | ||
|
||
#denoising on reoriented images | ||
weight="0.1" | ||
btkNLMDenoising -i "$RESULTS/${stack}_reo_iteration_${ITER}.nii.gz" -o "$RESULTS/${stack}_nlm_reo_iteration_${ITER}.nii.gz" -b $weight | ||
|
||
#Make slice intensities uniform in the stack | ||
mialsrtkCorrectSliceIntensity "$RESULTS/${stack}_nlm_reo_iteration_${ITER}.nii.gz" "$RESULTS/${stack}_desc-brain_mask_reo_iteration_${ITER}.nii.gz" "$RESULTS/${stack}_nlm_uni_reo_iteration_${ITER}.nii.gz" | ||
mialsrtkCorrectSliceIntensity "$RESULTS/${stack}_reo_iteration_${ITER}.nii.gz" "$RESULTS/${stack}_desc-brain_mask_reo_iteration_${ITER}.nii.gz" "$RESULTS/${stack}_uni_reo_iteration_${ITER}.nii.gz" | ||
|
||
#bias field correction slice by slice | ||
mialsrtkSliceBySliceN4BiasFieldCorrection "$RESULTS/${stack}_nlm_uni_reo_iteration_${ITER}.nii.gz" "$RESULTS/${stack}_desc-brain_mask_reo_iteration_${ITER}.nii.gz" "$RESULTS/${stack}_nlm_uni_bcorr_reo_iteration_${ITER}.nii.gz" "$RESULTS/${stack}_nlm_n4bias.nii.gz" | ||
mialsrtkSliceBySliceCorrectBiasField "$RESULTS/${stack}_uni_reo_iteration_${ITER}.nii.gz" "$RESULTS/${stack}_desc-brain_mask_reo_iteration_${ITER}.nii.gz" "$RESULTS/${stack}_nlm_n4bias.nii.gz" "$RESULTS/${stack}_uni_bcorr_reo_iteration_${ITER}.nii.gz" | ||
|
||
mialsrtkCorrectSliceIntensity "$RESULTS/${stack}_nlm_uni_bcorr_reo_iteration_${ITER}.nii.gz" "$RESULTS/${stack}_desc-brain_mask_reo_iteration_${ITER}.nii.gz" "$RESULTS/${stack}_nlm_uni_bcorr_reo_iteration_${ITER}.nii.gz" | ||
mialsrtkCorrectSliceIntensity "$RESULTS/${stack}_uni_bcorr_reo_iteration_${ITER}.nii.gz" "$RESULTS/${stack}_desc-brain_mask_reo_iteration_${ITER}.nii.gz" "$RESULTS/${stack}_uni_bcorr_reo_iteration_${ITER}.nii.gz" | ||
|
||
#Intensity rescaling cmd preparation | ||
cmdIntensityNLM="$cmdIntensityNLM -i $RESULTS/${stack}_nlm_uni_bcorr_reo_iteration_${ITER}.nii.gz -o $RESULTS/${stack}_nlm_uni_bcorr_reo_iteration_${ITER}.nii.gz" | ||
cmdIntensity="$cmdIntensity -i $RESULTS/${stack}_uni_bcorr_reo_iteration_${ITER}.nii.gz -o $RESULTS/${stack}_uni_bcorr_reo_iteration_${ITER}.nii.gz" | ||
cmdHistogramNormalization="$cmdHistogramNormalization -i $RESULTS/${stack}_uni_bcorr_reo_iteration_${ITER}.nii.gz -m $RESULTS/${stack}_desc-brain_mask_reo_iteration_${ITER}.nii.gz -o $RESULTS/${stack}_uni_bcorr_reo_iteration_${ITER}_histnorm.nii.gz" | ||
cmdHistogramNormalizationNLM="$cmdHistogramNormalization -i $RESULTS/${stack}_nlm_uni_bcorr_reo_iteration_${ITER}.nii.gz -m $RESULTS/${stack}_desc-brain_mask_reo_iteration_${ITER}.nii.gz -o $RESULTS/${stack}_nlm_uni_bcorr_reo_iteration_${ITER}_histnorm.nii.gz" | ||
|
||
done < "$SCANS" | ||
|
||
echo "$cmdIntensity" | ||
|
||
else | ||
|
||
while read -r line | ||
do | ||
set -- $line | ||
stack=$1 | ||
|
||
#Make slice intensities uniform in the stack | ||
mialsrtkCorrectSliceIntensity "$RESULTS/${stack}_nlm_reo_iteration_1.nii.gz" "$RESULTS/${stack}_desc-brain_mask_reo_iteration_${ITER}.nii.gz" "$RESULTS/${stack}_nlm_uni_reo_iteration_${ITER}.nii.gz" | ||
mialsrtkCorrectSliceIntensity "$RESULTS/${stack}_reo_iteration_1.nii.gz" "$RESULTS/${stack}_desc-brain_mask_reo_iteration_${ITER}.nii.gz" "$RESULTS/${stack}_uni_reo_iteration_${ITER}.nii.gz" | ||
|
||
cmdCorrectBiasField="mialsrtkCorrectBiasFieldWithMotionApplied -i $RESULTS/${stack}_nlm_uni_reo_iteration_${ITER}.nii.gz" | ||
cmdCorrectBiasField="$cmdCorrectBiasField -m $RESULTS/${stack}_desc-brain_mask_reo_iteration_${ITER}.nii.gz" | ||
cmdCorrectBiasField="$cmdCorrectBiasField -o $RESULTS/${stack}_nlm_uni_bcorr_reo_iteration_${ITER}.nii.gz" | ||
cmdCorrectBiasField="$cmdCorrectBiasField --input-bias-field $RESULTS/SRTV_${PATIENT}_${VOLS}V_lambda_${LAMBDA_TV}_deltat_${DELTA_T}_loops_${LOOPS}_rad${RAD_DILATION}_it${ITER}_gbcorrfield.nii.gz" | ||
cmdCorrectBiasField="$cmdCorrectBiasField --output-bias-field $RESULTS/${stack}_nlm_n4bias_iteration_${ITER}.nii.gz" | ||
cmdCorrectBiasField="$cmdCorrectBiasField -t $RESULTS/${stack}_transform_${VOLS}V_${LAST_ITER}.txt" | ||
eval "$cmdCorrectBiasField" | ||
|
||
cmdCorrectBiasField="mialsrtkCorrectBiasFieldWithMotionApplied -i $RESULTS/${stack}_uni_reo_iteration_${ITER}.nii.gz" | ||
cmdCorrectBiasField="$cmdCorrectBiasField -m $RESULTS/${stack}_desc-brain_mask_reo_iteration_${ITER}.nii.gz" | ||
cmdCorrectBiasField="$cmdCorrectBiasField -o $RESULTS/${stack}_uni_bcorr_reo_iteration_${ITER}.nii.gz" | ||
cmdCorrectBiasField="$cmdCorrectBiasField --input-bias-field $RESULTS/SRTV_${PATIENT}_${VOLS}V_lambda_${LAMBDA_TV}_deltat_${DELTA_T}_loops_${LOOPS}_rad${RAD_DILATION}_it${ITER}_gbcorrfield.nii.gz" | ||
cmdCorrectBiasField="$cmdCorrectBiasField --output-bias-field $RESULTS/${stack}_n4bias_iteration_${ITER}.nii.gz" | ||
cmdCorrectBiasField="$cmdCorrectBiasField -t $RESULTS/${stack}_transform_${VOLS}V_${LAST_ITER}.txt" | ||
eval "$cmdCorrectBiasField" | ||
|
||
cmdIntensityNLM="$cmdIntensityNLM -i $RESULTS/${stack}_nlm_uni_bcorr_reo_iteration_${ITER}.nii.gz -o $RESULTS/${stack}_nlm_uni_bcorr_reo_iteration_${ITER}.nii.gz" | ||
cmdIntensity="$cmdIntensity -i $RESULTS/${stack}_uni_bcorr_reo_iteration_${ITER}.nii.gz -o $RESULTS/${stack}_uni_bcorr_reo_iteration_${ITER}.nii.gz" | ||
|
||
cmdHistogramNormalization="$cmdHistogramNormalization -i $RESULTS/${stack}_uni_bcorr_reo_iteration_${ITER}.nii.gz -m $RESULTS/${stack}_desc-brain_mask_reo_iteration_${ITER}.nii.gz -o $RESULTS/${stack}_uni_bcorr_reo_iteration_${ITER}_histnorm.nii.gz" | ||
cmdHistogramNormalizationNLM="$cmdHistogramNormalizationNLM -i $RESULTS/${stack}_nlm_uni_bcorr_reo_iteration_${ITER}.nii.gz -m $RESULTS/${stack}_desc-brain_mask_reo_iteration_${ITER}.nii.gz -o $RESULTS/${stack}_nlm_uni_bcorr_reo_iteration_${ITER}_histnorm.nii.gz" | ||
|
||
done < "$SCANS" | ||
|
||
fi | ||
|
||
|
||
#Intensity rescaling | ||
eval "$cmdIntensityNLM" | ||
eval "$cmdIntensity" | ||
|
||
#histogram normalization - need to change the brain mask name expected according to the one used (full auto/localization and rigid extraction/localization only/manual) | ||
eval "$cmdHistogramNormalization" | ||
eval "$cmdHistogramNormalizationNLM" | ||
|
||
cmdIntensity="mialsrtkIntensityStandardization" | ||
cmdIntensityNLM="mialsrtkIntensityStandardization" | ||
while read -r line | ||
do | ||
set -- $line | ||
stack=$1 | ||
#Intensity rescaling cmd preparation | ||
cmdIntensityNLM="$cmdIntensityNLM -i $RESULTS/${stack}_nlm_uni_bcorr_reo_iteration_${ITER}_histnorm.nii.gz -o $RESULTS/${stack}_nlm_uni_bcorr_reo_iteration_${ITER}_histnorm.nii.gz" | ||
cmdIntensity="$cmdIntensity -i $RESULTS/${stack}_uni_bcorr_reo_iteration_${ITER}_histnorm.nii.gz -o $RESULTS/${stack}_uni_bcorr_reo_iteration_${ITER}_histnorm.nii.gz" | ||
done < "$SCANS" | ||
|
||
#Intensity rescaling | ||
eval "$cmdIntensityNLM" | ||
eval "$cmdIntensity" | ||
|
||
echo "Initialize the super-resolution image using initial masks - Iteration ${ITER}..." | ||
|
||
cmdImageRECON="mialsrtkImageReconstruction --mask" | ||
cmdSuperResolution="mialsrtkTVSuperResolution" | ||
#cmdRobustSuperResolution="$MIALSRTK_APPLICATIONS/mialsrtkRobustTVSuperResolutionWithGMM" | ||
|
||
#Preparation for (1) motion estimation and SDI reconstruction and (2) super-resolution reconstruction | ||
while read -r line | ||
do | ||
set -- $line | ||
stack=$1 | ||
mialsrtkMaskImage -i "$RESULTS/${stack}_nlm_uni_bcorr_reo_iteration_${ITER}_histnorm.nii.gz" -m $RESULTS/${stack}_desc-brain_mask_reo_iteration_${ITER}.nii.gz -o "$RESULTS/${stack}_nlm_uni_bcorr_reo_iteration_${ITER}_histnorm.nii.gz" | ||
|
||
cmdImageRECON="$cmdImageRECON -i $RESULTS/${stack}_nlm_uni_bcorr_reo_iteration_${ITER}_histnorm.nii.gz" | ||
cmdImageRECON="$cmdImageRECON -m $RESULTS/${stack}_desc-brain_mask_reo_iteration_${ITER}.nii.gz" | ||
cmdImageRECON="$cmdImageRECON -t $RESULTS/${stack}_transform_${VOLS}V_${ITER}.txt" | ||
|
||
cmdSuperResolution="$cmdSuperResolution -i $RESULTS/${stack}_uni_bcorr_reo_iteration_${ITER}_histnorm.nii.gz" | ||
cmdSuperResolution="$cmdSuperResolution -m $RESULTS/${stack}_desc-brain_mask_reo_iteration_${ITER}.nii.gz" | ||
cmdSuperResolution="$cmdSuperResolution -t $RESULTS/${stack}_transform_${VOLS}V_${ITER}.txt" | ||
#cmdRobustSuperResolution="$cmdRobustSuperResolution -i $RESULTS/${stack}_uni_bcorr_reo_iteration_${ITER}_histnorm.nii.gz -m $RESULTS/${stack}_desc-brain_mask_reo_iteration_${ITER}.nii.gz -t $RESULTS/${stack}_transform_${VOLS}V_${ITER}.txt" | ||
done < "$SCANS" | ||
|
||
#Run motion estimation and SDI reconstruction | ||
echo "Run motion estimation and scattered data interpolation - Iteration ${ITER}..." | ||
|
||
cmdImageRECON="$cmdImageRECON -o $RESULTS/SDI_${PATIENT}_${VOLS}V_rad${RAD_DILATION}_it${ITER}.nii.gz" | ||
eval "$cmdImageRECON" | ||
|
||
echo "Done" | ||
echo | ||
echo "##########################################################################################################################" | ||
echo | ||
|
||
#Brain image super-reconstruction | ||
echo "Reconstruct the super-resolution image with initial brain masks- Iteration ${ITER}..." | ||
|
||
cmdSuperResolution="$cmdSuperResolution -o $RESULTS/SRTV_${PATIENT}_${VOLS}V_rad${RAD_DILATION}_it${ITER}.nii.gz" | ||
cmdSuperResolution="$cmdSuperResolution -r $RESULTS/SDI_${PATIENT}_${VOLS}V_rad${RAD_DILATION}_it${ITER}.nii.gz" | ||
cmdSuperResolution="$cmdSuperResolution --bregman-loop 1 --loop ${LOOPS} --iter 50 --step-scale 10 --gamma 10 --deltat ${DELTA_T}" | ||
cmdSuperResolution="$cmdSuperResolution --lambda ${LAMBDA_TV} --inner-thresh 0.00001 --outer-thresh 0.000001" | ||
echo "CMD: $cmdSuperResolution" | ||
eval "$cmdSuperResolution" | ||
|
||
echo "Done" | ||
echo | ||
|
||
#up="1.0" | ||
#cmdRobustSuperResolution="$cmdRobustSuperResolution -o $RESULTS/RobustSRTV_${PATIENT}_${VOLS}V_NoNLM_bcorr_norm_lambda_${LAMBDA_TV}_deltat_${DELTA_T}_loops_${LOOPS}_it${ITER}_rad${RAD_DILATION}_up${up}.nii.gz -r $RESULTS/SDI_${PATIENT}_${VOLS}V_nlm_bcorr_norm_it${ITER}_rad${RAD_DILATION}.nii.gz --bregman-loop 1 --loop ${LOOPS} --iter 50 --step-scale 10 --gamma 10 --lambda ${LAMBDA_TV} --deltat ${DELTA_T} --inner-thresh 0.00001 --outer-thresh 0.000001 --use-robust --huber-mode 2 --upscaling-factor $up" | ||
#eval "$cmdRobustSuperResolution" | ||
|
||
NEXT_ITER=${ITER} | ||
NEXT_ITER=$((NEXT_ITER+1)) | ||
|
||
echo "##########################################################################################################################" | ||
echo | ||
|
||
echo "Refine the mask of the HR image for next iteration (${NEXT_ITER})..." | ||
|
||
echo | ||
echo "##########################################################################################################################" | ||
echo | ||
|
||
#Preparation for brain mask refinement | ||
cmdRefineMasks="mialsrtkRefineHRMaskByIntersection --use-staple --radius-dilation ${RAD_DILATION}" | ||
while read -r line | ||
do | ||
set -- $line | ||
stack=$1 | ||
cmdRefineMasks="$cmdRefineMasks -i $RESULTS/${stack}_uni_bcorr_reo_iteration_${ITER}_histnorm.nii.gz" | ||
cmdRefineMasks="$cmdRefineMasks -m $RESULTS/${stack}_desc-brain_mask_reo_iteration_${ITER}.nii.gz" | ||
cmdRefineMasks="$cmdRefineMasks -t $RESULTS/${stack}_transform_${VOLS}V_${ITER}.txt" | ||
cmdRefineMasks="$cmdRefineMasks -O $RESULTS/${stack}_desc-brain_mask_reo_iteration_${NEXT_ITER}.nii.gz" | ||
done < "$SCANS" | ||
|
||
#Brain mask refinement | ||
|
||
cmdRefineMasks="$cmdRefineMasks -o $RESULTS/SDI_${PATIENT}_${VOLS}V_rad${RAD_DILATION}_it${ITER}_brain_mask.nii.gz -r $RESULTS/SDI_${PATIENT}_${VOLS}V_rad${RAD_DILATION}_it${ITER}.nii.gz" | ||
eval "$cmdRefineMasks" | ||
|
||
#Bias field refinement | ||
mialsrtkN4BiasFieldCorrection "$RESULTS/SRTV_${PATIENT}_${VOLS}V_rad${RAD_DILATION}_it${ITER}.nii.gz" "$RESULTS/SDI_${PATIENT}_${VOLS}V_rad${RAD_DILATION}_it${ITER}_brain_mask.nii.gz" "$RESULTS/SRTV_${PATIENT}_${VOLS}V_rad${RAD_DILATION}_it${ITER}_gbcorr.nii.gz" "$RESULTS/SRTV_${PATIENT}_${VOLS}V_rad${RAD_DILATION}_it${ITER}_gbcorrfield.nii.gz" | ||
|
||
#Brain masking of the reconstructed image | ||
|
||
mialsrtkMaskImage -i "$RESULTS/SRTV_${PATIENT}_${VOLS}V_rad${RAD_DILATION}_it${ITER}.nii.gz" -m "$RESULTS/SDI_${PATIENT}_${VOLS}V_rad${RAD_DILATION}_it${ITER}_brain_mask.nii.gz" -o $RESULTS/SRTV_${PATIENT}_${VOLS}V_rad${RAD_DILATION}_it${ITER}_masked.nii.gz | ||
|
||
echo | ||
echo "##########################################################################################################################" | ||
echo | ||
|
||
LAST_ITER="$ITER" | ||
ITER=$((ITER+1)) | ||
|
||
done | ||
|
||
FINAL_OUTPUT_DIR="$(dirname "$RESULTS")/anat" | ||
echo "Copy final outputs to ${FINAL_OUTPUT_DIR}" | ||
cp "$RESULTS/SDI_${PATIENT}_${VOLS}V_rad${RAD_DILATION}_it${LAST_ITER}.nii.gz" "${FINAL_OUTPUT_DIR}/${PATIENT}_rec-SDI_T2w.nii.gz" | ||
cp "$RESULTS/SRTV_${PATIENT}_${VOLS}V_rad${RAD_DILATION}_it${LAST_ITER}.nii.gz" "${FINAL_OUTPUT_DIR}/${PATIENT}_rec-SR_T2w.nii.gz" | ||
cp "$RESULTS/SRTV_${PATIENT}_${VOLS}V_rad${RAD_DILATION}_it${LAST_ITER}_masked.nii.gz" "${FINAL_OUTPUT_DIR}/${PATIENT}_desc-masked_rec-SR_T2w.nii.gz" | ||
|
||
echo | ||
echo "##########################################################################################################################" | ||
echo | ||
|
||
END1=$(date +%s) | ||
|
||
DIFF1=$(( $END1 - $START1 )) | ||
|
||
echo "Done. It took $DIFF1 seconds for reconstruction, after $MAX_ITER refinement loops, using ${VOLS} volumes." | ||
echo | ||
echo "-----------------------------------------------" | ||
echo |
Binary file added
BIN
+6.35 KB
data/derivatives/manual_masks/sub-01/anat/sub-01_run-01_T2w_desc-brain_mask.nii.gz
Binary file not shown.
Binary file added
BIN
+7.37 KB
data/derivatives/manual_masks/sub-01/anat/sub-01_run-02_T2w_desc-brain_mask.nii.gz
Binary file not shown.
Binary file added
BIN
+6.74 KB
data/derivatives/manual_masks/sub-01/anat/sub-01_run-03_T2w_desc-brain_mask.nii.gz
Binary file not shown.
Binary file added
BIN
+16.1 KB
...v-0.75_dt-0.01_run-01/sub-01/tmp/sub-01_run-01_T2w_desc-brain_mask_reo_iteration_1.nii.gz
Binary file not shown.
Binary file added
BIN
+590 KB
...erivatives/mialsrtk_tv-0.75_dt-0.01_run-01/sub-01/tmp/sub-01_run-01_T2w_nlm_n4bias.nii.gz
Binary file not shown.
Binary file added
BIN
+7.34 MB
...s/mialsrtk_tv-0.75_dt-0.01_run-01/sub-01/tmp/sub-01_run-01_T2w_nlm_reo_iteration_1.nii.gz
Binary file not shown.
Binary file added
BIN
+409 KB
..._tv-0.75_dt-0.01_run-01/sub-01/tmp/sub-01_run-01_T2w_nlm_uni_bcorr_reo_iteration_1.nii.gz
Binary file not shown.
Binary file added
BIN
+379 KB
...alsrtk_tv-0.75_dt-0.01_run-01/sub-01/tmp/sub-01_run-01_T2w_nlm_uni_reo_iteration_1.nii.gz
Binary file not shown.
Binary file added
BIN
+2.83 MB
...tives/mialsrtk_tv-0.75_dt-0.01_run-01/sub-01/tmp/sub-01_run-01_T2w_reo_iteration_1.nii.gz
Binary file not shown.
Binary file added
BIN
+367 KB
...srtk_tv-0.75_dt-0.01_run-01/sub-01/tmp/sub-01_run-01_T2w_uni_bcorr_reo_iteration_1.nii.gz
Binary file not shown.
Binary file added
BIN
+367 KB
....75_dt-0.01_run-01/sub-01/tmp/sub-01_run-01_T2w_uni_bcorr_reo_iteration_1_histnorm.nii.gz
Binary file not shown.
Binary file added
BIN
+337 KB
...s/mialsrtk_tv-0.75_dt-0.01_run-01/sub-01/tmp/sub-01_run-01_T2w_uni_reo_iteration_1.nii.gz
Binary file not shown.
Binary file added
BIN
+17.7 KB
...v-0.75_dt-0.01_run-01/sub-01/tmp/sub-01_run-02_T2w_desc-brain_mask_reo_iteration_1.nii.gz
Binary file not shown.
Binary file added
BIN
+647 KB
...erivatives/mialsrtk_tv-0.75_dt-0.01_run-01/sub-01/tmp/sub-01_run-02_T2w_nlm_n4bias.nii.gz
Binary file not shown.
Binary file added
BIN
+8.84 MB
...s/mialsrtk_tv-0.75_dt-0.01_run-01/sub-01/tmp/sub-01_run-02_T2w_nlm_reo_iteration_1.nii.gz
Binary file not shown.
Binary file added
BIN
+485 KB
..._tv-0.75_dt-0.01_run-01/sub-01/tmp/sub-01_run-02_T2w_nlm_uni_bcorr_reo_iteration_1.nii.gz
Binary file not shown.
Binary file added
BIN
+448 KB
...alsrtk_tv-0.75_dt-0.01_run-01/sub-01/tmp/sub-01_run-02_T2w_nlm_uni_reo_iteration_1.nii.gz
Binary file not shown.
Binary file added
BIN
+3.37 MB
...tives/mialsrtk_tv-0.75_dt-0.01_run-01/sub-01/tmp/sub-01_run-02_T2w_reo_iteration_1.nii.gz
Binary file not shown.
Binary file added
BIN
+405 KB
...srtk_tv-0.75_dt-0.01_run-01/sub-01/tmp/sub-01_run-02_T2w_uni_bcorr_reo_iteration_1.nii.gz
Binary file not shown.
Binary file added
BIN
+407 KB
....75_dt-0.01_run-01/sub-01/tmp/sub-01_run-02_T2w_uni_bcorr_reo_iteration_1_histnorm.nii.gz
Binary file not shown.
Binary file added
BIN
+369 KB
...s/mialsrtk_tv-0.75_dt-0.01_run-01/sub-01/tmp/sub-01_run-02_T2w_uni_reo_iteration_1.nii.gz
Binary file not shown.
Binary file added
BIN
+15.6 KB
...v-0.75_dt-0.01_run-01/sub-01/tmp/sub-01_run-03_T2w_desc-brain_mask_reo_iteration_1.nii.gz
Binary file not shown.
Binary file added
BIN
+536 KB
...erivatives/mialsrtk_tv-0.75_dt-0.01_run-01/sub-01/tmp/sub-01_run-03_T2w_nlm_n4bias.nii.gz
Binary file not shown.
Binary file added
BIN
+8 MB
...s/mialsrtk_tv-0.75_dt-0.01_run-01/sub-01/tmp/sub-01_run-03_T2w_nlm_reo_iteration_1.nii.gz
Binary file not shown.
Binary file added
BIN
+486 KB
..._tv-0.75_dt-0.01_run-01/sub-01/tmp/sub-01_run-03_T2w_nlm_uni_bcorr_reo_iteration_1.nii.gz
Binary file not shown.
Binary file added
BIN
+277 KB
...dt-0.01_run-01/sub-01/tmp/sub-01_run-03_T2w_nlm_uni_bcorr_reo_iteration_1_histnorm.nii.gz
Binary file not shown.
Binary file added
BIN
+472 KB
...alsrtk_tv-0.75_dt-0.01_run-01/sub-01/tmp/sub-01_run-03_T2w_nlm_uni_reo_iteration_1.nii.gz
Binary file not shown.
Binary file added
BIN
+3.39 MB
...tives/mialsrtk_tv-0.75_dt-0.01_run-01/sub-01/tmp/sub-01_run-03_T2w_reo_iteration_1.nii.gz
Binary file not shown.
Binary file added
BIN
+333 KB
...srtk_tv-0.75_dt-0.01_run-01/sub-01/tmp/sub-01_run-03_T2w_uni_bcorr_reo_iteration_1.nii.gz
Binary file not shown.
Binary file added
BIN
+334 KB
....75_dt-0.01_run-01/sub-01/tmp/sub-01_run-03_T2w_uni_bcorr_reo_iteration_1_histnorm.nii.gz
Binary file not shown.
Binary file added
BIN
+304 KB
...s/mialsrtk_tv-0.75_dt-0.01_run-01/sub-01/tmp/sub-01_run-03_T2w_uni_reo_iteration_1.nii.gz
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Oops, something went wrong.