Skip to content

Commit 1c505eb

Browse files
committed
Add transform_into_voxels_from method for volumes
1 parent c8a976b commit 1c505eb

6 files changed

Lines changed: 263 additions & 79 deletions

File tree

examples/cells.ipynb

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@
1616
"id": "59e8a2c3",
1717
"metadata": {
1818
"execution": {
19-
"iopub.execute_input": "2025-05-06T13:25:42.755593Z",
20-
"iopub.status.busy": "2025-05-06T13:25:42.755497Z",
21-
"iopub.status.idle": "2025-05-06T13:25:43.162735Z",
22-
"shell.execute_reply": "2025-05-06T13:25:43.162187Z"
19+
"iopub.execute_input": "2025-05-06T14:59:56.209508Z",
20+
"iopub.status.busy": "2025-05-06T14:59:56.209311Z",
21+
"iopub.status.idle": "2025-05-06T14:59:56.625154Z",
22+
"shell.execute_reply": "2025-05-06T14:59:56.624760Z"
2323
},
2424
"vscode": {
2525
"languageId": "plaintext"
@@ -45,10 +45,10 @@
4545
"id": "97c2c4ed",
4646
"metadata": {
4747
"execution": {
48-
"iopub.execute_input": "2025-05-06T13:25:43.164616Z",
49-
"iopub.status.busy": "2025-05-06T13:25:43.164445Z",
50-
"iopub.status.idle": "2025-05-06T13:25:43.232323Z",
51-
"shell.execute_reply": "2025-05-06T13:25:43.231915Z"
48+
"iopub.execute_input": "2025-05-06T14:59:56.626623Z",
49+
"iopub.status.busy": "2025-05-06T14:59:56.626306Z",
50+
"iopub.status.idle": "2025-05-06T14:59:56.695333Z",
51+
"shell.execute_reply": "2025-05-06T14:59:56.695009Z"
5252
},
5353
"vscode": {
5454
"languageId": "plaintext"
@@ -90,10 +90,10 @@
9090
"id": "ed16156a",
9191
"metadata": {
9292
"execution": {
93-
"iopub.execute_input": "2025-05-06T13:25:43.234698Z",
94-
"iopub.status.busy": "2025-05-06T13:25:43.234532Z",
95-
"iopub.status.idle": "2025-05-06T13:25:44.108694Z",
96-
"shell.execute_reply": "2025-05-06T13:25:44.108349Z"
93+
"iopub.execute_input": "2025-05-06T14:59:56.696789Z",
94+
"iopub.status.busy": "2025-05-06T14:59:56.696539Z",
95+
"iopub.status.idle": "2025-05-06T14:59:57.564895Z",
96+
"shell.execute_reply": "2025-05-06T14:59:57.564352Z"
9797
},
9898
"vscode": {
9999
"languageId": "plaintext"
@@ -158,10 +158,10 @@
158158
"id": "d35452de",
159159
"metadata": {
160160
"execution": {
161-
"iopub.execute_input": "2025-05-06T13:25:44.110313Z",
162-
"iopub.status.busy": "2025-05-06T13:25:44.110207Z",
163-
"iopub.status.idle": "2025-05-06T13:25:44.530292Z",
164-
"shell.execute_reply": "2025-05-06T13:25:44.529809Z"
161+
"iopub.execute_input": "2025-05-06T14:59:57.566533Z",
162+
"iopub.status.busy": "2025-05-06T14:59:57.566426Z",
163+
"iopub.status.idle": "2025-05-06T14:59:58.006683Z",
164+
"shell.execute_reply": "2025-05-06T14:59:58.006196Z"
165165
},
166166
"vscode": {
167167
"languageId": "plaintext"
@@ -210,10 +210,10 @@
210210
"id": "c33d38bc",
211211
"metadata": {
212212
"execution": {
213-
"iopub.execute_input": "2025-05-06T13:25:44.534134Z",
214-
"iopub.status.busy": "2025-05-06T13:25:44.533946Z",
215-
"iopub.status.idle": "2025-05-06T13:25:44.541354Z",
216-
"shell.execute_reply": "2025-05-06T13:25:44.540932Z"
213+
"iopub.execute_input": "2025-05-06T14:59:58.010047Z",
214+
"iopub.status.busy": "2025-05-06T14:59:58.009937Z",
215+
"iopub.status.idle": "2025-05-06T14:59:58.015272Z",
216+
"shell.execute_reply": "2025-05-06T14:59:58.014845Z"
217217
},
218218
"vscode": {
219219
"languageId": "plaintext"
@@ -240,10 +240,10 @@
240240
"id": "ea6ed2dd",
241241
"metadata": {
242242
"execution": {
243-
"iopub.execute_input": "2025-05-06T13:25:44.543235Z",
244-
"iopub.status.busy": "2025-05-06T13:25:44.542890Z",
245-
"iopub.status.idle": "2025-05-06T13:25:45.003713Z",
246-
"shell.execute_reply": "2025-05-06T13:25:45.003363Z"
243+
"iopub.execute_input": "2025-05-06T14:59:58.016793Z",
244+
"iopub.status.busy": "2025-05-06T14:59:58.016657Z",
245+
"iopub.status.idle": "2025-05-06T14:59:58.480172Z",
246+
"shell.execute_reply": "2025-05-06T14:59:58.479669Z"
247247
},
248248
"vscode": {
249249
"languageId": "plaintext"
@@ -304,10 +304,10 @@
304304
"id": "b00a9d85",
305305
"metadata": {
306306
"execution": {
307-
"iopub.execute_input": "2025-05-06T13:25:45.006581Z",
308-
"iopub.status.busy": "2025-05-06T13:25:45.006349Z",
309-
"iopub.status.idle": "2025-05-06T13:25:45.567233Z",
310-
"shell.execute_reply": "2025-05-06T13:25:45.566889Z"
307+
"iopub.execute_input": "2025-05-06T14:59:58.482620Z",
308+
"iopub.status.busy": "2025-05-06T14:59:58.482298Z",
309+
"iopub.status.idle": "2025-05-06T14:59:59.040292Z",
310+
"shell.execute_reply": "2025-05-06T14:59:59.039830Z"
311311
},
312312
"vscode": {
313313
"languageId": "plaintext"

examples/cthead.ipynb

Lines changed: 90 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@
1616
"id": "94b5ef80",
1717
"metadata": {
1818
"execution": {
19-
"iopub.execute_input": "2025-05-06T13:25:47.189228Z",
20-
"iopub.status.busy": "2025-05-06T13:25:47.189129Z",
21-
"iopub.status.idle": "2025-05-06T13:25:47.602866Z",
22-
"shell.execute_reply": "2025-05-06T13:25:47.602362Z"
19+
"iopub.execute_input": "2025-05-06T15:00:00.606116Z",
20+
"iopub.status.busy": "2025-05-06T15:00:00.605715Z",
21+
"iopub.status.idle": "2025-05-06T15:00:01.032329Z",
22+
"shell.execute_reply": "2025-05-06T15:00:01.031919Z"
2323
},
2424
"vscode": {
2525
"languageId": "plaintext"
@@ -51,10 +51,10 @@
5151
"id": "1ee080d3",
5252
"metadata": {
5353
"execution": {
54-
"iopub.execute_input": "2025-05-06T13:25:47.604220Z",
55-
"iopub.status.busy": "2025-05-06T13:25:47.604051Z",
56-
"iopub.status.idle": "2025-05-06T13:25:47.730606Z",
57-
"shell.execute_reply": "2025-05-06T13:25:47.730148Z"
54+
"iopub.execute_input": "2025-05-06T15:00:01.033832Z",
55+
"iopub.status.busy": "2025-05-06T15:00:01.033665Z",
56+
"iopub.status.idle": "2025-05-06T15:00:01.159986Z",
57+
"shell.execute_reply": "2025-05-06T15:00:01.159598Z"
5858
},
5959
"vscode": {
6060
"languageId": "plaintext"
@@ -112,10 +112,10 @@
112112
"id": "7af5a922",
113113
"metadata": {
114114
"execution": {
115-
"iopub.execute_input": "2025-05-06T13:25:47.731665Z",
116-
"iopub.status.busy": "2025-05-06T13:25:47.731561Z",
117-
"iopub.status.idle": "2025-05-06T13:25:48.684375Z",
118-
"shell.execute_reply": "2025-05-06T13:25:48.683911Z"
115+
"iopub.execute_input": "2025-05-06T15:00:01.161687Z",
116+
"iopub.status.busy": "2025-05-06T15:00:01.161575Z",
117+
"iopub.status.idle": "2025-05-06T15:00:02.113539Z",
118+
"shell.execute_reply": "2025-05-06T15:00:02.113208Z"
119119
},
120120
"vscode": {
121121
"languageId": "plaintext"
@@ -145,7 +145,7 @@
145145
"\n",
146146
"# Create and configure scene\n",
147147
"root = libcarna.node()\n",
148-
"libcarna.volume(\n",
148+
"volume = libcarna.volume(\n",
149149
" GEOMETRY_TYPE_VOLUME,\n",
150150
" data / data.max(),\n",
151151
" parent=root,\n",
@@ -180,10 +180,10 @@
180180
"id": "493f1153",
181181
"metadata": {
182182
"execution": {
183-
"iopub.execute_input": "2025-05-06T13:25:48.685887Z",
184-
"iopub.status.busy": "2025-05-06T13:25:48.685780Z",
185-
"iopub.status.idle": "2025-05-06T13:25:49.177131Z",
186-
"shell.execute_reply": "2025-05-06T13:25:49.176690Z"
183+
"iopub.execute_input": "2025-05-06T15:00:02.114668Z",
184+
"iopub.status.busy": "2025-05-06T15:00:02.114562Z",
185+
"iopub.status.idle": "2025-05-06T15:00:02.593785Z",
186+
"shell.execute_reply": "2025-05-06T15:00:02.593320Z"
187187
},
188188
"vscode": {
189189
"languageId": "plaintext"
@@ -234,10 +234,10 @@
234234
"id": "6e7f236c",
235235
"metadata": {
236236
"execution": {
237-
"iopub.execute_input": "2025-05-06T13:25:49.179468Z",
238-
"iopub.status.busy": "2025-05-06T13:25:49.179339Z",
239-
"iopub.status.idle": "2025-05-06T13:25:50.011254Z",
240-
"shell.execute_reply": "2025-05-06T13:25:50.010793Z"
237+
"iopub.execute_input": "2025-05-06T15:00:02.595470Z",
238+
"iopub.status.busy": "2025-05-06T15:00:02.595160Z",
239+
"iopub.status.idle": "2025-05-06T15:00:03.424846Z",
240+
"shell.execute_reply": "2025-05-06T15:00:03.424373Z"
241241
},
242242
"vscode": {
243243
"languageId": "plaintext"
@@ -297,10 +297,10 @@
297297
"id": "696c040a",
298298
"metadata": {
299299
"execution": {
300-
"iopub.execute_input": "2025-05-06T13:25:50.012839Z",
301-
"iopub.status.busy": "2025-05-06T13:25:50.012725Z",
302-
"iopub.status.idle": "2025-05-06T13:25:50.855577Z",
303-
"shell.execute_reply": "2025-05-06T13:25:50.855025Z"
300+
"iopub.execute_input": "2025-05-06T15:00:03.426239Z",
301+
"iopub.status.busy": "2025-05-06T15:00:03.425947Z",
302+
"iopub.status.idle": "2025-05-06T15:00:04.248022Z",
303+
"shell.execute_reply": "2025-05-06T15:00:04.247639Z"
304304
},
305305
"vscode": {
306306
"languageId": "plaintext"
@@ -328,7 +328,7 @@
328328
"ball = libcarna.mesh_factory.create_ball(10)\n",
329329
"\n",
330330
"# Add a marker for bone (red)\n",
331-
"libcarna.geometry(\n",
331+
"marker_bone = libcarna.geometry(\n",
332332
" GEOMETRY_TYPE_OPAQUE,\n",
333333
" parent=root,\n",
334334
" local_transform=libcarna.translate(-43, 20, 0),\n",
@@ -340,7 +340,7 @@
340340
")\n",
341341
"\n",
342342
"# Add a marker for air (green)\n",
343-
"libcarna.geometry(\n",
343+
"marker_air = libcarna.geometry(\n",
344344
" GEOMETRY_TYPE_OPAQUE,\n",
345345
" parent=root,\n",
346346
" local_transform=libcarna.translate(-80, 0, 0),\n",
@@ -373,7 +373,69 @@
373373
"Note that we use `dvr.replicate()` when adding the previously defined DVR to the renderer. This is because each\n",
374374
"rendering stage can only be added to one renderer, hence, we replicate it this time. Of course, we could have used the\n",
375375
"`dvr.replicate()` method the first time that we added the DVR to a renderer, too, but this is not mandatory. All\n",
376-
"rendering stages provide such a method."
376+
"rendering stages provide such a method.\n",
377+
"\n",
378+
"Next, we compute the voxel coordinates of the markers:"
379+
]
380+
},
381+
{
382+
"cell_type": "code",
383+
"execution_count": 7,
384+
"id": "30104594",
385+
"metadata": {
386+
"execution": {
387+
"iopub.execute_input": "2025-05-06T15:00:04.249930Z",
388+
"iopub.status.busy": "2025-05-06T15:00:04.249817Z",
389+
"iopub.status.idle": "2025-05-06T15:00:04.252365Z",
390+
"shell.execute_reply": "2025-05-06T15:00:04.252013Z"
391+
},
392+
"vscode": {
393+
"languageId": "plaintext"
394+
}
395+
},
396+
"outputs": [],
397+
"source": [
398+
"p_bone = volume.transform_into_voxels_from(marker_bone).intpoint()\n",
399+
"p_air = volume.transform_into_voxels_from(marker_air ).intpoint()"
400+
]
401+
},
402+
{
403+
"cell_type": "markdown",
404+
"id": "5449dd14",
405+
"metadata": {},
406+
"source": [
407+
"Now we can directy read out the image intensities of the markers:"
408+
]
409+
},
410+
{
411+
"cell_type": "code",
412+
"execution_count": 8,
413+
"id": "2556561b",
414+
"metadata": {
415+
"execution": {
416+
"iopub.execute_input": "2025-05-06T15:00:04.253626Z",
417+
"iopub.status.busy": "2025-05-06T15:00:04.253528Z",
418+
"iopub.status.idle": "2025-05-06T15:00:04.256229Z",
419+
"shell.execute_reply": "2025-05-06T15:00:04.255908Z"
420+
},
421+
"vscode": {
422+
"languageId": "plaintext"
423+
}
424+
},
425+
"outputs": [
426+
{
427+
"data": {
428+
"text/plain": [
429+
"(2105, 53)"
430+
]
431+
},
432+
"execution_count": 8,
433+
"metadata": {},
434+
"output_type": "execute_result"
435+
}
436+
],
437+
"source": [
438+
"data[p_bone], data[p_air]"
377439
]
378440
}
379441
],

0 commit comments

Comments
 (0)