cellfinder 1.1.3__py3-none-any.whl → 1.3.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.
Potentially problematic release.
This version of cellfinder might be problematic. Click here for more details.
- cellfinder/__init__.py +21 -12
- cellfinder/core/classify/classify.py +13 -6
- cellfinder/core/classify/cube_generator.py +27 -11
- cellfinder/core/classify/resnet.py +9 -6
- cellfinder/core/classify/tools.py +13 -11
- cellfinder/core/detect/detect.py +12 -1
- cellfinder/core/detect/filters/volume/ball_filter.py +198 -113
- cellfinder/core/detect/filters/volume/structure_detection.py +105 -41
- cellfinder/core/detect/filters/volume/structure_splitting.py +1 -1
- cellfinder/core/detect/filters/volume/volume_filter.py +48 -49
- cellfinder/core/download/cli.py +39 -32
- cellfinder/core/download/download.py +44 -56
- cellfinder/core/main.py +53 -68
- cellfinder/core/tools/prep.py +12 -20
- cellfinder/core/tools/source_files.py +5 -3
- cellfinder/core/tools/system.py +10 -0
- cellfinder/core/train/train_yml.py +29 -27
- cellfinder/napari/curation.py +1 -1
- cellfinder/napari/detect/detect.py +259 -58
- cellfinder/napari/detect/detect_containers.py +11 -1
- cellfinder/napari/detect/thread_worker.py +16 -2
- cellfinder/napari/train/train.py +2 -9
- cellfinder/napari/train/train_containers.py +3 -3
- cellfinder/napari/utils.py +88 -47
- {cellfinder-1.1.3.dist-info → cellfinder-1.3.0.dist-info}/METADATA +12 -11
- {cellfinder-1.1.3.dist-info → cellfinder-1.3.0.dist-info}/RECORD +30 -34
- cellfinder/core/download/models.py +0 -49
- cellfinder/core/tools/IO.py +0 -48
- cellfinder/core/tools/tf.py +0 -46
- cellfinder/napari/images/brainglobe.png +0 -0
- {cellfinder-1.1.3.dist-info → cellfinder-1.3.0.dist-info}/LICENSE +0 -0
- {cellfinder-1.1.3.dist-info → cellfinder-1.3.0.dist-info}/WHEEL +0 -0
- {cellfinder-1.1.3.dist-info → cellfinder-1.3.0.dist-info}/entry_points.txt +0 -0
- {cellfinder-1.1.3.dist-info → cellfinder-1.3.0.dist-info}/top_level.txt +0 -0
cellfinder/napari/utils.py
CHANGED
|
@@ -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
|
|
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
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
"""
|
|
39
|
-
|
|
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
|
|
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
|
|
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
|
-
|
|
52
|
-
name=
|
|
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
|
-
|
|
63
|
-
name=
|
|
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
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
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
|
-
|
|
80
|
-
the
|
|
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
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
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
|
-
|
|
89
|
-
|
|
90
|
-
points
|
|
91
|
-
|
|
92
|
-
|
|
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.
|
|
3
|
+
Version: 1.3.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
|
|
@@ -18,11 +18,12 @@ Classifier: Programming Language :: Python
|
|
|
18
18
|
Classifier: Programming Language :: Python :: 3
|
|
19
19
|
Classifier: Programming Language :: Python :: 3.9
|
|
20
20
|
Classifier: Programming Language :: Python :: 3.10
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
21
22
|
Classifier: Topic :: Scientific/Engineering :: Image Recognition
|
|
22
23
|
Requires-Python: >=3.9
|
|
23
24
|
Description-Content-Type: text/markdown
|
|
24
25
|
License-File: LICENSE
|
|
25
|
-
Requires-Dist: brainglobe-utils >=0.
|
|
26
|
+
Requires-Dist: brainglobe-utils >=0.5.0
|
|
26
27
|
Requires-Dist: brainglobe-napari-io >=0.3.4
|
|
27
28
|
Requires-Dist: dask[array]
|
|
28
29
|
Requires-Dist: fancylog >=0.0.7
|
|
@@ -31,10 +32,10 @@ Requires-Dist: numba
|
|
|
31
32
|
Requires-Dist: numpy
|
|
32
33
|
Requires-Dist: scikit-image
|
|
33
34
|
Requires-Dist: scikit-learn
|
|
35
|
+
Requires-Dist: keras >=3.0.0
|
|
36
|
+
Requires-Dist: torch >=2.1.0
|
|
34
37
|
Requires-Dist: tifffile
|
|
35
38
|
Requires-Dist: tqdm
|
|
36
|
-
Requires-Dist: tensorflow <2.12.0,>=2.5.0 ; platform_system != "Darwin" or platform_machine != "arm64"
|
|
37
|
-
Requires-Dist: tensorflow-macos <2.12.0,>=2.5.0 ; platform_system == "Darwin" and platform_machine == "arm64"
|
|
38
39
|
Provides-Extra: dev
|
|
39
40
|
Requires-Dist: black ; extra == 'dev'
|
|
40
41
|
Requires-Dist: pre-commit ; extra == 'dev'
|
|
@@ -54,17 +55,17 @@ Requires-Dist: napari[pyqt5] ; extra == 'napari'
|
|
|
54
55
|
Requires-Dist: pooch >=1 ; extra == 'napari'
|
|
55
56
|
Requires-Dist: qtpy ; extra == 'napari'
|
|
56
57
|
|
|
57
|
-
[](https://pypi.org/project/cellfinder)
|
|
59
|
+
[](https://pypi.org/project/cellfinder)
|
|
60
|
+
[](https://pepy.tech/project/cellfinder)
|
|
61
|
+
[](https://pypi.org/project/cellfinder)
|
|
62
|
+
[](https://github.com/brainglobe/cellfinder)
|
|
62
63
|
[](https://github.com/brainglobe/cellfinder/actions)
|
|
63
|
-
[](https://codecov.io/gh/brainglobe/cellfinder)
|
|
64
65
|
[](https://github.com/python/black)
|
|
65
66
|
[](https://pycqa.github.io/isort/)
|
|
66
67
|
[](https://github.com/pre-commit/pre-commit)
|
|
67
|
-
[](https://brainglobe.info/developers/index.html)
|
|
68
|
+
[](https://brainglobe.info/community/developers/index.html)
|
|
68
69
|
[](https://twitter.com/brain_globe)
|
|
69
70
|
|
|
70
71
|
# cellfinder
|
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
cellfinder/__init__.py,sha256=
|
|
1
|
+
cellfinder/__init__.py,sha256=S5oQ3EORuyQTMYC4uUuzGKZ23J3Ya6q-1DOBib1KfiA,1166
|
|
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=
|
|
4
|
+
cellfinder/core/main.py,sha256=t2mkq6iieEytbPckehBB43juwN5E-vhzstLSs620vdM,3625
|
|
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
|
|
8
|
-
cellfinder/core/classify/classify.py,sha256=
|
|
9
|
-
cellfinder/core/classify/cube_generator.py,sha256=
|
|
10
|
-
cellfinder/core/classify/resnet.py,sha256=
|
|
11
|
-
cellfinder/core/classify/tools.py,sha256=
|
|
8
|
+
cellfinder/core/classify/classify.py,sha256=33ZvNDmgVabH_6p4jV9Xi8bLKwDZnVhzlImrL_TlnBk,3269
|
|
9
|
+
cellfinder/core/classify/cube_generator.py,sha256=jC5aogTVy213PHouViSR9CgKkuOks3yk6csQC5kRoOE,17125
|
|
10
|
+
cellfinder/core/classify/resnet.py,sha256=vGa85y_NcQnOXwAt5EtatLx5mrO8IoShCcNKtJ5-EFg,10034
|
|
11
|
+
cellfinder/core/classify/tools.py,sha256=s5PEKAsZVbVuoferZ_nqMUM0f2bV_8WEKsdKe3SXEuE,2560
|
|
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=
|
|
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,40 @@ 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=
|
|
24
|
-
cellfinder/core/detect/filters/volume/structure_detection.py,sha256=
|
|
25
|
-
cellfinder/core/detect/filters/volume/structure_splitting.py,sha256=
|
|
26
|
-
cellfinder/core/detect/filters/volume/volume_filter.py,sha256=
|
|
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=
|
|
29
|
-
cellfinder/core/download/download.py,sha256=
|
|
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=
|
|
37
|
-
cellfinder/core/tools/source_files.py,sha256=
|
|
38
|
-
cellfinder/core/tools/system.py,sha256=
|
|
39
|
-
cellfinder/core/tools/tf.py,sha256=jNU97-gIB51rLube9EoZ9bREkbqWRk-xPZhDTXG_jE4,1713
|
|
34
|
+
cellfinder/core/tools/prep.py,sha256=YU4VDyjEsOXn3S3gymEfPUzka-WYiHmR4Q4XdRebhDI,2175
|
|
35
|
+
cellfinder/core/tools/source_files.py,sha256=vvwsIMe1ULKvXg_x22L75iqvCyMjEbUjJsDFQk3GYzY,856
|
|
36
|
+
cellfinder/core/tools/system.py,sha256=WvEzPr7v-ohLDnzf4n13TMcN5OYIAXOEkaSmrHzdnwc,2438
|
|
40
37
|
cellfinder/core/tools/tiff.py,sha256=NzIz6wq2GzxmcIhawFMwZADe-uQO2rIG46H7xkpGKLs,2899
|
|
41
38
|
cellfinder/core/tools/tools.py,sha256=G8oDGNRuWkzEJDnnC4r3SNGgpVbqbelCZR5ODk9JRzs,4867
|
|
42
39
|
cellfinder/core/train/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
43
|
-
cellfinder/core/train/train_yml.py,sha256=
|
|
40
|
+
cellfinder/core/train/train_yml.py,sha256=9QXv2wk24G8hYskMnBij7OngEELUWySK2fH4NFbYWw4,13260
|
|
44
41
|
cellfinder/napari/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
45
|
-
cellfinder/napari/curation.py,sha256=
|
|
42
|
+
cellfinder/napari/curation.py,sha256=nbxCwY2bhEPM15Wf3S_Ff8qGdLSWojr4X48mmAJqD3U,21447
|
|
46
43
|
cellfinder/napari/input_container.py,sha256=tkm0dkPt7kSL8Xkvs1fh8M6vKWw57QLIt_wv74HFkGk,2150
|
|
47
44
|
cellfinder/napari/napari.yaml,sha256=WMR1CIAmYIVyQngbdbomTRZLvlDbb6LxsXsvTRClQnE,921
|
|
48
45
|
cellfinder/napari/sample_data.py,sha256=oUST23q09MM8dxHbUCmO0AjtXG6OlR_32LLqP0EU2UA,732
|
|
49
|
-
cellfinder/napari/utils.py,sha256=
|
|
46
|
+
cellfinder/napari/utils.py,sha256=AwTs76M9azutHhHj2yuaKErDEQ5F6pFbIIakBfzen6M,3824
|
|
50
47
|
cellfinder/napari/detect/__init__.py,sha256=BD9Bg9NTAr6yRTq2A_p58U6j4w5wbY0sdXwhPJ3MSMY,34
|
|
51
|
-
cellfinder/napari/detect/detect.py,sha256=
|
|
52
|
-
cellfinder/napari/detect/detect_containers.py,sha256=
|
|
53
|
-
cellfinder/napari/detect/thread_worker.py,sha256=
|
|
54
|
-
cellfinder/napari/images/brainglobe.png,sha256=IT2zfikD2vKTOg--e6bMRHr5mC2x3s-eOt_t0eblvQ0,21216
|
|
48
|
+
cellfinder/napari/detect/detect.py,sha256=VB3SLZvqJhjuypjpaZuV9JscQ-sE8yVHG8RzEsZWfeA,13809
|
|
49
|
+
cellfinder/napari/detect/detect_containers.py,sha256=j9NTsIyyDNrhlI2dc7hvc7QlxvI1NRHlCe137v7fsPg,5467
|
|
50
|
+
cellfinder/napari/detect/thread_worker.py,sha256=PWM3OE-FpK-dpdhaE_Gi-2lD3u8sL-SJ13mp0pMhTyI,3078
|
|
55
51
|
cellfinder/napari/train/__init__.py,sha256=xo4CK-DvSecInGEc2ohcTgQYlH3iylFnGvKTCoq2WkI,35
|
|
56
|
-
cellfinder/napari/train/train.py,sha256=
|
|
57
|
-
cellfinder/napari/train/train_containers.py,sha256=
|
|
58
|
-
cellfinder-1.
|
|
59
|
-
cellfinder-1.
|
|
60
|
-
cellfinder-1.
|
|
61
|
-
cellfinder-1.
|
|
62
|
-
cellfinder-1.
|
|
63
|
-
cellfinder-1.
|
|
52
|
+
cellfinder/napari/train/train.py,sha256=zJY7zKcLqDTDtD76thmbwViEU4tTFCmXZze-zHsTpoo,5941
|
|
53
|
+
cellfinder/napari/train/train_containers.py,sha256=1wZ_GPe7B5XsLYs5XIx4m8GMw5KeVhg6SchhPtXu4V8,4386
|
|
54
|
+
cellfinder-1.3.0.dist-info/LICENSE,sha256=Tw8iMytIDXLSmcIUsbQmRWojstl9yOWsPCx6ZT6dZLY,1564
|
|
55
|
+
cellfinder-1.3.0.dist-info/METADATA,sha256=b40Zf7cFJV6nv3HxqXCtJubKshRQmXNpXaPx0vVrFtI,6528
|
|
56
|
+
cellfinder-1.3.0.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
|
|
57
|
+
cellfinder-1.3.0.dist-info/entry_points.txt,sha256=cKKjU8GPiN-TRelG2sT2JCKAcB9XDCjP6g9atE9pSoY,247
|
|
58
|
+
cellfinder-1.3.0.dist-info/top_level.txt,sha256=jyTQzX-tDjbsMr6s-E71Oy0IKQzmHTXSk4ZhpG5EDSE,11
|
|
59
|
+
cellfinder-1.3.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
|
cellfinder/core/tools/IO.py
DELETED
|
@@ -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
|
cellfinder/core/tools/tf.py
DELETED
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import tensorflow as tf
|
|
2
|
-
|
|
3
|
-
from cellfinder.core import logger
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
def allow_gpu_memory_growth():
|
|
7
|
-
"""
|
|
8
|
-
If a gpu is present, prevent tensorflow from using all the memory straight
|
|
9
|
-
away. Allows multiple processes to use the GPU (and avoid occasional
|
|
10
|
-
errors on some systems) at the cost of a slight performance penalty.
|
|
11
|
-
"""
|
|
12
|
-
gpus = tf.config.experimental.list_physical_devices("GPU")
|
|
13
|
-
if gpus:
|
|
14
|
-
logger.debug("Allowing GPU memory growth")
|
|
15
|
-
try:
|
|
16
|
-
# Currently, memory growth needs to be the same across GPUs
|
|
17
|
-
for gpu in gpus:
|
|
18
|
-
tf.config.experimental.set_memory_growth(gpu, True)
|
|
19
|
-
logical_gpus = tf.config.experimental.list_logical_devices("GPU")
|
|
20
|
-
logger.debug(
|
|
21
|
-
f"{len(gpus)} physical GPUs, {len(logical_gpus)} logical GPUs"
|
|
22
|
-
)
|
|
23
|
-
except RuntimeError as e:
|
|
24
|
-
# Memory growth must be set before GPUs have been initialized
|
|
25
|
-
print(e)
|
|
26
|
-
else:
|
|
27
|
-
logger.debug("No GPUs found, using CPU.")
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
def set_tf_threads(max_threads):
|
|
31
|
-
"""
|
|
32
|
-
Limit the number of threads that tensorflow uses
|
|
33
|
-
:param max_threads: Maximum number of threads to use
|
|
34
|
-
:return:
|
|
35
|
-
"""
|
|
36
|
-
logger.debug(
|
|
37
|
-
f"Setting maximum number of threads for tensorflow "
|
|
38
|
-
f"to: {max_threads}"
|
|
39
|
-
)
|
|
40
|
-
|
|
41
|
-
# If statements are for testing. If tf is initialised, then setting these
|
|
42
|
-
# parameters throws an error
|
|
43
|
-
if tf.config.threading.get_inter_op_parallelism_threads() != 0:
|
|
44
|
-
tf.config.threading.set_inter_op_parallelism_threads(max_threads)
|
|
45
|
-
if tf.config.threading.get_intra_op_parallelism_threads() != 0:
|
|
46
|
-
tf.config.threading.set_intra_op_parallelism_threads(max_threads)
|
|
Binary file
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|