Skip to content

Commit

Permalink
Add load_project function
Browse files Browse the repository at this point in the history
Use this to load an image and stack of labels programitically.
  • Loading branch information
bnorthan committed Apr 28, 2024
1 parent 26d3850 commit 98a10f0
Showing 1 changed file with 22 additions and 6 deletions.
28 changes: 22 additions & 6 deletions src/napari_segment_everything/segment_everything.py
Original file line number Diff line number Diff line change
Expand Up @@ -388,18 +388,34 @@ def open_project(self):
if file_name:
with open(file_name, "rb") as f:
project = pickle.load(f)
self.results = project["results"]
results = project["results"]
image = project["image"]
self.viewer.add_image(image)
self.image = image
self.load_project(image, results)



def load_project(self, image, results):
self.results = results
self.results = sorted(self.results, key=lambda x: x['area'], reverse=False)
label_num = 1
for result in self.results:
result['keep'] = True
result['label_num'] = label_num
label_num += 1


self.image = image
add_properties_to_label_image(self.image, self.results)
self.viewer.add_image(image)

self._3D_labels_layer.data = make_label_image_3d(self.results)
self.viewer.dims.ndisplay = 3
self._3D_labels_layer.translate = (-len(self.results), 0, 0)

add_properties_to_label_image(self.image, self.results)

self.add_points()
self.add_boxes()
self.update_slider_min_max()

def save_project(self):
options = QFileDialog.Options()
file_name, _ = QFileDialog.getSaveFileName(
Expand Down

0 comments on commit 98a10f0

Please sign in to comment.