Skip to content

Commit c8507bc

Browse files
committed
Update tutorials
1 parent 8da9452 commit c8507bc

File tree

9 files changed

+143
-80
lines changed

9 files changed

+143
-80
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ plt.show()
7272

7373
On a single NVIDIA RTX 2080 Ti GPU, producing such an image takes
7474

75-
33.3 ms ± 6.78 µs per loop (mean ± std. dev. of 7 runs, 10 loops each)
75+
33.6 ms ± 27.8 µs per loop (mean ± std. dev. of 7 runs, 10 loops each)
7676

7777
The full example is available at
7878
[`introduction.ipynb`](https://vivekg.dev/DiffDRR/tutorials/introduction.html).

notebooks/index.ipynb

Lines changed: 3 additions & 3 deletions
Large diffs are not rendered by default.

notebooks/tutorials/introduction.ipynb

Lines changed: 71 additions & 20 deletions
Large diffs are not rendered by default.

notebooks/tutorials/metrics.ipynb

Lines changed: 5 additions & 5 deletions
Large diffs are not rendered by default.

notebooks/tutorials/optimizers.ipynb

Lines changed: 17 additions & 17 deletions
Large diffs are not rendered by default.

notebooks/tutorials/render.html

Lines changed: 2 additions & 2 deletions
Large diffs are not rendered by default.

notebooks/tutorials/spherical.ipynb

Lines changed: 14 additions & 10 deletions
Large diffs are not rendered by default.

notebooks/tutorials/timing.ipynb

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@
6666
"name": "stdout",
6767
"output_type": "stream",
6868
"text": [
69-
"9.28 ms ± 375 µs per loop (mean ± std. dev. of 7 runs, 1 loop each)\n"
69+
"9.3 ms ± 1.31 ms per loop (mean ± std. dev. of 7 runs, 1 loop each)\n"
7070
]
7171
}
7272
],
@@ -75,7 +75,7 @@
7575
"height = 100\n",
7676
"\n",
7777
"drr = DRR(volume, spacing, sdr=300.0, height=height, delx=4.0).to(device)\n",
78-
"%timeit drr(rotations, translations, \"euler_angles\", \"ZYX\")\n",
78+
"%timeit drr(rotations, translations, parameterization=\"euler_angles\", convention=\"ZYX\")\n",
7979
"del drr"
8080
]
8181
},
@@ -89,16 +89,16 @@
8989
"name": "stdout",
9090
"output_type": "stream",
9191
"text": [
92-
"33.3 ms ± 14.3 µs per loop (mean ± std. dev. of 7 runs, 10 loops each)\n"
92+
"34.9 ms ± 326 µs per loop (mean ± std. dev. of 7 runs, 1 loop each)\n"
9393
]
9494
}
9595
],
9696
"source": [
97-
"#|cuda\n",
97+
"# |cuda\n",
9898
"height = 200\n",
9999
"\n",
100100
"drr = DRR(volume, spacing, sdr=300.0, height=height, delx=4.0).to(device)\n",
101-
"%timeit drr(rotations, translations, \"euler_angles\", \"ZYX\")\n",
101+
"%timeit drr(rotations, translations, parameterization=\"euler_angles\", convention=\"ZYX\")\n",
102102
"del drr"
103103
]
104104
},
@@ -112,7 +112,7 @@
112112
"name": "stdout",
113113
"output_type": "stream",
114114
"text": [
115-
"72.1 ms ± 30.2 µs per loop (mean ± std. dev. of 7 runs, 10 loops each)\n"
115+
"72.3 ms ± 158 µs per loop (mean ± std. dev. of 7 runs, 1 loop each)\n"
116116
]
117117
}
118118
],
@@ -121,7 +121,7 @@
121121
"height = 300\n",
122122
"\n",
123123
"drr = DRR(volume, spacing, sdr=300.0, height=height, delx=4.0).to(device)\n",
124-
"%timeit drr(rotations, translations, \"euler_angles\", \"ZYX\")\n",
124+
"%timeit drr(rotations, translations, parameterization=\"euler_angles\", convention=\"ZYX\")\n",
125125
"del drr"
126126
]
127127
},
@@ -135,7 +135,7 @@
135135
"name": "stdout",
136136
"output_type": "stream",
137137
"text": [
138-
"123 ms ± 35.1 µs per loop (mean ± std. dev. of 7 runs, 10 loops each)\n"
138+
"123 ms ± 434 µs per loop (mean ± std. dev. of 7 runs, 1 loop each)\n"
139139
]
140140
}
141141
],
@@ -144,7 +144,7 @@
144144
"height = 400\n",
145145
"\n",
146146
"drr = DRR(volume, spacing, sdr=300.0, height=height, delx=4.0).to(device)\n",
147-
"%timeit drr(rotations, translations, \"euler_angles\", \"ZYX\")\n",
147+
"%timeit drr(rotations, translations, parameterization=\"euler_angles\", convention=\"ZYX\")\n",
148148
"del drr"
149149
]
150150
},
@@ -158,7 +158,7 @@
158158
"name": "stdout",
159159
"output_type": "stream",
160160
"text": [
161-
"187 ms ± 96.1 µs per loop (mean ± std. dev. of 7 runs, 10 loops each)\n"
161+
"185 ms ± 666 µs per loop (mean ± std. dev. of 7 runs, 1 loop each)\n"
162162
]
163163
}
164164
],
@@ -167,7 +167,7 @@
167167
"height = 500\n",
168168
"\n",
169169
"drr = DRR(volume, spacing, sdr=300.0, height=height, delx=4.0).to(device)\n",
170-
"%timeit drr(rotations, translations, \"euler_angles\", \"ZYX\")\n",
170+
"%timeit drr(rotations, translations, parameterization=\"euler_angles\", convention=\"ZYX\")\n",
171171
"del drr"
172172
]
173173
},
@@ -201,7 +201,7 @@
201201
"name": "stdout",
202202
"output_type": "stream",
203203
"text": [
204-
"183 ms ± 214 µs per loop (mean ± std. dev. of 7 runs, 10 loops each)\n"
204+
"186 ms ± 1.23 ms per loop (mean ± std. dev. of 7 runs, 1 loop each)\n"
205205
]
206206
}
207207
],
@@ -213,7 +213,7 @@
213213
"drr = DRR(\n",
214214
" volume, spacing, sdr=300.0, height=height, delx=4.0, patch_size=patch_size\n",
215215
").to(device)\n",
216-
"%timeit drr(rotations, translations, \"euler_angles\", \"ZYX\")\n",
216+
"%timeit drr(rotations, translations, parameterization=\"euler_angles\", convention=\"ZYX\")\n",
217217
"del drr"
218218
]
219219
},
@@ -227,7 +227,7 @@
227227
"name": "stdout",
228228
"output_type": "stream",
229229
"text": [
230-
"259 ms ± 92.7 µs per loop (mean ± std. dev. of 7 runs, 1 loop each)\n"
230+
"262 ms ± 250 µs per loop (mean ± std. dev. of 7 runs, 1 loop each)\n"
231231
]
232232
}
233233
],
@@ -239,7 +239,7 @@
239239
"drr = DRR(\n",
240240
" volume, spacing, sdr=300.0, height=height, delx=4.0, patch_size=patch_size\n",
241241
").to(device)\n",
242-
"%timeit drr(rotations, translations, \"euler_angles\", \"ZYX\")\n",
242+
"%timeit drr(rotations, translations, parameterization=\"euler_angles\", convention=\"ZYX\")\n",
243243
"del drr"
244244
]
245245
},
@@ -253,7 +253,7 @@
253253
"name": "stdout",
254254
"output_type": "stream",
255255
"text": [
256-
"417 ms ± 234 µs per loop (mean ± std. dev. of 7 runs, 1 loop each)\n"
256+
"418 ms ± 1.64 ms per loop (mean ± std. dev. of 7 runs, 1 loop each)\n"
257257
]
258258
}
259259
],
@@ -265,7 +265,7 @@
265265
"drr = DRR(\n",
266266
" volume, spacing, sdr=300.0, height=height, delx=4.0, patch_size=patch_size\n",
267267
").to(device)\n",
268-
"%timeit drr(rotations, translations, \"euler_angles\", \"ZYX\")\n",
268+
"%timeit drr(rotations, translations, parameterization=\"euler_angles\", convention=\"ZYX\")\n",
269269
"del drr"
270270
]
271271
},
@@ -279,7 +279,7 @@
279279
"name": "stdout",
280280
"output_type": "stream",
281281
"text": [
282-
"826 ms ± 268 µs per loop (mean ± std. dev. of 7 runs, 1 loop each)\n"
282+
"828 ms ± 2.89 ms per loop (mean ± std. dev. of 7 runs, 1 loop each)\n"
283283
]
284284
}
285285
],
@@ -291,7 +291,7 @@
291291
"drr = DRR(\n",
292292
" volume, spacing, sdr=300.0, height=height, delx=4.0, patch_size=patch_size\n",
293293
").to(device)\n",
294-
"%timeit drr(rotations, translations, \"euler_angles\", \"ZYX\")\n",
294+
"%timeit drr(rotations, translations, parameterization=\"euler_angles\", convention=\"ZYX\")\n",
295295
"del drr"
296296
]
297297
},

