Skip to content

Commit c9284c6

Browse files
committed
Fix bugs, add segmentation example
1 parent 1f64e45 commit c9284c6

10 files changed

Lines changed: 265 additions & 161 deletions

examples/cells.ipynb

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

examples/cthead.ipynb

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

examples/introduction.ipynb

Lines changed: 34 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@
1414
"id": "3bf7058d",
1515
"metadata": {
1616
"execution": {
17-
"iopub.execute_input": "2025-05-09T09:12:49.023933Z",
18-
"iopub.status.busy": "2025-05-09T09:12:49.023707Z",
19-
"iopub.status.idle": "2025-05-09T09:12:49.585847Z",
20-
"shell.execute_reply": "2025-05-09T09:12:49.585428Z"
17+
"iopub.execute_input": "2025-05-09T15:53:15.629826Z",
18+
"iopub.status.busy": "2025-05-09T15:53:15.629624Z",
19+
"iopub.status.idle": "2025-05-09T15:53:16.193332Z",
20+
"shell.execute_reply": "2025-05-09T15:53:16.192906Z"
2121
},
2222
"vscode": {
2323
"languageId": "plaintext"
@@ -52,10 +52,10 @@
5252
"id": "cd38b675",
5353
"metadata": {
5454
"execution": {
55-
"iopub.execute_input": "2025-05-09T09:12:49.587247Z",
56-
"iopub.status.busy": "2025-05-09T09:12:49.587030Z",
57-
"iopub.status.idle": "2025-05-09T09:12:49.589118Z",
58-
"shell.execute_reply": "2025-05-09T09:12:49.588780Z"
55+
"iopub.execute_input": "2025-05-09T15:53:16.194832Z",
56+
"iopub.status.busy": "2025-05-09T15:53:16.194658Z",
57+
"iopub.status.idle": "2025-05-09T15:53:16.196728Z",
58+
"shell.execute_reply": "2025-05-09T15:53:16.196424Z"
5959
},
6060
"vscode": {
6161
"languageId": "plaintext"
@@ -84,10 +84,10 @@
8484
"id": "8518d1b2",
8585
"metadata": {
8686
"execution": {
87-
"iopub.execute_input": "2025-05-09T09:12:49.590271Z",
88-
"iopub.status.busy": "2025-05-09T09:12:49.590024Z",
89-
"iopub.status.idle": "2025-05-09T09:12:49.592062Z",
90-
"shell.execute_reply": "2025-05-09T09:12:49.591725Z"
87+
"iopub.execute_input": "2025-05-09T15:53:16.198185Z",
88+
"iopub.status.busy": "2025-05-09T15:53:16.198082Z",
89+
"iopub.status.idle": "2025-05-09T15:53:16.200110Z",
90+
"shell.execute_reply": "2025-05-09T15:53:16.199808Z"
9191
},
9292
"vscode": {
9393
"languageId": "plaintext"
@@ -120,10 +120,10 @@
120120
"id": "df9403bf",
121121
"metadata": {
122122
"execution": {
123-
"iopub.execute_input": "2025-05-09T09:12:49.593234Z",
124-
"iopub.status.busy": "2025-05-09T09:12:49.592987Z",
125-
"iopub.status.idle": "2025-05-09T09:12:49.597666Z",
126-
"shell.execute_reply": "2025-05-09T09:12:49.597336Z"
123+
"iopub.execute_input": "2025-05-09T15:53:16.201610Z",
124+
"iopub.status.busy": "2025-05-09T15:53:16.201420Z",
125+
"iopub.status.idle": "2025-05-09T15:53:16.205859Z",
126+
"shell.execute_reply": "2025-05-09T15:53:16.205516Z"
127127
},
128128
"vscode": {
129129
"languageId": "plaintext"
@@ -133,7 +133,7 @@
133133
{
134134
"data": {
135135
"text/plain": [
136-
"<libcarna._spatial.geometry.<locals>.Geometry at 0x704a26a4aab0>"
136+
"<libcarna._spatial.geometry.<locals>.Geometry at 0x773c0acaebd0>"
137137
]
138138
},
139139
"execution_count": 4,
@@ -186,10 +186,10 @@
186186
"id": "4a1a1c31",
187187
"metadata": {
188188
"execution": {
189-
"iopub.execute_input": "2025-05-09T09:12:49.598829Z",
190-
"iopub.status.busy": "2025-05-09T09:12:49.598572Z",
191-
"iopub.status.idle": "2025-05-09T09:12:49.600643Z",
192-
"shell.execute_reply": "2025-05-09T09:12:49.600311Z"
189+
"iopub.execute_input": "2025-05-09T15:53:16.207368Z",
190+
"iopub.status.busy": "2025-05-09T15:53:16.207160Z",
191+
"iopub.status.idle": "2025-05-09T15:53:16.209166Z",
192+
"shell.execute_reply": "2025-05-09T15:53:16.208827Z"
193193
},
194194
"vscode": {
195195
"languageId": "plaintext"
@@ -225,10 +225,10 @@
225225
"id": "0ca491a8",
226226
"metadata": {
227227
"execution": {
228-
"iopub.execute_input": "2025-05-09T09:12:49.601752Z",
229-
"iopub.status.busy": "2025-05-09T09:12:49.601552Z",
230-
"iopub.status.idle": "2025-05-09T09:12:49.679674Z",
231-
"shell.execute_reply": "2025-05-09T09:12:49.679091Z"
228+
"iopub.execute_input": "2025-05-09T15:53:16.210634Z",
229+
"iopub.status.busy": "2025-05-09T15:53:16.210433Z",
230+
"iopub.status.idle": "2025-05-09T15:53:16.298052Z",
231+
"shell.execute_reply": "2025-05-09T15:53:16.297617Z"
232232
},
233233
"vscode": {
234234
"languageId": "plaintext"
@@ -257,10 +257,10 @@
257257
"id": "37ff9c22",
258258
"metadata": {
259259
"execution": {
260-
"iopub.execute_input": "2025-05-09T09:12:49.681256Z",
261-
"iopub.status.busy": "2025-05-09T09:12:49.681146Z",
262-
"iopub.status.idle": "2025-05-09T09:12:49.776487Z",
263-
"shell.execute_reply": "2025-05-09T09:12:49.775955Z"
260+
"iopub.execute_input": "2025-05-09T15:53:16.299624Z",
261+
"iopub.status.busy": "2025-05-09T15:53:16.299485Z",
262+
"iopub.status.idle": "2025-05-09T15:53:16.394546Z",
263+
"shell.execute_reply": "2025-05-09T15:53:16.394214Z"
264264
},
265265
"vscode": {
266266
"languageId": "plaintext"
@@ -270,7 +270,7 @@
270270
{
271271
"data": {
272272
"text/plain": [
273-
"<matplotlib.image.AxesImage at 0x704a268ea570>"
273+
"<matplotlib.image.AxesImage at 0x773c0ab534a0>"
274274
]
275275
},
276276
"execution_count": 7,
@@ -311,10 +311,10 @@
311311
"id": "10ab7a0a",
312312
"metadata": {
313313
"execution": {
314-
"iopub.execute_input": "2025-05-09T09:12:49.778128Z",
315-
"iopub.status.busy": "2025-05-09T09:12:49.778007Z",
316-
"iopub.status.idle": "2025-05-09T09:12:49.926269Z",
317-
"shell.execute_reply": "2025-05-09T09:12:49.925715Z"
314+
"iopub.execute_input": "2025-05-09T15:53:16.396152Z",
315+
"iopub.status.busy": "2025-05-09T15:53:16.395998Z",
316+
"iopub.status.idle": "2025-05-09T15:53:16.533510Z",
317+
"shell.execute_reply": "2025-05-09T15:53:16.533160Z"
318318
},
319319
"vscode": {
320320
"languageId": "plaintext"

misc/libcarna/_dvr.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ def __init__(
3939
cmap: str | libcarna.base.ColorMap | None = None,
4040
clim: tuple[float | None, float | None] | None = None,
4141
sr: int = libcarna.presets.VolumeRenderingStage.DEFAULT_SAMPLE_RATE,
42-
transl: float = libcarna.presets.DVRStage.DEFAULT_TRANSLUCENCY,
42+
transl: float = 0,
4343
diffuse: float = libcarna.presets.DVRStage.DEFAULT_DIFFUSE_LIGHT,
4444
):
4545
super().__init__(geometry_type)

misc/libcarna/_mask_renderer.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ class mask_renderer(libcarna.presets.MaskRenderingStage):
77
88
Arguments:
99
geometry_type: Geometry type to be rendered.
10-
mask_role: Mask role to be used.
10+
sr: Sample rate for volume rendering. Larger values result in higher quality and less artifacts, but slower
11+
rendering.
1112
color: Color to use for the mask.
1213
fill: If `True`, the mask is filled. If `False`, only the borders are rendered.
1314
@@ -27,12 +28,13 @@ class mask_renderer(libcarna.presets.MaskRenderingStage):
2728
def __init__(
2829
self,
2930
geometry_type: int,
30-
mask_role: int = libcarna.presets.MaskRenderingStage.DEFAULT_ROLE_MASK,
3131
*,
32+
sr: int = libcarna.presets.VolumeRenderingStage.DEFAULT_SAMPLE_RATE,
3233
color: libcarna.color = libcarna.presets.MaskRenderingStage.DEFAULT_COLOR,
3334
fill: bool = False,
3435
):
35-
super().__init__(geometry_type, mask_role)
36+
super().__init__(geometry_type, mask_role=0)
37+
self.sample_rate = sr
3638
self.color = color
3739
self.filling = fill
3840

@@ -42,7 +44,7 @@ def replicate(self):
4244
"""
4345
return mask_renderer(
4446
self.geometry_type,
45-
self.mask_role,
47+
sr=self.sample_rate,
4648
color=self.color,
4749
fill=self.filling,
4850
)

src/py/presets.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ PYBIND11_MODULE( presets, m )
245245
"mask_role",
246246
VIEW_DELEGATE( MaskRenderingStageView, maskRenderingStage().maskRole )
247247
)
248-
.def_property(
248+
.def_property( // TODO: This shouldn't be a property, see comment above.
249249
"color",
250250
VIEW_DELEGATE( MaskRenderingStageView, maskRenderingStage().color() ),
251251
VIEW_DELEGATE( MaskRenderingStageView, maskRenderingStage().setColor( color ), const LibCarna::base::Color& color )
-51 Bytes
Loading
888 Bytes
Loading

test/test_mask_renderer.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,14 @@ class mask_renderer(testsuite.LibCarnaTestCase):
66

77
def test__replicate(self):
88
GEOMETRY_TYPE_VOLUME = 1
9-
MASK_ROLE = 2
109
mask_renderer1 = libcarna.mask_renderer(
1110
GEOMETRY_TYPE_VOLUME,
12-
MASK_ROLE,
11+
sr=500,
1312
color=libcarna.color.RED,
1413
fill=True,
1514
)
1615
mask_renderer2 = mask_renderer1.replicate()
1716
self.assertEqual(mask_renderer2.geometry_type, GEOMETRY_TYPE_VOLUME)
18-
self.assertEqual(mask_renderer2.mask_role, MASK_ROLE)
17+
self.assertEqual(mask_renderer2.sample_rate, 500)
1918
self.assertEqual(mask_renderer2.color, libcarna.color.RED)
2019
self.assertEqual(mask_renderer2.filling, True)

test/test_spatial.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ def setUp(self):
5151
def test__transform_into_voxels_from(self):
5252
np.testing.assert_array_almost_equal(
5353
self.volume.transform_into_voxels_from(self.root).point(),
54-
(32., 24., 5., 1.),
54+
(32., 24., 5.,),
5555
)
5656

5757
def test__extent(self):

0 commit comments

Comments
 (0)