Skip to content

Update batch_single_subject.sh and process_data.sh to match changes to 2024 SCT Course Slides #64

Update batch_single_subject.sh and process_data.sh to match changes to 2024 SCT Course Slides

Update batch_single_subject.sh and process_data.sh to match changes to 2024 SCT Course Slides #64

name: "Run sct_run_batch -s process_data.sh"
# The tl;dr purpose of this workflow is to:
# - A) Run the batch processing script part of the the SCT Course
# - B) If run manually, then take some of the output files and package them into tutorial-specific datasets.
#
# In-depth explanation:
# Most of SCT's tutorials depend on files generated by previous steps. (For example, 'sct_register_to_template'
# depends on the segmented spinal cord image file generated by `sct_deepseg`. This creates a dilemma: If we want
# SCT's tutorials to stand alone, we need to provide these intermediate files. But, if we want to run the tutorials
# start to finish in a sequence (e.g. during the SCT Course), it would be confusing if the intermediate files
# were already there.
#
# The solution is to only store the minimally-necessary files in the repository, then generate the intermediate files
# using this workflow. That way, we can provide 2 different downloads:
# - 'sct_course_data.zip': Files required to run the SCT course from start to finish.
# - 'registration.zip', 'segmentation.zip', etc.: Files required by individual tutorials.
on:
pull_request:
jobs:
run-course-script:
runs-on: ubuntu-latest
steps:
- name: Checkout spinalcordtoolbox
uses: actions/checkout@v4
with:
repository: spinalcordtoolbox/spinalcordtoolbox
path: spinalcordtoolbox
# install_sct edits ~/.bashrc, but those environment changes don't get passed to subsequent steps in GH Actions.
# So, we filter through the .bashrc and pass the values to $GITHUB_ENV and $GITHUB_PATH.
# Relevant documentation: https://docs.github.com/en/actions/reference/workflow-commands-for-github-actions#environment-files
# This workaround should be replaced by https://github.com/spinalcordtoolbox/spinalcordtoolbox/pull/3198#discussion_r568225392
- name: Install spinalcordtoolbox
run: |
cd spinalcordtoolbox
./install_sct -iy
cat ~/.bashrc | grep "export SCT_DIR" | cut -d " " -f 2 >> $GITHUB_ENV
cat ~/.bashrc | grep "export PATH" | grep -o "/.*" | cut -d ':' -f 1 >> $GITHUB_PATH
- name: "Checkout '${{ github.event.repository.name }}'"
uses: actions/checkout@v4
with:
path: ${{ github.event.repository.name }}
- name: Run sct_run_batch -s process_data.sh
run: |
cd "${{ github.event.repository.name }}/multi_subject"
sct_run_batch -script process_data.sh -config config.yml
- name: Output full log for sanity checking
run: |
cd "${{ github.event.repository.name }}/multi_subject/output/log"
for logfile in process_data_sub-01.log err.process_data_sub-01.log; do
if [[ -e "${logfile}" ]]; then
echo "=== Contents of ${logfile} ==="
cat "${logfile}"
else
echo "=== No file ${logfile} ==="
fi
done
- name: Check that script executed without error
run: |
cd "${{ github.event.repository.name }}/multi_subject/output/log"
[ "$(compgen -G "process_data_sub-0*.log")" ] # Log files should exist
[ ! "$(compgen -G "err.process_data_sub-0*.log")" ] # Error files should NOT exist
grep -iF "warning" process_data_sub-01.log
grep -iF "error" process_data_sub-01.log