From 9a36e851ed5d229fc169789c382bf5a0a78e745b Mon Sep 17 00:00:00 2001 From: Mathieu Boudreau Date: Fri, 1 Nov 2024 10:19:46 -0300 Subject: [PATCH 1/8] Initial JB build without reqs to wakeup GitHub Actions --- .github/workflows/run_notebooks.yml | 57 +++++------------------------ _config.yml | 25 +++++++++++++ _toc.yml | 8 ++++ requirements.txt | 2 +- 4 files changed, 44 insertions(+), 48 deletions(-) create mode 100644 _config.yml create mode 100644 _toc.yml diff --git a/.github/workflows/run_notebooks.yml b/.github/workflows/run_notebooks.yml index 8fbcbcd..5c0d837 100644 --- a/.github/workflows/run_notebooks.yml +++ b/.github/workflows/run_notebooks.yml @@ -4,6 +4,7 @@ on: push: branches: - main # Trigger the action on the main branch + - mb/jb jobs: # Run the notebooks @@ -28,12 +29,12 @@ jobs: - name: Install Python dependencies run: | python -m pip install --upgrade pip - pip install -r requirements.txt + #pip install -r requirements.txt - name: Install SCT run: | git clone --depth 1 https://github.com/spinalcordtoolbox/spinalcordtoolbox.git - yes | spinalcordtoolbox/install_sct + #yes | spinalcordtoolbox/install_sct # NB: 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 @@ -46,51 +47,13 @@ jobs: # Make sure SCT can be called from within the environment sct_check_dependencies - - name: Run Jupyter Notebooks + - name: Run Jupyter Notebooks and build book continue-on-error: true # Allow workflow to continue even if notebook execution fails - run: | - echo $PATH - mkdir -p executed_notebooks - for notebook in $(find . -name "*.ipynb"); do - echo "Executing $notebook" - jupyter nbconvert --to notebook --execute --allow-errors --inplace \ - --output executed_notebooks/$(basename $notebook) $notebook \ - 2>&1 | tee -a notebook_execution.log || exit 1 - done - - - name: Check Execution Log - run: cat notebook_execution.log - - - name: Upload Executed Notebooks - uses: actions/upload-artifact@v3 - with: - name: executed-notebooks - path: executed_notebooks/ - - # Deploy to GitHub Pages (depends on run-notebooks) - deploy: - runs-on: ubuntu-latest - needs: run-notebooks # Ensure this job runs after 'run-notebooks' - - steps: - - name: Checkout Repository - uses: actions/checkout@v3 - - - name: Download Executed Notebooks - uses: actions/download-artifact@v3 + run: jupyter-book build . + - name: Upload artifact + uses: actions/upload-pages-artifact@v3 with: - name: executed-notebooks - path: executed_notebooks/ - - - name: Copy Executed Notebooks to Pages Directory - run: | - COMMIT_SHA=$(git rev-parse --short HEAD) - mkdir -p gh-pages/$COMMIT_SHA - cp executed_notebooks/*.ipynb gh-pages/$COMMIT_SHA/ - + path: './_build/html' - name: Deploy to GitHub Pages - uses: peaceiris/actions-gh-pages@v3 - with: - github_token: ${{ secrets.GITHUB_TOKEN }} - publish_dir: gh-pages - publish_branch: gh-pages + id: deployment + uses: actions/deploy-pages@v4 diff --git a/_config.yml b/_config.yml new file mode 100644 index 0000000..c933266 --- /dev/null +++ b/_config.yml @@ -0,0 +1,25 @@ +# Book settings +# Learn more at https://jupyterbook.org/customize/config.html + +title: Multi-center benchmarking of cervical spinal cord RF coils at 7 T: A traveling spines study +author: NeuroPoly Lab + +# Force re-execution of notebooks on each build. +# See https://jupyterbook.org/content/execute.html +execute: + execute_notebooks: force + +launch_buttons: + notebook_interface: jupyterlab + binderhub_url: https://mybinder.org + + +# Information about where the book exists on the web +repository: + url: https://github.com/coil-qc-code/coil-qc-code # Online location of your book + branch: mb/jb # Which branch of the repository should be used when creating links (optional) + +only_build_toc_files: true + +execute: + timeout: 36000 diff --git a/_toc.yml b/_toc.yml new file mode 100644 index 0000000..d8fd13f --- /dev/null +++ b/_toc.yml @@ -0,0 +1,8 @@ +# Table of contents +# Learn more at https://jupyterbook.org/customize/toc.html + +format: jb-book +root: README.md +chapters: +- file: data_processing-human.ipynb +- file: data_processing-phantom.ipynb \ No newline at end of file diff --git a/requirements.txt b/requirements.txt index 1c76210..d4a7dd3 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,4 @@ -jupyter-book==0.13.0 +jupyter-book lxml_html_clean plotly seaborn From 58511f5cf8876c6645a45095cbef873d6107bb39 Mon Sep 17 00:00:00 2001 From: Mathieu Boudreau Date: Fri, 1 Nov 2024 10:20:44 -0300 Subject: [PATCH 2/8] Skip sct-check for now --- .github/workflows/run_notebooks.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/run_notebooks.yml b/.github/workflows/run_notebooks.yml index 5c0d837..13638f8 100644 --- a/.github/workflows/run_notebooks.yml +++ b/.github/workflows/run_notebooks.yml @@ -45,7 +45,7 @@ jobs: - name: Verify SCT installation run: | # Make sure SCT can be called from within the environment - sct_check_dependencies + #sct_check_dependencies - name: Run Jupyter Notebooks and build book continue-on-error: true # Allow workflow to continue even if notebook execution fails From b67b1c74878fcb8a5222444a58bf3a3997734853 Mon Sep 17 00:00:00 2001 From: Mathieu Boudreau Date: Fri, 1 Nov 2024 10:22:42 -0300 Subject: [PATCH 3/8] Add jb reqs --- .github/workflows/run_notebooks.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/run_notebooks.yml b/.github/workflows/run_notebooks.yml index 13638f8..18a3114 100644 --- a/.github/workflows/run_notebooks.yml +++ b/.github/workflows/run_notebooks.yml @@ -29,6 +29,7 @@ jobs: - name: Install Python dependencies run: | python -m pip install --upgrade pip + pip install notebook jupyter-book #pip install -r requirements.txt - name: Install SCT From ef53b60c2317ee1f48f3bda24de7758addf5c54f Mon Sep 17 00:00:00 2001 From: Mathieu Boudreau Date: Fri, 1 Nov 2024 10:24:01 -0300 Subject: [PATCH 4/8] Fix string in config --- _config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/_config.yml b/_config.yml index c933266..6e17c05 100644 --- a/_config.yml +++ b/_config.yml @@ -1,7 +1,7 @@ # Book settings # Learn more at https://jupyterbook.org/customize/config.html -title: Multi-center benchmarking of cervical spinal cord RF coils at 7 T: A traveling spines study +title: "Multi-center benchmarking of cervical spinal cord RF coils at 7 T: A traveling spines study" author: NeuroPoly Lab # Force re-execution of notebooks on each build. From b8d116002612dbdfab02933811d540644dfa3216 Mon Sep 17 00:00:00 2001 From: Mathieu Boudreau Date: Fri, 1 Nov 2024 10:25:27 -0300 Subject: [PATCH 5/8] GH Actions is awake, try again --- _config.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/_config.yml b/_config.yml index 6e17c05..0afcd34 100644 --- a/_config.yml +++ b/_config.yml @@ -23,3 +23,4 @@ only_build_toc_files: true execute: timeout: 36000 + From 638b018f597210b2a7bd6a388f9f00e9494128e6 Mon Sep 17 00:00:00 2001 From: Mathieu Boudreau Date: Fri, 1 Nov 2024 10:27:44 -0300 Subject: [PATCH 6/8] Appologize to GH Actions and explicitely tell it has permission to write to pages --- .github/workflows/run_notebooks.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/run_notebooks.yml b/.github/workflows/run_notebooks.yml index 18a3114..a231f22 100644 --- a/.github/workflows/run_notebooks.yml +++ b/.github/workflows/run_notebooks.yml @@ -6,6 +6,10 @@ on: - main # Trigger the action on the main branch - mb/jb +permissions: + id-token: write + pages: write + jobs: # Run the notebooks run-notebooks: From 91e5780181fd08f4dafa298d57807dc7f79af55f Mon Sep 17 00:00:00 2001 From: Mathieu Boudreau Date: Fri, 1 Nov 2024 10:40:41 -0300 Subject: [PATCH 7/8] Add cell tags to scroll long outputs --- data_processing-human.ipynb | 80 +++++++++++++++++++++++++++++------ data_processing-phantom.ipynb | 42 +++++++++++++++--- 2 files changed, 103 insertions(+), 19 deletions(-) diff --git a/data_processing-human.ipynb b/data_processing-human.ipynb index 24e28cc..6a92294 100644 --- a/data_processing-human.ipynb +++ b/data_processing-human.ipynb @@ -1,5 +1,13 @@ { "cells": [ + { + "cell_type": "markdown", + "id": "86a25f63", + "metadata": {}, + "source": [ + "# 7T coil comparison: processing of human data" + ] + }, { "cell_type": "markdown", "id": "0", @@ -49,7 +57,11 @@ "cell_type": "code", "execution_count": null, "id": "3", - "metadata": {}, + "metadata": { + "tags": [ + "scroll-output" + ] + }, "outputs": [], "source": [ "# Download data from OpenNeuro ⏳\n", @@ -89,7 +101,11 @@ "cell_type": "code", "execution_count": null, "id": "6", - "metadata": {}, + "metadata": { + "tags": [ + "scroll-output" + ] + }, "outputs": [], "source": [ "# Run segmentation on MP2RAGE scan ⏳\n", @@ -114,7 +130,11 @@ "cell_type": "code", "execution_count": null, "id": "7", - "metadata": {}, + "metadata": { + "tags": [ + "scroll-output" + ] + }, "outputs": [], "source": [ "# Label vertebrae\n", @@ -137,7 +157,11 @@ "cell_type": "code", "execution_count": null, "id": "8", - "metadata": {}, + "metadata": { + "tags": [ + "scroll-output" + ] + }, "outputs": [], "source": [ "# Crop MP2RAGE for faster processing and better registration results\n", @@ -163,7 +187,11 @@ "cell_type": "code", "execution_count": null, "id": "10", - "metadata": {}, + "metadata": { + "tags": [ + "scroll-output" + ] + }, "outputs": [], "source": [ "# Segment spinal cord on TFL data (B1+ mapping) ⏳\n", @@ -187,7 +215,11 @@ "cell_type": "code", "execution_count": null, "id": "11", - "metadata": {}, + "metadata": { + "tags": [ + "scroll-output" + ] + }, "outputs": [], "source": [ "# Register TFL data (B1+ mapping) to the MP2RAGE scan ⏳\n", @@ -205,7 +237,11 @@ "cell_type": "code", "execution_count": null, "id": "12", - "metadata": {}, + "metadata": { + "tags": [ + "scroll-output" + ] + }, "outputs": [], "source": [ "# Register DREAM data (B1+ mapping) to the MP2RAGE scan ⏳\n", @@ -219,7 +255,11 @@ "cell_type": "code", "execution_count": null, "id": "13", - "metadata": {}, + "metadata": { + "tags": [ + "scroll-output" + ] + }, "outputs": [], "source": [ "# Segment spinal cord on SNR data\n", @@ -246,7 +286,11 @@ "cell_type": "code", "execution_count": null, "id": "14", - "metadata": {}, + "metadata": { + "tags": [ + "scroll-output" + ] + }, "outputs": [], "source": [ "# Register Rx coilQA data (SNR, g-factor) to the MP2RAGE scan ⏳\n", @@ -260,7 +304,11 @@ "cell_type": "code", "execution_count": null, "id": "15", - "metadata": {}, + "metadata": { + "tags": [ + "scroll-output" + ] + }, "outputs": [], "source": [ "# Warping spinal cord segmentation and vertebral level to each flip angle and SNR map\n", @@ -511,7 +559,11 @@ "cell_type": "code", "execution_count": null, "id": "21", - "metadata": {}, + "metadata": { + "tags": [ + "scroll-output" + ] + }, "outputs": [], "source": [ "# Extract B1+ and SNR along the spinal cord between levels C1 and T2 (included) and save data to CSV files\n", @@ -914,7 +966,11 @@ "cell_type": "code", "execution_count": null, "id": "34", - "metadata": {}, + "metadata": { + "tags": [ + "scroll-output" + ] + }, "outputs": [], "source": [ "# First co-regsiter subjects across sites for better visualisation and flatten the spinal cord (ie, being it into the sagittal midline)\n", diff --git a/data_processing-phantom.ipynb b/data_processing-phantom.ipynb index 0e37ad7..4f5e4e0 100644 --- a/data_processing-phantom.ipynb +++ b/data_processing-phantom.ipynb @@ -51,7 +51,11 @@ "cell_type": "code", "execution_count": null, "id": "3", - "metadata": {}, + "metadata": { + "tags": [ + "scroll-output" + ] + }, "outputs": [], "source": [ "# Download data from OpenNeuro ⏳\n", @@ -91,7 +95,11 @@ "cell_type": "code", "execution_count": null, "id": "6", - "metadata": {}, + "metadata": { + "tags": [ + "scroll-output" + ] + }, "outputs": [], "source": [ "# Convert the TFL flip angle maps to B1+ efficiency maps [nT/V] (inspired by code from Kyle Gilbert)\n", @@ -142,7 +150,11 @@ "cell_type": "code", "execution_count": null, "id": "7", - "metadata": {}, + "metadata": { + "tags": [ + "scroll-output" + ] + }, "outputs": [], "source": [ "# load DREAM FA maps acquired with different reference voltages\n", @@ -244,7 +256,11 @@ "cell_type": "code", "execution_count": null, "id": "8", - "metadata": {}, + "metadata": { + "tags": [ + "scroll-output" + ] + }, "outputs": [], "source": [ "# Split SNR data across multiple volumes. The first volume corresponds to the SoS SNR reconstruction, which is\n", @@ -270,7 +286,11 @@ "cell_type": "code", "execution_count": null, "id": "10", - "metadata": {}, + "metadata": { + "tags": [ + "scroll-output" + ] + }, "outputs": [], "source": [ "os.chdir(os.path.join(path_data, \"sub-CRMBM\", \"fmap\"))\n", @@ -301,7 +321,11 @@ "cell_type": "code", "execution_count": null, "id": "12", - "metadata": {}, + "metadata": { + "tags": [ + "scroll-output" + ] + }, "outputs": [], "source": [ "# Create dictionary of labels across sites\n", @@ -377,7 +401,11 @@ "cell_type": "code", "execution_count": null, "id": "15", - "metadata": {}, + "metadata": { + "tags": [ + "scroll-output" + ] + }, "outputs": [], "source": [ "# Extract B1+ and SNR along the spinal cord mask and save data to CSV files\n", From 647befbb2fa1e0166eeda024caaa11d41f86258d Mon Sep 17 00:00:00 2001 From: Mathieu Boudreau Date: Fri, 1 Nov 2024 10:41:15 -0300 Subject: [PATCH 8/8] Restore dependencies installation --- .github/workflows/run_notebooks.yml | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/.github/workflows/run_notebooks.yml b/.github/workflows/run_notebooks.yml index a231f22..f9d6ff9 100644 --- a/.github/workflows/run_notebooks.yml +++ b/.github/workflows/run_notebooks.yml @@ -33,13 +33,12 @@ jobs: - name: Install Python dependencies run: | python -m pip install --upgrade pip - pip install notebook jupyter-book - #pip install -r requirements.txt + pip install -r requirements.txt - name: Install SCT run: | git clone --depth 1 https://github.com/spinalcordtoolbox/spinalcordtoolbox.git - #yes | spinalcordtoolbox/install_sct + yes | spinalcordtoolbox/install_sct # NB: 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 @@ -50,7 +49,7 @@ jobs: - name: Verify SCT installation run: | # Make sure SCT can be called from within the environment - #sct_check_dependencies + sct_check_dependencies - name: Run Jupyter Notebooks and build book continue-on-error: true # Allow workflow to continue even if notebook execution fails