cellfinder 1.1.3__py3-none-any.whl → 1.2.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,8 +1,9 @@
1
1
  from dataclasses import dataclass
2
2
  from pathlib import Path
3
- from typing import Optional
3
+ from typing import List, Optional
4
4
 
5
5
  import numpy
6
+ from brainglobe_utils.cells.cells import Cell
6
7
 
7
8
  from cellfinder.napari.input_container import InputContainer
8
9
  from cellfinder.napari.utils import html_label_widget
@@ -59,6 +60,8 @@ class DataInputs(InputContainer):
59
60
  class DetectionInputs(InputContainer):
60
61
  """Container for cell candidate detection inputs."""
61
62
 
63
+ skip_detection: bool = False
64
+ detected_cells: Optional[List[Cell]] = None
62
65
  soma_diameter: float = 16.0
63
66
  ball_xy_size: float = 6
64
67
  ball_z_size: float = 15
@@ -75,6 +78,7 @@ class DetectionInputs(InputContainer):
75
78
  def widget_representation(cls) -> dict:
76
79
  return dict(
77
80
  detection_options=html_label_widget("Detection:"),
81
+ skip_detection=dict(value=cls.defaults()["skip_detection"]),
78
82
  soma_diameter=cls._custom_widget("soma_diameter"),
79
83
  ball_xy_size=cls._custom_widget(
80
84
  "ball_xy_size", custom_label="Ball filter (xy)"
@@ -107,6 +111,7 @@ class DetectionInputs(InputContainer):
107
111
  class ClassificationInputs(InputContainer):
108
112
  """Container for classification inputs."""
109
113
 
114
+ skip_classification: bool = False
110
115
  use_pre_trained_weights: bool = True
111
116
  trained_model: Optional[Path] = Path.home()
112
117
 
@@ -123,6 +128,9 @@ class ClassificationInputs(InputContainer):
123
128
  value=cls.defaults()["use_pre_trained_weights"]
124
129
  ),
125
130
  trained_model=dict(value=cls.defaults()["trained_model"]),
131
+ skip_classification=dict(
132
+ value=cls.defaults()["skip_classification"]
133
+ ),
126
134
  )
127
135
 
128
136
 
@@ -1,3 +1,4 @@
1
+ from magicgui.widgets import ProgressBar
1
2
  from napari.qt.threading import WorkerBase, WorkerBaseSignals
2
3
  from qtpy.QtCore import Signal
3
4
 
@@ -41,6 +42,19 @@ class Worker(WorkerBase):
41
42
  self.classification_inputs = classification_inputs
42
43
  self.misc_inputs = misc_inputs
43
44
 
45
+ def connect_progress_bar_callback(self, progress_bar: ProgressBar):
46
+ """
47
+ Connects the progress bar to the work so that updates are shown on
48
+ the bar.
49
+ """
50
+
51
+ def update_progress_bar(label: str, max: int, value: int):
52
+ progress_bar.label = label
53
+ progress_bar.max = max
54
+ progress_bar.value = value
55
+
56
+ self.update_progress_bar.connect(update_progress_bar)
57
+
44
58
  def work(self) -> list:
45
59
  self.update_progress_bar.emit("Setting up detection...", 1, 0)
46
60
 
@@ -8,11 +8,7 @@ from napari.utils.notifications import show_info
8
8
  from qtpy.QtWidgets import QScrollArea
9
9
 
10
10
  from cellfinder.core.train.train_yml import run as train_yml
11
- from cellfinder.napari.utils import (
12
- header_label_widget,
13
- html_label_widget,
14
- widget_header,
15
- )
11
+ from cellfinder.napari.utils import cellfinder_header, html_label_widget
16
12
 
