Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix dependencies #25

Merged
merged 3 commits into from
Nov 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 13 additions & 13 deletions napari_organoid_counter/_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
from napari import layers
from napari.utils.notifications import show_info

from PyQt5.QtCore import Qt
from PyQt5.QtWidgets import *
from qtpy.QtCore import Qt
from qtpy.QtWidgets import QWidget, QVBoxLayout, QApplication, QDialog, QFileDialog, QGroupBox, QHBoxLayout, QLabel, QComboBox, QPushButton, QLineEdit, QProgressBar, QSlider

from napari_organoid_counter._orgacount import OrganoiDL
from napari_organoid_counter._utils import *
from napari_organoid_counter import _utils as utils
from napari_organoid_counter import settings

import warnings
Expand Down Expand Up @@ -72,7 +72,7 @@ def __init__(self,
# models to the model dict
settings.init()
settings.MODELS_DIR.mkdir(parents=True, exist_ok=True)
add_local_models()
utils.add_local_models()
self.model_name = list(settings.MODELS.keys())[0]

# init params
Expand Down Expand Up @@ -173,7 +173,7 @@ def _removed_layer(self, event):
def _preprocess(self):
""" Preprocess the current image in the viewer to improve visualisation for the user """
img = self.original_images[self.image_layer_name]
img = apply_normalization(img)
img = utils.apply_normalization(img)
self.viewer.layers[self.image_layer_name].data = img
self.viewer.layers[self.image_layer_name].contrast_limits = (0,255)

Expand Down Expand Up @@ -230,7 +230,7 @@ def _on_run_click(self):
show_info('Please load an image first and try again!')
return
# check if model exists locally and if not ask user if it's ok to download
if not return_is_file(settings.MODELS_DIR, settings.MODELS[self.model_name]["filename"]):
if not utils.return_is_file(settings.MODELS_DIR, settings.MODELS[self.model_name]["filename"]):
confirm_window = ConfirmUpload(self)
confirm_window.exec_()
# if user clicks cancel return doing nothing
Expand All @@ -254,7 +254,7 @@ def _on_run_click(self):
img_data = self.viewer.layers[self.image_layer_name].data

# check that image is grayscale
if len(squeeze_img(img_data).shape) > 2:
if len(utils.squeeze_img(img_data).shape) > 2:
show_info('Only grayscale images currently supported. Try a different image or process it first and try again!')
return

Expand Down Expand Up @@ -298,7 +298,7 @@ def _on_choose_model_clicked(self):
model_path = fd.selectedFiles()[0]
import shutil
shutil.copy2(model_path, settings.MODELS_DIR)
model_name = add_to_dict(model_path)
model_name = utils.add_to_dict(model_path)
self.model_selection.addItem(model_name)

def _on_window_sizes_changed(self):
Expand All @@ -320,7 +320,7 @@ def _rerun(self):
self.organoiDL.update_next_id(self.cur_shapes_name, len(self.cur_shapes_layer.scale)+1)

# make sure to add info to cur_shapes_layer.metadata to differentiate this action from when user adds/removes boxes
with set_dict_key( self.cur_shapes_layer.metadata, 'napari-organoid-counter:_rerun', True):
with utils.set_dict_key( self.cur_shapes_layer.metadata, 'napari-organoid-counter:_rerun', True):
# first update bboxes in organoiDLin case user has added/removed
self.organoiDL.update_bboxes_scores(self.cur_shapes_name,
self.cur_shapes_layer.data,
Expand Down Expand Up @@ -409,27 +409,27 @@ def _on_save_csv_click(self):
if not bboxes: show_info('No organoids detected! Please run auto organoid counter or run algorithm first and try again!')
else:
# write diameters and area to csv
data_csv = get_bbox_diameters(bboxes,
data_csv = utils.get_bbox_diameters(bboxes,
self.viewer.layers[self.save_layer_name].properties['box_id'],
self.viewer.layers[self.save_layer_name].scale)
fd = QFileDialog()
name, _ = fd.getSaveFileName(self, 'Save File', self.save_layer_name, 'CSV files (*.csv)')#, 'CSV Files (*.csv)')
if name: write_to_csv(name, data_csv)
if name: utils.write_to_csv(name, data_csv)

def _on_save_json_click(self):
""" Is called whenever Save boxes button is clicked """
bboxes = self.viewer.layers[self.save_layer_name].data
#scores = #add
if not bboxes: show_info('No organoids detected! Please run auto organoid counter or run algorithm first and try again!')
else:
data_json = get_bboxes_as_dict(bboxes,
data_json = utils.get_bboxes_as_dict(bboxes,
self.viewer.layers[self.save_layer_name].properties['box_id'],
self.viewer.layers[self.save_layer_name].properties['scores'],
self.viewer.layers[self.save_layer_name].scale)
# write bbox coordinates to json
fd = QFileDialog()
name,_ = fd.getSaveFileName(self, 'Save File', self.save_layer_name, 'JSON files (*.json)')#, 'CSV Files (*.csv)')
if name: write_to_json(name, data_json)
if name: utils.write_to_json(name, data_json)

def _update_added_image(self, added_items):
"""
Expand Down
1 change: 0 additions & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ install_requires =
napari-aicsimageio>=0.7.2
torch>=1.13.1
torchvision>=0.14.1
zenodo_get==1.3.4

[options.extras_require]
testing =
Expand Down