Skip to content

Commit

Permalink
Update tests (#97)
Browse files Browse the repository at this point in the history
* Fix default mutables in config

* Re-enable CRF optional dependency

* Fix layer set to invisible causing test errors

* Update README.md

* Update credits for example data
  • Loading branch information
C-Achard authored Oct 19, 2024
1 parent ee7944e commit bee33f5
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 20 deletions.
6 changes: 3 additions & 3 deletions examples/README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Testing CellSeg3D on demo data

Here is a very small volume (from [IDR project 853](https://idr.openmicroscopy.org/webclient/?show=project-853)) to test on.
All credits to the original authors of the data.
You can install, launch `napari`, activate the CellSeg3D plugin app, and drag & drop this volume into the canvas.
Then, for example, run `inference` with one of our models.

See [CellSeg3D documentation](https://adaptivemotorcontrollab.github.io/CellSeg3D/welcome.html) for more details.
Then, for example, run the `Inference` module with one of our models.

See [CellSeg3D documentation](https://adaptivemotorcontrollab.github.io/CellSeg3D/welcome.html) for more details.
5 changes: 3 additions & 2 deletions napari_cellseg3d/code_plugins/plugin_crop.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ def __init__(self, viewer: "napari.viewer.Viewer", parent=None):

self.create_new_layer = ui.CheckBox("Create new layers")
self.create_new_layer.setToolTip(
'Use this to create a new layer everytime you start cropping, so you can "zoom in" your volume'
'Use this to create a new layer every time you start cropping, so you can "zoom in" your volume'
)

self._viewer.layers.events.inserted.connect(self._check_image_list)
Expand Down Expand Up @@ -324,8 +324,9 @@ def _start(self):

if self.crop_second_image:
self.image_layer2 = self._add_isotropic_layer(
self.image_layer2, visible=False
self.image_layer2
)
self.image_layer2.visible = False
else:
self.image_layer1.opacity = 0.7
self.image_layer1.colormap = "inferno"
Expand Down
22 changes: 11 additions & 11 deletions napari_cellseg3d/config.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""Module to store configuration parameters for napari_cellseg3d."""
import datetime
from dataclasses import dataclass
from dataclasses import dataclass, field
from pathlib import Path
from typing import List, Optional

Expand Down Expand Up @@ -182,9 +182,9 @@ class PostProcessConfig:
instance (InstanceSegConfig): instance segmentation config
"""

zoom: Zoom = Zoom()
thresholding: Thresholding = Thresholding()
instance: InstanceSegConfig = InstanceSegConfig()
zoom: Zoom = field(default_factory=Zoom)
thresholding: Thresholding = field(default_factory=Thresholding)
instance: InstanceSegConfig = field(default_factory=InstanceSegConfig)
artifact_removal: bool = False
artifact_removal_size: int = 500

Expand Down Expand Up @@ -265,16 +265,16 @@ class InferenceWorkerConfig:
"""

device: str = "cpu"
model_info: ModelInfo = ModelInfo()
weights_config: WeightsInfo = WeightsInfo()
model_info: ModelInfo = field(default_factory=ModelInfo)
weights_config: WeightsInfo = field(default_factory=WeightsInfo)
results_path: str = str(Path.home() / "cellseg3d" / "inference")
filetype: str = ".tif"
keep_on_cpu: bool = False
compute_stats: bool = False
post_process_config: PostProcessConfig = PostProcessConfig()
sliding_window_config: SlidingWindowConfig = SlidingWindowConfig()
post_process_config: PostProcessConfig = field(default_factory=PostProcessConfig)
sliding_window_config: SlidingWindowConfig = field(default_factory=SlidingWindowConfig)
use_crf: bool = False
crf_config: CRFConfig = CRFConfig()
crf_config: CRFConfig = field(default_factory=CRFConfig)

images_filepaths: List[str] = None
layer: napari.layers.Layer = None
Expand Down Expand Up @@ -329,10 +329,10 @@ class TrainingWorkerConfig:
learning_rate: np.float64 = 1e-3
validation_interval: int = 2
batch_size: int = 1
deterministic_config: DeterministicConfig = DeterministicConfig()
deterministic_config: DeterministicConfig = field(default_factory=DeterministicConfig)
scheduler_factor: float = 0.5
scheduler_patience: int = 10
weights_info: WeightsInfo = WeightsInfo()
weights_info: WeightsInfo = field(default_factory=WeightsInfo)
# data params
results_path_folder: str = str(Path.home() / "cellseg3d" / "training")
sampling: bool = False
Expand Down
8 changes: 4 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,9 @@ profile = "black"
line_length = 79

[project.optional-dependencies]
#crf = [
# "pydensecrf@git+https://github.com/lucasb-eyer/pydensecrf.git#egg=master",
#]
crf = [
"pydensecrf@git+https://github.com/lucasb-eyer/pydensecrf.git#egg=master",
]
pyqt5 = [
"pyqt5",
]
Expand Down Expand Up @@ -164,7 +164,7 @@ test = [
"coverage",
"tox",
"twine",
# "pydensecrf@git+https://github.com/lucasb-eyer/pydensecrf.git#egg=master",
"pydensecrf@git+https://github.com/lucasb-eyer/pydensecrf.git#egg=master",
"onnx",
"onnxruntime",
]

0 comments on commit bee33f5

Please sign in to comment.