Skip to content

Commit c428c58

Browse files
authored
Merge pull request #43 from nipreps/codex/update-book.yml-and-tutorial-markdown-files
ENH: Factor tutorial dataset access into helper
2 parents 35919c9 + c1ea7d1 commit c428c58

File tree

12 files changed

+378
-301
lines changed

12 files changed

+378
-301
lines changed

.github/workflows/book.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,18 @@ jobs:
4747
- name: Install project environment
4848
run: pixi install --locked
4949

50+
- name: Prepare tutorial data
51+
run: |
52+
set -xeuo pipefail
53+
data_dir="${{ github.workspace }}/data"
54+
data_file="$data_dir/dwi_full_brainmask.h5"
55+
mkdir -p "$data_dir"
56+
curl -L \
57+
https://files.osf.io/v1/resources/8k95s/providers/osfstorage/68e5464a451cf9cf1fc51a53 \
58+
--output "$data_file"
59+
test -s "$data_file"
60+
echo "NIPREPS_TUTORIAL_DATA=$data_file" >> "$GITHUB_ENV"
61+
5062
# Build the page
5163
- name: Build the book
5264
run: pixi run build-book

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,5 @@ _build/
1717
.pixi/*
1818
!.pixi/config.toml
1919
report.svg
20+
data/dwi_full_brainmask.h5
21+
__pycache__

docs/notebook/01-intro.ipynb

Lines changed: 7 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"cells": [
33
{
44
"cell_type": "markdown",
5-
"id": "07c0e96c",
5+
"id": "41f638b5",
66
"metadata": {},
77
"source": [
88
"# The problem of head-motion in dMRI"
@@ -11,7 +11,7 @@
1111
{
1212
"cell_type": "code",
1313
"execution_count": null,
14-
"id": "045bf720",
14+
"id": "c48d22ad",
1515
"metadata": {
1616
"tags": [
1717
"remove-cell"
@@ -28,7 +28,7 @@
2828
},
2929
{
3030
"cell_type": "markdown",
31-
"id": "1e062d91",
31+
"id": "0b4fe167",
3232
"metadata": {},
3333
"source": [
3434
"A recurring problem for any MRI acquisition is that image reconstruction and modeling are extremely sensitive to very small changes in the position of the imaged object.\n",
@@ -41,20 +41,20 @@
4141
{
4242
"cell_type": "code",
4343
"execution_count": null,
44-
"id": "53de77d7",
44+
"id": "607ba45b",
4545
"metadata": {
4646
"tags": [
4747
"remove-input"
4848
]
4949
},
5050
"outputs": [],
5151
"source": [
52-
"HTML(\"\"\"<video width=\"640\" height=\"680\" loop=\"yes\" muted=\"yes\" autoplay=\"yes\" controls=\"yes\"><source src=\"../assets/videos/hm-sagittal.mp4\" type=\"video/mp4\"/></video>\"\"\")"
52+
"HTML(\"\"\"<video width=\"640\" height=\"680\" loop=\"yes\" muted=\"yes\" autoplay=\"yes\" controls=\"yes\"><source src=\"../videos/hm-sagittal.mp4\" type=\"video/mp4\"/></video>\"\"\")"
5353
]
5454
},
5555
{
5656
"cell_type": "markdown",
57-
"id": "4e5c553c",
57+
"id": "28cc163f",
5858
"metadata": {},
5959
"source": [
6060
"## Dimensions of the head-motion problem\n",
@@ -145,36 +145,16 @@
145145
"* A reliable registration framework to estimate the misalignment.\n",
146146
"* The integration of the three elements above in an iterable loop."
147147
]
148-
},
149-
{
150-
"cell_type": "code",
151-
"execution_count": null,
152-
"id": "fd4f6138-709b-4368-b1f6-69123edcaf13",
153-
"metadata": {},
154-
"outputs": [],
155-
"source": []
156148
}
157149
],
158150
"metadata": {
159151
"jupytext": {
160-
"default_lexer": "python"
152+
"default_lexer": "ipython3"
161153
},
162154
"kernelspec": {
163155
"display_name": "Python 3 (ipykernel)",
164156
"language": "python",
165157
"name": "python3"
166-
},
167-
"language_info": {
168-
"codemirror_mode": {
169-
"name": "ipython",
170-
"version": 3
171-
},
172-
"file_extension": ".py",
173-
"mimetype": "text/x-python",
174-
"name": "python",
175-
"nbconvert_exporter": "python",
176-
"pygments_lexer": "ipython3",
177-
"version": "3.11.13"
178158
}
179159
},
180160
"nbformat": 4,

docs/notebook/02-data.ipynb

Lines changed: 28 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"cells": [
33
{
44
"cell_type": "markdown",
5-
"id": "fac4dff7",
5+
"id": "a41f16fb",
66
"metadata": {},
77
"source": [
88
"# Introduction to dMRI data"
@@ -11,7 +11,7 @@
1111
{
1212
"cell_type": "code",
1313
"execution_count": null,
14-
"id": "8c58eea3",
14+
"id": "95dc8c25",
1515
"metadata": {
1616
"tags": [
1717
"remove-cell"
@@ -28,7 +28,7 @@
2828
},
2929
{
3030
"cell_type": "markdown",
31-
"id": "6079c59f",
31+
"id": "da052ddd",
3232
"metadata": {},
3333
"source": [
3434
"Diffusion imaging probes the random, microscopic movement of water molecules by using MRI sequences that are sensitive to the geometry and environmental organization surrounding these protons.\n",
@@ -40,20 +40,20 @@
4040
{
4141
"cell_type": "code",
4242
"execution_count": null,
43-
"id": "44fe4b07",
43+
"id": "946abc6d",
4444
"metadata": {
4545
"tags": [
4646
"remove-input"
4747
]
4848
},
4949
"outputs": [],
5050
"source": [
51-
"HTML(\"\"\"<video loop=\"yes\" muted=\"yes\" autoplay=\"yes\" controls=\"yes\"><source src=\"../assets/videos/dMRI-signal-movie.mp4\" type=\"video/mp4\"/></video>\"\"\")"
51+
"HTML(\"\"\"<video loop=\"yes\" muted=\"yes\" autoplay=\"yes\" controls=\"yes\"><source src=\"../videos/dMRI-signal-movie.mp4\" type=\"video/mp4\"/></video>\"\"\")"
5252
]
5353
},
5454
{
5555
"cell_type": "markdown",
56-
"id": "b993d0ac",
56+
"id": "3abc4df2",
5757
"metadata": {},
5858
"source": [
5959
"*Sourced from Dr. A. Rokem, DIPY Workshop 2021*\n",
@@ -86,7 +86,7 @@
8686
{
8787
"cell_type": "code",
8888
"execution_count": null,
89-
"id": "14885d6a",
89+
"id": "c5a0b738",
9090
"metadata": {},
9191
"outputs": [],
9292
"source": [
@@ -124,7 +124,7 @@
124124
},
125125
{
126126
"cell_type": "markdown",
127-
"id": "7581f5f8",
127+
"id": "fe4c7e01",
128128
"metadata": {},
129129
"source": [
130130
"This code implements several *attributes* as well as a *behavior* - the `__len__` *method*.\n",
@@ -136,7 +136,7 @@
136136
{
137137
"cell_type": "code",
138138
"execution_count": null,
139-
"id": "868f5734",
139+
"id": "fb24834b",
140140
"metadata": {},
141141
"outputs": [],
142142
"source": [
@@ -152,7 +152,7 @@
152152
},
153153
{
154154
"cell_type": "markdown",
155-
"id": "84cf1c50",
155+
"id": "17fe71bd",
156156
"metadata": {},
157157
"source": [
158158
"The output of this `print()` statement is telling us that this (simulated) dataset has 64 diffusion-weighted samples.\n",
@@ -169,7 +169,7 @@
169169
{
170170
"cell_type": "code",
171171
"execution_count": null,
172-
"id": "5ebc1a4d",
172+
"id": "e18a2488",
173173
"metadata": {},
174174
"outputs": [],
175175
"source": [
@@ -183,7 +183,7 @@
183183
},
184184
{
185185
"cell_type": "markdown",
186-
"id": "8e5fc8b2",
186+
"id": "ed3a0dc1",
187187
"metadata": {},
188188
"source": [
189189
"In this case, the dataset is reporting to have 102 diffusion-weighted samples.\n",
@@ -195,7 +195,7 @@
195195
{
196196
"cell_type": "code",
197197
"execution_count": null,
198-
"id": "9df1aa93",
198+
"id": "3500222f",
199199
"metadata": {},
200200
"outputs": [],
201201
"source": [
@@ -204,7 +204,7 @@
204204
},
205205
{
206206
"cell_type": "markdown",
207-
"id": "c2dbe2bb",
207+
"id": "c3a27f6a",
208208
"metadata": {},
209209
"source": [
210210
"Perhaps, the most interesting aspect of our DWI data structure is that it allows indexed access.\n",
@@ -214,7 +214,7 @@
214214
{
215215
"cell_type": "code",
216216
"execution_count": null,
217-
"id": "3dc30f25",
217+
"id": "a00aad1e",
218218
"metadata": {},
219219
"outputs": [],
220220
"source": [
@@ -225,7 +225,7 @@
225225
},
226226
{
227227
"cell_type": "markdown",
228-
"id": "56e5c29b",
228+
"id": "3e4631a6",
229229
"metadata": {},
230230
"source": [
231231
"## Visualizing the data\n",
@@ -246,7 +246,7 @@
246246
{
247247
"cell_type": "code",
248248
"execution_count": null,
249-
"id": "d5a8df5e",
249+
"id": "a922378b",
250250
"metadata": {
251251
"tags": [
252252
"hide-cell"
@@ -261,7 +261,7 @@
261261
},
262262
{
263263
"cell_type": "markdown",
264-
"id": "19a93483",
264+
"id": "dce21b10",
265265
"metadata": {},
266266
"source": [
267267
"When calling `plot_dwi()`, we will be required a 3D data object, and optionally, an `affine` orientation matrix and a `gradient` or b-vector.\n",
@@ -281,7 +281,7 @@
281281
{
282282
"cell_type": "code",
283283
"execution_count": null,
284-
"id": "815446a5",
284+
"id": "53318d78",
285285
"metadata": {
286286
"tags": [
287287
"hide-cell"
@@ -296,7 +296,7 @@
296296
{
297297
"cell_type": "code",
298298
"execution_count": null,
299-
"id": "2afc9c73",
299+
"id": "e998629a",
300300
"metadata": {
301301
"tags": [
302302
"hide-cell"
@@ -310,7 +310,7 @@
310310
},
311311
{
312312
"cell_type": "markdown",
313-
"id": "7253e78e",
313+
"id": "3c737783",
314314
"metadata": {},
315315
"source": [
316316
"Diffusion that exhibits directionality in the same direction as the gradient results in a loss of signal.\n",
@@ -334,7 +334,7 @@
334334
{
335335
"cell_type": "code",
336336
"execution_count": null,
337-
"id": "c76d4f1d",
337+
"id": "7e0105e2",
338338
"metadata": {
339339
"tags": [
340340
"hide-cell"
@@ -347,7 +347,7 @@
347347
},
348348
{
349349
"cell_type": "markdown",
350-
"id": "36be2121",
350+
"id": "1eb0e4f0",
351351
"metadata": {},
352352
"source": [
353353
"We get a $4\\times102$ -- three spatial coordinates ($b_x$, $b_y$, $b_z$) of the unit-norm \"*b-vector*\", plus the gradient sensitization magnitude (the \"*b-value*\"), with a total of 102 different orientations for the case at hand.\n",
@@ -363,7 +363,7 @@
363363
{
364364
"cell_type": "code",
365365
"execution_count": null,
366-
"id": "c6c5dcca",
366+
"id": "997899de",
367367
"metadata": {
368368
"tags": [
369369
"hide-cell"
@@ -376,7 +376,7 @@
376376
},
377377
{
378378
"cell_type": "markdown",
379-
"id": "4f22f9f9",
379+
"id": "3a7d6697",
380380
"metadata": {},
381381
"source": [
382382
"Later, we'll refer to this array as the gradient table.\n",
@@ -395,7 +395,7 @@
395395
{
396396
"cell_type": "code",
397397
"execution_count": null,
398-
"id": "bb4cae0d",
398+
"id": "0caf42c7",
399399
"metadata": {},
400400
"outputs": [],
401401
"source": [
@@ -406,7 +406,7 @@
406406
},
407407
{
408408
"cell_type": "markdown",
409-
"id": "b48d1407",
409+
"id": "c682e45b",
410410
"metadata": {},
411411
"source": [
412412
"We've projected all of the gradient directions onto the surface of a sphere, with each unique gradient strength colour-coded.\n",
@@ -423,21 +423,9 @@
423423
"default_lexer": "python"
424424
},
425425
"kernelspec": {
426-
"display_name": "Python 3 (ipykernel)",
426+
"display_name": "Python 3",
427427
"language": "python",
428428
"name": "python3"
429-
},
430-
"language_info": {
431-
"codemirror_mode": {
432-
"name": "ipython",
433-
"version": 3
434-
},
435-
"file_extension": ".py",
436-
"mimetype": "text/x-python",
437-
"name": "python",
438-
"nbconvert_exporter": "python",
439-
"pygments_lexer": "ipython3",
440-
"version": "3.11.13"
441429
}
442430
},
443431
"nbformat": 4,

0 commit comments

Comments
 (0)