17
13
  from .train_containers import (
18
14
  MiscTrainingInputs,
@@ -41,7 +37,6 @@ def run_training(
41
37
 
42
38
  def training_widget() -> FunctionGui:
43
39
  @magicgui(
44
- header=header_label_widget,
45
40
  training_label=html_label_widget("Network training", tag="h3"),
46
41
  **TrainingDataInputs.widget_representation(),
47
42
  **OptionalNetworkInputs.widget_representation(),
@@ -52,7 +47,6 @@ def training_widget() -> FunctionGui:
52
47
  scrollable=True,
53
48
  )
54
49
  def widget(
55
- header: dict,
56
50
  training_label: dict,
57
51
  data_options: dict,
58
52
  yaml_files: Path,
@@ -161,8 +155,7 @@ def training_widget() -> FunctionGui:
161
155
  )
162
156
  worker.start()
163
157
 
164
- widget.header.value = widget_header
165
- widget.header.native.setOpenExternalLinks(True)
158
+ widget.native.layout().insertWidget(0, cellfinder_header())
166
159
 
167
160
  @widget.reset_button.changed.connect
168
161
  def restore_defaults():
@@ -4,7 +4,7 @@ from typing import Optional
4
4
 
5
5
  from magicgui.types import FileDialogMode
6
6
 
7
- from cellfinder.core.download.models import model_weight_urls
7
+ from cellfinder.core.download.download import model_filenames
8
8
  from cellfinder.core.train.train_yml import models
9
9
  from cellfinder.napari.input_container import InputContainer
10
10
  from cellfinder.napari.utils import html_label_widget
@@ -46,7 +46,7 @@ class OptionalNetworkInputs(InputContainer):
46
46
  trained_model: Optional[Path] = Path.home()
47
47
  model_weights: Optional[Path] = Path.home()
48
48
  model_depth: str = list(models.keys())[2]
49
- pretrained_model: str = str(list(model_weight_urls.keys())[0])
49
+ pretrained_model: str = str(list(model_filenames.keys())[0])
50
50
 
51
51
  def as_core_arguments(self) -> dict:
52
52
  arguments = super().as_core_arguments()
@@ -65,7 +65,7 @@ class OptionalNetworkInputs(InputContainer):
65
65
  ),
66
66
  pretrained_model=cls._custom_widget(
67
67
  "pretrained_model",
68
- choices=list(model_weight_urls.keys()),
68
+ choices=list(model_filenames.keys()),
69
69
  ),
70
70
  )
71
71
 
@@ -1,24 +1,10 @@
1
1
  from typing import List, Tuple
2
2
 
3
3
  import napari
4
+ import napari.layers
4
5
  import numpy as np
5
- import pandas as pd
6
6
  from brainglobe_utils.cells.cells import Cell
7
- from pkg_resources import resource_filename
8
-
9
- brainglobe_logo = resource_filename(
10
- "cellfinder", "napari/images/brainglobe.png"
11
- )
12
-
13
-
14
- widget_header = """
15
- <p>Efficient cell detection in large images.</p>
16
- <p><a href="https://brainglobe.info" style="color:gray;">Website</a></p>
17
- <p><a href="https://brainglobe.info/documentation/cellfinder/user-guide/napari-plugin/index.html" style="color:gray;">Documentation</a></p>
18
- <p><a href="https://github.com/brainglobe/cellfinder" style="color:gray;">Source</a></p>
19
- <p><a href="https://doi.org/10.1371/journal.pcbi.1009074" style="color:gray;">Citation</a></p>
20
- <p><small>For help, hover the cursor over each parameter.</small>
21
- """ # noqa: E501
7
+ from brainglobe_utils.qtpy.logo import header_widget
22
8
 
23
9
 
24
10
  def html_label_widget(label: str, *, tag: str = "b") -> dict:
@@ -31,25 +17,42 @@ def html_label_widget(label: str, *, tag: str = "b") -> dict:
31
17
  )
32
18
 
33
19
 
34
- header_label_widget = html_label_widget(
35
- f"""
36
- <img src="{brainglobe_logo}"width="100">
37
- <p>cellfinder</p>
38
- """,
39
- tag="h1",
40
- )
20
+ def cellfinder_header():
21
+ """
22
+ Create the header containing the brainglobe logo and documentation links
23
+ for all cellfinder widgets.
24
+ """
25
+ return header_widget(
26
+ "cellfinder",
27
+ "Efficient cell detection in large images.",
28
+ documentation_path="cellfinder/user-guide/napari-plugin/index.html",
29
+ citation_doi="https://doi.org/10.1371/journal.pcbi.1009074",
30
+ help_text="For help, hover the cursor over each parameter.",
31
+ )
32
+
33
+
34
+ # the xyz axis order in napari relative to ours. I.e. our zeroth axis is the
35
+ # napari last axis. Ours is XYZ.
36
+ napari_points_axis_order = 2, 1, 0
37
+ # the xyz axis order in brainglobe relative to napari. I.e. napari's zeroth
38
+ # axis is our last axis - it's just flipped
39
+ brainglobe_points_axis_order = napari_points_axis_order
41
40
 
