Skip to content

Commit

Permalink
fix orientation bug
Browse files Browse the repository at this point in the history
  • Loading branch information
arthurmasson committed Jun 28, 2024
1 parent 1794b6d commit 18cdb34
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions src/napari_exodeepfinder/_segmentation_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ def __init__(self, napari_viewer: napari.Viewer):
super().__init__()
self.viewer = napari_viewer

self.labelmap = None

self.print_signal.connect(self.on_print_signal)

# Use this event because of bug in viewer.events.layers_change.connect() : it doesn't register name change
Expand Down Expand Up @@ -131,19 +129,20 @@ def launch_process(self):
current_layer_text = self._input_layer_box.currentText()
self.data = self.viewer.layers[current_layer_text].data

# invert axes from z,y,x to x,y,z (weird convention)
data = np.transpose(self.data, (2, 1, 0))

# Initialize segmentation:
seg = Segment(Ncl=Ncl, path_weights=path_weights, patch_size=psize)
seg.set_observer(core.observer_gui(self.print_signal))

# Segment data:
scoremaps = seg.launch(self.data)
scoremaps = seg.launch(data)

seg.display('Saving labelmap ...')
seg.display('Saving labelmap...')
# Get labelmap from scoremaps and save:
labelmap_not_converted = sm.to_labelmap(scoremaps)
# invert axes from z,y,x to x,y,z (weird convention)
self.labelmap = np.transpose(labelmap_not_converted, (2, 1, 0))
cm.write_array(self.labelmap, path_lmap)
labelmap = sm.to_labelmap(scoremaps)
cm.write_array(labelmap, path_lmap)

# Get binned labelmap and save:
if self.bin_label_map.isChecked():
Expand All @@ -154,8 +153,8 @@ def launch_process(self):
labelmapB = np.transpose(labelmapB_not_converted, (2, 1, 0))
cm.write_array(labelmapB, s[0] + '_binned' + s[1])

seg.display('Finished !')
return labelmap_not_converted
seg.display('Finished!')
return np.transpose(labelmap, (2, 1, 0))

def add_labels(self, labelmap):
self.viewer.add_labels(labelmap)
Expand Down

0 comments on commit 18cdb34

Please sign in to comment.