|
1 | 1 | """Instance segmentation methods for 3D images.""" |
| 2 | + |
2 | 3 | import abc |
3 | 4 | from dataclasses import dataclass |
4 | 5 | from functools import partial |
@@ -128,14 +129,14 @@ def record_parameters(self): |
128 | 129 | """Records all the parameters of the instance segmentation method from the current values of the widgets.""" |
129 | 130 | if len(self.sliders) > 0: |
130 | 131 | for slider in self.sliders: |
131 | | - self.recorded_parameters[ |
132 | | - slider.label.text() |
133 | | - ] = slider.slider_value |
| 132 | + self.recorded_parameters[slider.label.text()] = ( |
| 133 | + slider.slider_value |
| 134 | + ) |
134 | 135 | if len(self.counters) > 0: |
135 | 136 | for counter in self.counters: |
136 | | - self.recorded_parameters[ |
137 | | - counter.label.text() |
138 | | - ] = counter.value() |
| 137 | + self.recorded_parameters[counter.label.text()] = ( |
| 138 | + counter.value() |
| 139 | + ) |
139 | 140 |
|
140 | 141 | def run_method_from_params(self, image): |
141 | 142 | """Runs the method on the image with the RECORDED parameters set in the widget. |
@@ -327,10 +328,9 @@ def binary_connected( |
327 | 328 | ) |
328 | 329 | semantic = np.squeeze(volume) |
329 | 330 | foreground = np.where(semantic > thres, volume, 0) # int(255 * thres) |
330 | | - segm = label(foreground) |
331 | | - segm = remove_small_objects(segm, thres_small) |
| 331 | + seg = label(foreground) |
| 332 | + return remove_small_objects(seg, thres_small) |
332 | 333 |
|
333 | | - return segm |
334 | 334 |
|
335 | 335 |
|
336 | 336 | def binary_watershed( |
@@ -551,9 +551,9 @@ def __init__(self, widget_parent=None): |
551 | 551 | ) |
552 | 552 |
|
553 | 553 | self.sliders[0].label.setText("Foreground probability threshold") |
554 | | - self.sliders[ |
555 | | - 0 |
556 | | - ].tooltips = "Probability threshold for foreground object" |
| 554 | + self.sliders[0].tooltips = ( |
| 555 | + "Probability threshold for foreground object" |
| 556 | + ) |
557 | 557 | self.sliders[0].setValue(500) |
558 | 558 |
|
559 | 559 | self.sliders[1].label.setText("Seed probability threshold") |
@@ -652,9 +652,9 @@ def __init__(self, widget_parent=None): |
652 | 652 | ) |
653 | 653 |
|
654 | 654 | self.sliders[0].label.setText("Foreground probability threshold") |
655 | | - self.sliders[ |
656 | | - 0 |
657 | | - ].tooltips = "Probability threshold for foreground object" |
| 655 | + self.sliders[0].tooltips = ( |
| 656 | + "Probability threshold for foreground object" |
| 657 | + ) |
658 | 658 | self.sliders[0].setValue(800) |
659 | 659 |
|
660 | 660 | self.counters[0].label.setText("Small objects removal") |
@@ -715,18 +715,18 @@ def __init__(self, widget_parent=None): |
715 | 715 | widget_parent=widget_parent, |
716 | 716 | ) |
717 | 717 | self.counters[0].label.setText("Spot sigma") # closeness |
718 | | - self.counters[ |
719 | | - 0 |
720 | | - ].tooltips = "Determines how close detected objects can be" |
| 718 | + self.counters[0].tooltips = ( |
| 719 | + "Determines how close detected objects can be" |
| 720 | + ) |
721 | 721 | self.counters[0].setMaximum(100) |
722 | | - self.counters[0].setValue(2) |
| 722 | + self.counters[0].setValue(0.65) |
723 | 723 |
|
724 | 724 | self.counters[1].label.setText("Outline sigma") # smoothness |
725 | | - self.counters[ |
726 | | - 1 |
727 | | - ].tooltips = "Determines the smoothness of the segmentation" |
| 725 | + self.counters[1].tooltips = ( |
| 726 | + "Determines the smoothness of the segmentation" |
| 727 | + ) |
728 | 728 | self.counters[1].setMaximum(100) |
729 | | - self.counters[1].setValue(2) |
| 729 | + self.counters[1].setValue(0.65) |
730 | 730 |
|
731 | 731 | self.counters[2].label.setText("Small object removal") |
732 | 732 | self.counters[2].tooltips = ( |
|
0 commit comments