42
41
 
43
- def add_layers(points: List[Cell], viewer: napari.Viewer) -> None:
42
+ def add_classified_layers(
43
+ points: List[Cell],
44
+ viewer: napari.Viewer,
45
+ unknown_name: str = "Rejected",
46
+ cell_name: str = "Detected",
47
+ ) -> None:
44
48
  """
45
- Adds classified cell candidates as two separate point layers to the napari
46
- viewer.
49
+ Adds cell candidates as two separate point layers - unknowns and cells, to
50
+ the napari viewer. Does not add any other cell types, only Cell.UNKNOWN
51
+ and Cell.CELL from the list of cells.
47
52
  """
48
- detected, rejected = cells_to_array(points)
49
-
50
53
  viewer.add_points(
51
- rejected,
52
- name="Rejected",
54
+ cells_to_array(points, Cell.UNKNOWN, napari_order=True),
55
+ name=unknown_name,
53
56
  size=15,
54
57
  n_dimensional=True,
55
58
  opacity=0.6,
@@ -59,8 +62,8 @@ def add_layers(points: List[Cell], viewer: napari.Viewer) -> None:
59
62
  metadata=dict(point_type=Cell.UNKNOWN),
60
63
  )
61
64
  viewer.add_points(
62
- detected,
63
- name="Detected",
65
+ cells_to_array(points, Cell.CELL, napari_order=True),
66
+ name=cell_name,
64
67
  size=15,
65
68
  n_dimensional=True,
66
69
  opacity=0.6,
@@ -70,23 +73,61 @@ def add_layers(points: List[Cell], viewer: napari.Viewer) -> None:
70
73
  )
71
74
 
72
75
 