notebooks/tutorials/visualization.ipynb

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@
6767
"\n",
6868
"from diffdrr.data import load_example_ct\n",
6969
"from diffdrr.drr import DRR\n",
70+
"from diffdrr.pose import convert\n",
7071
"from diffdrr.visualization import drr_to_mesh, img_to_mesh\n",
7172
"\n",
7273
"device = torch.device(\"cuda\" if torch.cuda.is_available() else \"cpu\")\n",
@@ -94,9 +95,8 @@
9495
"# Make a mesh from the camera and detector plane\n",
9596
"rotations = torch.tensor([[torch.pi, 0.0, torch.pi / 2]], device=device)\n",
9697
"translations = torch.tensor([[bx - focal_len / 3, by, bz]], device=device)\n",
97-
"camera, detector, texture, principal_ray = img_to_mesh(\n",
98-
" drr, rotations, translations, \"euler_angles\", \"ZYX\"\n",
99-
")\n",
98+
"pose = convert(rotations, translations, parameterization=\"euler_angles\", convention=\"ZYX\")\n",
99+
"camera, detector, texture, principal_ray = img_to_mesh(drr, pose)\n",
100100
"\n",
101101
"# Make the plot\n",
102102
"plotter = pyvista.Plotter()\n",
@@ -148,6 +148,14 @@
148148
"\n",
149149
"IFrame(\"render.html\", height=500, width=749)"
150150
]
151+
},
152+
{
153+
"cell_type": "code",
154+
"execution_count": null,
155+
"id": "40851265-af9e-49d0-a9df-2c73f0776eab",
156+
"metadata": {},
157+
"outputs": [],
158+
"source": []
151159
}
152160
],
153161
"metadata": {

0 commit comments

Comments
 (0)