Skip to content

Commit cca464f

Browse files
committed
TST: Run fMRI notebook on push and print output
1 parent deeedb4 commit cca464f

File tree

3 files changed

+530
-1
lines changed

3 files changed

+530
-1
lines changed

.github/workflows/notebooks.yml

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
11
name: Run notebooks
22

33
on:
4+
push:
5+
branches:
6+
- main
7+
- maint/*
8+
pull_request:
9+
branches:
10+
- main
11+
- maint/*
412
schedule:
513
- cron: '0 0 * * 1' # Every Monday at 00:00 UTC
614
# Allow job to be triggered manually from GitHub interface
@@ -99,5 +107,17 @@ jobs:
99107
run: |
100108
${{ github.workspace }}/scripts/fetch_fmri_nb_openneuro_data.sh "${TEST_DATA_HOME}"
101109
110+
- name: Install notebook env dependencies from tox
111+
run: |
112+
tox run -e notebooks --notest
113+
102114
- name: Run notebooks with tox
103-
run: tox -e notebooks
115+
# run: tox -e notebooks
116+
run: |
117+
pip install nbconvert jupyter
118+
pip install nbval
119+
# jupyter nbconvert --to notebook --execute ${{ github.workspace }}/docs/notebooks/bold_realignment.ipynb \
120+
# --output executed_bold_realignment.ipynb
121+
# jupyter nbconvert --to python ${{ github.workspace }}/docs/notebooks/bold_realignment.ipnb
122+
python ${{ github.workspace }}/docs/notebooks/bold_realignment.py
123+
# pytest -s --nbval ${{ github.workspace }}/docs/notebooks/bold_realignment.ipynb

docs/notebooks/bold_realignment.ipynb

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,27 @@
8181
" if not DATA_PATH.exists() or not DATA_PATH.is_dir():\n",
8282
" raise FileNotFoundError(f\"Directory does not exist: {DATA_PATH}\")\n",
8383
"\n",
84+
" import hashlib\n",
85+
" model_path = DATA_PATH / \"synthstrip.1.pt\"\n",
86+
" md5_hash = hashlib.md5()\n",
87+
" try:\n",
88+
" with open(model_path, \"rb\") as file:\n",
89+
" # Read the file in chunks to handle large files efficiently\n",
90+
" for chunk in iter(lambda: file.read(4096), b\"\"):\n",
91+
" md5_hash.update(chunk)\n",
92+
" except FileNotFoundError:\n",
93+
" raise FileNotFoundError(f\"File not found.\")\n",
94+
"\n",
95+
" md5_value = md5_hash.hexdigest()\n",
96+
" print(f\"The MD5 hash of {model_path} is: {md5_value}\")\n",
97+
"\n",
8498
" if not bmask_path.exists():\n",
99+
" bmsk_results = SynthStrip(\n",
100+
" in_file=str(avg_path),\n",
101+
" use_gpu=True,\n",
102+
" model=model_path,\n",
103+
" ).run(cwd=str(WORKDIR))\n",
104+
"\n",
85105
" ssiface = SynthStrip(\n",
86106
" in_file=str(avg_path),\n",
87107
" use_gpu=True,\n",

0 commit comments

Comments
 (0)