73
- def cells_df_as_np(
74
- cells_df: pd.DataFrame,
75
- new_order: List[int] = [2, 1, 0],
76
- type_column: str = "type",
76
+ def add_single_layer(
77
+ points: List[Cell],
78
+ viewer: napari.Viewer,
79
+ name: str,
80
+ cell_type: int,
81
+ ) -> None:
82
+ """
83
+ Adds all cells of cell_type Cell.TYPE to a new point layer in the napari
84
+ viewer, with given name.
85
+ """
86
+ viewer.add_points(
87
+ cells_to_array(points, cell_type, napari_order=True),
88
+ name=name,
89
+ size=15,
90
+ n_dimensional=True,
91
+ opacity=0.6,
92
+ symbol="ring",
93
+ face_color="lightskyblue",
94
+ visible=True,
95
+ metadata=dict(point_type=cell_type),
96
+ )
97
+
98
+
99
+ def cells_to_array(
100
+ cells: List[Cell], cell_type: int, napari_order: bool = True
77
101
  ) -> np.ndarray:
78
102
  """
79
- Convert a dataframe to an array, dropping *type_column* and re-ordering
80
- the columns with *new_order*.
103
+ Converts all the cells of the given type as a 2D pos array.
104
+ The column order is either XYZ, otherwise it's the napari ordering
105
+ of the 3 axes (napari_points_axis_order).
81
106
  """
82
- cells_df = cells_df.drop(columns=[type_column])
83
- cells = cells_df[cells_df.columns[new_order]]
84
- cells = cells.to_numpy()
85
- return cells
107
+ cells = [c for c in cells if c.type == cell_type]
108
+ if not cells:
109
+ # make sure we return 2d array if cells is empty
110
+ return np.zeros((0, 3), dtype=np.int_)
111
+ points = np.array([(c.x, c.y, c.z) for c in cells])
86
112
 
113
+ if napari_order:
114
+ return points[:, napari_points_axis_order]
115
+ return points
87
116
 
88
- def cells_to_array(cells: List[Cell]) -> Tuple[np.ndarray, np.ndarray]:
89
- df = pd.DataFrame([c.to_dict() for c in cells])
90
- points = cells_df_as_np(df[df["type"] == Cell.CELL])
91
- rejected = cells_df_as_np(df[df["type"] == Cell.UNKNOWN])
92
- return points, rejected
117
+
118
+ def napari_array_to_cells(
119
+ points: napari.layers.Points,
120
+ cell_type: int,
121
+ brainglobe_order: Tuple[int, int, int] = brainglobe_points_axis_order,
122
+ ) -> List[Cell]:
123
+ """
124
+ Takes a napari Points layer and returns a list of cell objects, one for
125
+ each point in the layer.
126
+ """
127
+ data = np.asarray(points.data)[:, brainglobe_order].tolist()
128
+
129
+ cells = []
130
+ for row in data:
131
+ cells.append(Cell(pos=row, cell_type=cell_type))
132
+
133
+ return cells
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: cellfinder
3
- Version: 1.1.3
3
+ Version: 1.2.0
4
4
  Summary: Automated 3D cell detection in large microscopy images
5
5
  Author-email: "Adam Tyson, Christian Niedworok, Charly Rousseau" <code@adamltyson.com>
6
6
  License: BSD-3-Clause
@@ -22,7 +22,7 @@ Classifier: Topic :: Scientific/Engineering :: Image Recognition
22
22
  Requires-Python: >=3.9
23
23
  Description-Content-Type: text/markdown
24
24
  License-File: LICENSE
25
- Requires-Dist: brainglobe-utils >=0.4.2
25
+ Requires-Dist: brainglobe-utils >=0.5.0
26
26
  Requires-Dist: brainglobe-napari-io >=0.3.4
27
27
  Requires-Dist: dask[array]
28
28
  Requires-Dist: fancylog >=0.0.7
@@ -54,17 +54,17 @@ Requires-Dist: napari[pyqt5] ; extra == 'napari'
54
54
  Requires-Dist: pooch >=1 ; extra == 'napari'
55
55
  Requires-Dist: qtpy ; extra == 'napari'
56
56
 
57
- [![Python Version](https://img.shields.io/pypi/pyversions/cellfinder-core.svg)](https://pypi.org/project/cellfinder)
58
- [![PyPI](https://img.shields.io/pypi/v/cellfinder-core.svg)](https://pypi.org/project/cellfinder)
59
- [![Downloads](https://pepy.tech/badge/cellfinder-core)](https://pepy.tech/project/cellfinder)
60
- [![Wheel](https://img.shields.io/pypi/wheel/cellfinder-core.svg)](https://pypi.org/project/cellfinder)
61
- [![Development Status](https://img.shields.io/pypi/status/cellfinder-core.svg)](https://github.com/brainglobe/cellfinder)
57
+ [![Python Version](https://img.shields.io/pypi/pyversions/cellfinder.svg)](https://pypi.org/project/cellfinder)
58
+ [![PyPI](https://img.shields.io/pypi/v/cellfinder.svg)](https://pypi.org/project/cellfinder)
59
+ [![Downloads](https://pepy.tech/badge/cellfinder)](https://pepy.tech/project/cellfinder)
60
+ [![Wheel](https://img.shields.io/pypi/wheel/cellfinder.svg)](https://pypi.org/project/cellfinder)
61
+ [![Development Status](https://img.shields.io/pypi/status/cellfinder.svg)](https://github.com/brainglobe/cellfinder)
62
62
  [![Tests](https://img.shields.io/github/actions/workflow/status/brainglobe/cellfinder/test_and_deploy.yml?branch=main)](https://github.com/brainglobe/cellfinder/actions)
63
- [![codecov](https://codecov.io/gh/brainglobe/cellfinder-core/branch/main/graph/badge.svg?token=nx1lhNI7ox)](https://codecov.io/gh/brainglobe/cellfinder)
63
+ [![codecov](https://codecov.io/gh/brainglobe/cellfinder/branch/main/graph/badge.svg?token=nx1lhNI7ox)](https://codecov.io/gh/brainglobe/cellfinder)
64
64
  [![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/python/black)
65
65
  [![Imports: isort](https://img.shields.io/badge/%20imports-isort-%231674b1?style=flat&labelColor=ef8336)](https://pycqa.github.io/isort/)
66
66
  [![pre-commit](https://img.shields.io/badge/pre--commit-enabled-brightgreen?logo=pre-commit&logoColor=white)](https://github.com/pre-commit/pre-commit)
67
- [![Contributions](https://img.shields.io/badge/Contributions-Welcome-brightgreen.svg)](https://brainglobe.info/developers/index.html)
67
+ [![Contributions](https://img.shields.io/badge/Contributions-Welcome-brightgreen.svg)](https://brainglobe.info/community/developers/index.html)
68
68
  [![Twitter](https://img.shields.io/twitter/follow/brain_globe?style=social)](https://twitter.com/brain_globe)
69
69
 
70
70
  # cellfinder
@@ -1,7 +1,7 @@
1
- cellfinder/__init__.py,sha256=XwXxMZJgw62dOHhrAKMQk0CE3378WRQWoC-kpf5LLpE,935
1
+ cellfinder/__init__.py,sha256=7H9UKFWCk-TNkFLwk-D4EVU5-rJZsGxfo0qcaFVcfKY,1035
2
2
  cellfinder/cli_migration_warning.py,sha256=gPtNrtnXvWpl5q0k_EGAQZg0DwcpCmuBTgpg56n5NfA,1578
3
3
  cellfinder/core/__init__.py,sha256=pRFuQsl78HEK0S6gvhJw70QLbjjSBzP-GFO0AtVaGtk,62
4
- cellfinder/core/main.py,sha256=3Wg4QvBUlaHq04Yltjg9FSiePAhtGeFL1C-6Z1SI0Gk,3900
4
+ cellfinder/core/main.py,sha256=Y-4Wt9d9K7o2l3IO7acZbtNuhqZzF5UU-rMJksb6k94,4392
5
5
  cellfinder/core/types.py,sha256=lTqWE4v0SMM0qLAZJdyAzqV1nLgDtobEpglNJcXt160,106
6
6
  cellfinder/core/classify/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
7
7
  cellfinder/core/classify/augment.py,sha256=8dMbM7KhimM6NMgdMC53oHoCfYj1CIB-h3Yk8CZAxPw,6321
@@ -12,7 +12,7 @@ cellfinder/core/classify/tools.py,sha256=UqABKS9KnkwR3PIhGRl7xHJbADP0mgVRSxXI5dy
12
12
  cellfinder/core/config/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
13
13
  cellfinder/core/config/cellfinder.conf,sha256=5i8axif7ekMutKDiVnZRs-LiJrgVQljg_beltidqtNk,56
14
14
  cellfinder/core/detect/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
15
- cellfinder/core/detect/detect.py,sha256=bsiOPyxM3D_YZiYxqyauTxe7C4C2-rb_9yYiJiYaylM,9102
15
+ cellfinder/core/detect/detect.py,sha256=iEYaYuYCSR4VJXmlFbEE1ti9Pjpv6m4rSfFILSOYmhE,9592
16
16
  cellfinder/core/detect/filters/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
17
17
  cellfinder/core/detect/filters/setup_filters.py,sha256=sUyZ2dKbfwhn4YTq3kLVTHkckZZ460AVozLfoz7hJK8,2084
18
18
  cellfinder/core/detect/filters/plane/__init__.py,sha256=lybcPbVDnurEQeq2FiLq0zR8p_ztarQOlajhdh1Q2-4,40
@@ -20,44 +20,41 @@ cellfinder/core/detect/filters/plane/classical_filter.py,sha256=Nton_nrvv6LhNlK1
20
20
  cellfinder/core/detect/filters/plane/plane_filter.py,sha256=PWcAHDKB3qn3i9aSmQzUTEi3tgmccrf24DipjnYbOg0,2746
21
21
  cellfinder/core/detect/filters/plane/tile_walker.py,sha256=lhKrq-MB35bR0_JYgj7WMR4otuaZ6XRDDhJhKyH1yS8,3001
22
22
  cellfinder/core/detect/filters/volume/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
23
- cellfinder/core/detect/filters/volume/ball_filter.py,sha256=nNGYAjDWst4Ufh6o6LAb5CVi5hFqYi2ObyrwgChbkQw,11175
24
- cellfinder/core/detect/filters/volume/structure_detection.py,sha256=8lSyDFiqn5lYoE_mDLpXTUOsWGVm2-suGttZBdDAqmA,9152
25
- cellfinder/core/detect/filters/volume/structure_splitting.py,sha256=VuXKAOHG6f63ommPxZC08JRoegbQgZUReZAmvY5nm_U,7656
26
- cellfinder/core/detect/filters/volume/volume_filter.py,sha256=nBc9kZhsZ2jsyuzizXcx6s0i5-Vc7BfUfDqtIxhGUSo,6873
23
+ cellfinder/core/detect/filters/volume/ball_filter.py,sha256=ZEg8FNty-VD5N9j4FLZ18G-BuSvxjHs2-QTblwKcZgw,13894
24
+ cellfinder/core/detect/filters/volume/structure_detection.py,sha256=mTHi0_A9FCK39I6fZm2dfMpDxIkfaidOIf6eCjTw-70,11307
25
+ cellfinder/core/detect/filters/volume/structure_splitting.py,sha256=XzTYguVT8VdTu2h4-Jdt5Yyeu8VBYmdRo5jmwwLwuck,7660
26
+ cellfinder/core/detect/filters/volume/volume_filter.py,sha256=BJ8bStlNvMWsGlBekeqXpS8d9YKoLe3ifMfrEPpva2Q,7035
27
27
  cellfinder/core/download/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
28
- cellfinder/core/download/cli.py,sha256=uejrDBoveybeyMq-tcn8460r2Hf3iC1FhpEC2sXs7EI,1807
29
- cellfinder/core/download/download.py,sha256=oKxo6Ch3wCAbVmyzjvIhnaSUb0sF5P8mJYGbJCU9Gag,3933
30
- cellfinder/core/download/models.py,sha256=mLb6wAUn-tH1FtgvQU6ooLXqXetTP4D5Jd4_gPN-kJo,1359
31
- cellfinder/core/tools/IO.py,sha256=q-euCP1s3iuWYvD2V72sPSBfwr5A1ETcL6Z_K41mLV0,1235
28
+ cellfinder/core/download/cli.py,sha256=X9L9ZIkWqs58hX8G8q_0AKN4gk8BhydGxI9nLpdHQQE,1764
29
+ cellfinder/core/download/download.py,sha256=YQP4NMM9Xt0rECRJEV5z6RCZNi5uCFhohFnDreH0qHA,3277
32
30
  cellfinder/core/tools/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
33
31
  cellfinder/core/tools/array_operations.py,sha256=LDbqWA_N2YtxeKS877QYdJRL2FCMC1R1ExJtdb6-vEA,3371
34
32
  cellfinder/core/tools/geometry.py,sha256=xlEQQmVQ9jcXqRzUqU554P8VxkaWkc5J_YhjkkKlI0Q,1124
35
33
  cellfinder/core/tools/image_processing.py,sha256=z27bGjf3Iv3G4Nt1OYzpEnIYQNc4nNomj_QitqvZB78,2269
36
- cellfinder/core/tools/prep.py,sha256=A1tfHZmkGFpbb7cjLdfP8KavZNqRwzdum92NW8Et01o,2553
37
- cellfinder/core/tools/source_files.py,sha256=NCPeA_kvnPWgS_fxWarc-9nBNjxkgL1xMFg-Co_kPlA,791
34
+ cellfinder/core/tools/prep.py,sha256=hGWwXxeP88ahp6ji2bkBu9FOz8BmrZsVwI-CEv4qxQ4,2473
35
+ cellfinder/core/tools/source_files.py,sha256=vvwsIMe1ULKvXg_x22L75iqvCyMjEbUjJsDFQk3GYzY,856
38
36
  cellfinder/core/tools/system.py,sha256=6iSOLrz2mtKgOIdwjp_VS0-74XQCuaQYCvWAViJgEus,2232
39
37
  cellfinder/core/tools/tf.py,sha256=jNU97-gIB51rLube9EoZ9bREkbqWRk-xPZhDTXG_jE4,1713
40
38
  cellfinder/core/tools/tiff.py,sha256=NzIz6wq2GzxmcIhawFMwZADe-uQO2rIG46H7xkpGKLs,2899
41
39
  cellfinder/core/tools/tools.py,sha256=G8oDGNRuWkzEJDnnC4r3SNGgpVbqbelCZR5ODk9JRzs,4867
42
40
  cellfinder/core/train/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
43
- cellfinder/core/train/train_yml.py,sha256=TO_8e6Uz1S-P49o53gB_4i97Afz6RCHqmyyIrA70TZ8,13214
41
+ cellfinder/core/train/train_yml.py,sha256=0iiROBdxNoMyMoPGYC8tq6bGM3jzAKlGA2LABgoqd6M,13139
44
42
  cellfinder/napari/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
45
43
  cellfinder/napari/curation.py,sha256=jz7GekuuzOdwiEFLarvvO5Bho68k8eL7AjObMdEoPXw,21447
46
44
  cellfinder/napari/input_container.py,sha256=tkm0dkPt7kSL8Xkvs1fh8M6vKWw57QLIt_wv74HFkGk,2150
47
45
  cellfinder/napari/napari.yaml,sha256=WMR1CIAmYIVyQngbdbomTRZLvlDbb6LxsXsvTRClQnE,921
48
46
  cellfinder/napari/sample_data.py,sha256=oUST23q09MM8dxHbUCmO0AjtXG6OlR_32LLqP0EU2UA,732
49
- cellfinder/napari/utils.py,sha256=mCy4Lr_gE2wWgRUSEiApNUjgLLAz0SSahTZnmUnRbgQ,2592
47
+ cellfinder/napari/utils.py,sha256=AwTs76M9azutHhHj2yuaKErDEQ5F6pFbIIakBfzen6M,3824
50
48
  cellfinder/napari/detect/__init__.py,sha256=BD9Bg9NTAr6yRTq2A_p58U6j4w5wbY0sdXwhPJ3MSMY,34
51
- cellfinder/napari/detect/detect.py,sha256=Jr4-lDGIntwcxSQ1Ne4xoA0SaKd4kf4zUT8MPyyO5ic,7443
52
- cellfinder/napari/detect/detect_containers.py,sha256=C_tN7qwWNHhYFRRn_2yQ7QDyxpj3pQXLZalO0UQ_cbw,5020
53
- cellfinder/napari/detect/thread_worker.py,sha256=BchLapCyML4SBDfihsqNLvqGM8FVcXEejaGg8MSkMCs,2604
54
- cellfinder/napari/images/brainglobe.png,sha256=IT2zfikD2vKTOg--e6bMRHr5mC2x3s-eOt_t0eblvQ0,21216
49
+ cellfinder/napari/detect/detect.py,sha256=gX10U4HHcni1ff3zYXkXYX6dWMZErYpvzVde56yV80w,13658
50
+ cellfinder/napari/detect/detect_containers.py,sha256=Xx-E2JTbe5Ih_1m5ZhQ0pCYFxfdQxVJMMfGh9EZExms,5377
51
+ cellfinder/napari/detect/thread_worker.py,sha256=3xGUPSthycpErcVxl_yc5soIv_z0Hf0iEaZq0Yx90OM,3078
55
52
  cellfinder/napari/train/__init__.py,sha256=xo4CK-DvSecInGEc2ohcTgQYlH3iylFnGvKTCoq2WkI,35
56
- cellfinder/napari/train/train.py,sha256=Cv8ivPWZoJJ-Iq1vW1JUmViaSnBPeqs07jBvZfOZQLc,6061
57
- cellfinder/napari/train/train_containers.py,sha256=mYI_M1QssWgPBpkqViqgj1Ls32lVRUAjt6OGTqcrKI4,4390
58
- cellfinder-1.1.3.dist-info/LICENSE,sha256=Tw8iMytIDXLSmcIUsbQmRWojstl9yOWsPCx6ZT6dZLY,1564
59
- cellfinder-1.1.3.dist-info/METADATA,sha256=znQeFj56Dxn2pna6L-ZYb98Ht8c5akgzcYhzhDu7YgI,6652
60
- cellfinder-1.1.3.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
61
- cellfinder-1.1.3.dist-info/entry_points.txt,sha256=cKKjU8GPiN-TRelG2sT2JCKAcB9XDCjP6g9atE9pSoY,247
62
- cellfinder-1.1.3.dist-info/top_level.txt,sha256=jyTQzX-tDjbsMr6s-E71Oy0IKQzmHTXSk4ZhpG5EDSE,11
63
- cellfinder-1.1.3.dist-info/RECORD,,
53
+ cellfinder/napari/train/train.py,sha256=zJY7zKcLqDTDtD76thmbwViEU4tTFCmXZze-zHsTpoo,5941
54
+ cellfinder/napari/train/train_containers.py,sha256=1wZ_GPe7B5XsLYs5XIx4m8GMw5KeVhg6SchhPtXu4V8,4386
55
+ cellfinder-1.2.0.dist-info/LICENSE,sha256=Tw8iMytIDXLSmcIUsbQmRWojstl9yOWsPCx6ZT6dZLY,1564
56
+ cellfinder-1.2.0.dist-info/METADATA,sha256=0_L_i066TdGFnfaRZe8zY-y0XwF7HX88F0mzV4AqLEw,6632
57
+ cellfinder-1.2.0.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
58
+ cellfinder-1.2.0.dist-info/entry_points.txt,sha256=cKKjU8GPiN-TRelG2sT2JCKAcB9XDCjP6g9atE9pSoY,247
59
+ cellfinder-1.2.0.dist-info/top_level.txt,sha256=jyTQzX-tDjbsMr6s-E71Oy0IKQzmHTXSk4ZhpG5EDSE,11
60
+ cellfinder-1.2.0.dist-info/RECORD,,
@@ -1,49 +0,0 @@
1
- import os
2
- from pathlib import Path
3
- from typing import Literal
4
-
5
- from cellfinder.core import logger
6
- from cellfinder.core.download.download import download
7
-
8
- model_weight_urls = {
9
- "resnet50_tv": "https://gin.g-node.org/cellfinder/models/raw/"
10
- "master/resnet50_tv.h5",
11
- "resnet50_all": "https://gin.g-node.org/cellfinder/models/raw/"
12
- "master/resnet50_weights.h5",
13
- }
14
-
15
- download_requirements_gb = {
16
- "resnet50_tv": 0.18,
17
- "resnet50_all": 0.18,
18
- }
19
-
20
- model_type = Literal["resnet50_tv", "resnet50_all"]
21
-
22
-
23
- def main(model_name: model_type, download_path: os.PathLike) -> Path:
24
- """
25
- For a given model name and download path, download the model file
26
- and return the path to the downloaded file.
27
- """
28
- download_path = Path(download_path)
29
-
30
- model_weight_dir = download_path / "model_weights"
31
- model_path = model_weight_dir / f"{model_name}.h5"
32
- if not model_path.exists():
33
- model_weight_dir.mkdir(parents=True)
34
-
35
- logger.info(
36
- f"Downloading '{model_name}' model. This may take a little while."
37
- )
38
-
39
- download(
40
- model_path,
41
- model_weight_urls[model_name],
42
- model_name,
43
- download_requires=download_requirements_gb[model_name],
44
- )
45
-
46
- else:
47
- logger.info(f"Model already exists at {model_path}. Skipping download")
48
-
49
- return model_path
@@ -1,48 +0,0 @@
1
- import glob
2
- import os
3
- from typing import Tuple
4
-
5
- import numpy as np
6
- from brainglobe_utils.general.system import get_sorted_file_paths
7
- from dask import array as da
8
- from dask import delayed
9
- from tifffile import TiffFile, imread
10
-
11
-
12
- def get_tiff_meta(
13
- path: str,
14
- ) -> Tuple[Tuple[int, int], np.dtype]:
15
- with TiffFile(path) as tfile:
16
- nz = len(tfile.pages)
17
- if not nz:
18
- raise ValueError(f"tiff file {path} has no pages!")
19
- first_page = tfile.pages[0]
20
-
21
- return tfile.pages[0].shape, first_page.dtype
22
-
23
-
24
- lazy_imread = delayed(imread) # lazy reader
25
-
26
-
27
- def read_with_dask(path):
28
- """
29
- Based on https://github.com/tlambert03/napari-ndtiffs
30
- :param path:
31
- :return:
32
- """
33
-
34
- if path.endswith(".txt"):
35
- with open(path, "r") as f:
36
- filenames = [line.rstrip() for line in f.readlines()]
37
-
38
- else:
39
- filenames = glob.glob(os.path.join(path, "*.tif"))
40
-
41
- shape, dtype = get_tiff_meta(filenames[0])
42
- lazy_arrays = [lazy_imread(fn) for fn in get_sorted_file_paths(filenames)]
43
- dask_arrays = [
44
- da.from_delayed(delayed_reader, shape=shape, dtype=dtype)
45
- for delayed_reader in lazy_arrays
46
- ]
47
- stack = da.stack(dask_arrays, axis=0)
48
- return stack
Binary file