Skip to content

Commit

Permalink
fix: šŸ› Fix datasplit._neuroglancer bug that happened with binarizedā€¦
Browse files Browse the repository at this point in the history
ā€¦ arrays.

Also set GT to automatically be a segmentation layer in neuroglancer, for run.visualize_pipeline
  • Loading branch information
rhoadesScholar committed Sep 5, 2024
1 parent bccd778 commit 407dd59
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -438,7 +438,8 @@ def _neuroglancer_source(self):
This method is used to return the source array for neuroglancer.
"""
# return self._source_array._neuroglancer_source()
return np.ones_like(self.source_array.data, dtype=np.uint64) * self._constant
shape = self.source_array[self.source_array.roi].shape[-3:]
return np.ones(shape, dtype=np.uint64) * self._constant

def _combined_neuroglancer_source(self) -> neuroglancer.LocalVolume:
"""
Expand Down
3 changes: 2 additions & 1 deletion dacapo/experiments/run.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
from dacapo.store.create_store import create_array_store
from .datasplits import DataSplit
from .tasks.task import Task
from .architectures import Architecture
Expand Down Expand Up @@ -230,6 +229,8 @@ def visualize_pipeline(self):
"Only GunpowderTrainer is supported for visualization"
)
if not hasattr(self.trainer, "_pipeline"):
from ..store.create_store import create_array_store

array_store = create_array_store()
self.trainer.build_batch_provider(
self.datasplit.train,
Expand Down
7 changes: 6 additions & 1 deletion dacapo/experiments/trainers/gunpowder_trainer.py
Original file line number Diff line number Diff line change
Expand Up @@ -544,7 +544,12 @@ def load_batch(event):
dimensions=dims,
)

s.layers[str(name)] = neuroglancer.ImageLayer(source=local_vol)
if name == self._gt_key:
s.layers[str(name)] = neuroglancer.SegmentationLayer(
source=local_vol
)
else:
s.layers[str(name)] = neuroglancer.ImageLayer(source=local_vol)

s.layout = neuroglancer.row_layout(
[
Expand Down
2 changes: 1 addition & 1 deletion examples/distance_task/synthetic_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@
csv_path,
input_resolution,
output_resolution,
binarize_gt=True,
binarize_gt=True, # Binarize the ground truth data to convert from instance segmentation to semantic segmentation
).compute()

datasplit = datasplit_config.datasplit_type(datasplit_config)
Expand Down

0 comments on commit 407dd59

Please sign in to comment.