Skip to content

Commit

Permalink
Fix bug in rasterize graph
Browse files Browse the repository at this point in the history
we were using `graph.data.items()` to iterate over nodes instead of `graph.nodes`

Squashed commit of the following:

commit d027f5a260a1e2a9cf851efca85b7318434675d6
Author: William Patton <wllmpttn24@gmail.com>
Date:   Tue Jan 2 09:44:21 2024 -0800

    refactor rasterize_points test to use pytest

commit eadb0476d8475b55120486df6cf30f95b6df86f4
Author: William Patton <wllmpttn24@gmail.com>
Date:   Tue Jan 2 09:25:11 2024 -0800

    remove extra roi handling

    The node only needs to request the data it needs for its
    own operations.
    If you request a mask for a set of points that extend outside
    the bounds of your mask you will get an error

commit 29507f1f21d69cf76e34e7b0f05cd780100fd68b
Author: William Patton <wllmpttn24@gmail.com>
Date:   Tue Jan 2 09:22:21 2024 -0800

    remove type cast

    we do a bitwise during the `__rasterize` call which
    results fails if you change the dtype

commit 96e93e53ce0bc8240357259dab92f1ca64a08199
Author: William Patton <wllmpttn24@gmail.com>
Date:   Tue Jan 2 09:21:16 2024 -0800

    remove matplotlib

commit eb2977a187a1cad95da54a515c84ce44d73b8315
Author: Samia Mohinta <44754434+Mohinta2892@users.noreply.github.com>
Date:   Thu Dec 14 15:27:41 2023 +0000

    fix mask intersection with request

    outputs must match request rois when a mask is provided

commit 682189dac2ef6b94876bd30df813717da6530060
Author: Samia Mohinta <44754434+Mohinta2892@users.noreply.github.com>
Date:   Thu Dec 14 15:25:12 2023 +0000

    Update rasterize_graph.py

commit e36dcf179ccd1aec6a5cafd31e7a9a858352faa1
Author: Mohinta2892 <samiamohinta2892@gmail.com>
Date:   Thu Nov 2 19:18:00 2023 +0000

    reformat rasterize_graph and rasterize_points

commit 42da2702e746f702d3d07144ab9fc1d4352b0c0d
Author: Samia Mohinta <44754434+Mohinta2892@users.noreply.github.com>
Date:   Thu Nov 2 14:23:01 2023 +0000

    Test for issue #193

    Test added to pass mask to `RasterizeGraph()` via `RasterizationSettings`.

commit b17cfad413f5ad7f48045a2167ec20d89674d939
Author: Samia Mohinta <44754434+Mohinta2892@users.noreply.github.com>
Date:   Thu Nov 2 14:19:42 2023 +0000

    fix for issue #193

    lines 224-226: replace graph.data.items() with graph.nodes
    lines 255-257: explicitly cast the boolean mask data to the original dtype of mask_array
  • Loading branch information
pattonw committed Jan 2, 2024
1 parent 588824f commit d449036
Show file tree
Hide file tree
Showing 2 changed files with 217 additions and 204 deletions.
9 changes: 7 additions & 2 deletions gunpowder/nodes/rasterize_graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,8 @@ def process(self, batch, request):
mask_array = batch.arrays[mask].crop(enlarged_vol_roi)
# get those component labels in the mask, that contain graph
labels = []
for i, point in graph.data.items():
# for i, point in graph.data.items():
for i, point in enumerate(graph.nodes):
v = Coordinate(point.location / voxel_size)
v -= data_roi.begin
labels.append(mask_array.data[v])
Expand Down Expand Up @@ -250,11 +251,15 @@ def process(self, batch, request):
voxel_size,
self.spec[self.array].dtype,
self.settings,
Array(data=mask_array.data == label, spec=mask_array.spec),
Array(
data=(mask_array.data == label),
spec=mask_array.spec,
),
)
for label in labels
],
axis=0,
dtype=self.spec[self.array].dtype,
)

else:
Expand Down
Loading

0 comments on commit d449036

Please sign in to comment.