Skip to content

Commit cd614b7

Browse files
aspect
1 parent 18ece33 commit cd614b7

File tree

5 files changed

+11
-14
lines changed

5 files changed

+11
-14
lines changed

src/.DS_Store

0 Bytes
Binary file not shown.

src/omnipose/__init__.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22
import os
33
import multiprocessing
44
os.environ['NUMEXPR_MAX_THREADS'] = str(multiprocessing.cpu_count())
5-
5+
# apparently there is another function in numexpr that can detect number of cores too
6+
# this might be a reason why loading takes so long
7+
# "and can increase import times for NumExpr or packages that import it such as Pandas or PyTables."
68

79
# controlled import to prevent MIP print statement
810
# import mip

src/omnipose/core.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1724,9 +1724,11 @@ def div_rescale(dP,mask,p=1):
17241724
dP *= div
17251725
return dP
17261726

1727+
from scipy.special import expit
17271728
def sigmoid(x):
17281729
"""The sigmoid function."""
1729-
return 1 / (1 + np.exp(-x))
1730+
expit(x) # this is the same as 1 / (1 + np.exp(-x))
1731+
# return 1 / (1 + np.exp(-x))
17301732

17311733
# def bd_rescale(dP,mask,bd):
17321734
# dP = dP.copy()

src/omnipose/misc.py

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
import torch
1212
import fastremap
1313

14+
from ncolor import unique_nonzero
15+
1416
def vector_to_arrow(vectors, flip_y: bool = False):
1517
"""
1618
Convert one or many 2-D vectors (in y,x order) into Unicode arrow glyphs.
@@ -62,16 +64,7 @@ def vector_to_arrow(vectors, flip_y: bool = False):
6264

6365
glyphs = [arrow_map.get(sig, '?') for sig in signs]
6466
return glyphs[0] if len(glyphs) == 1 else glyphs
65-
66-
def unique_nonzero(labels):
67-
"""
68-
Get unique nonzero labels
69-
"""
70-
# return np.sort(np.array(list(set(fastremap.unique(labels))-set((0,)))))
71-
if np.any(labels):
72-
return fastremap.unique(labels[labels > 0])
73-
else:
74-
return np.array([0])
67+
7568

7669

7770
def random_int(N, M=None, seed=None):

src/omnipose/plot.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,10 +86,10 @@ def _legend(self, *args, **kwargs):
8686
_Axes.legend = _legend
8787

8888

89-
def figure(nrow=None, ncol=None, **kwargs):
89+
def figure(nrow=None, ncol=None, aspect=1, **kwargs):
9090
figsize = kwargs.get('figsize', 2)
9191
if not isinstance(figsize, (list, tuple, np.ndarray)) and figsize is not None:
92-
figsize = (figsize, figsize)
92+
figsize = (figsize*aspect, figsize)
9393

9494
kwargs['figsize'] = figsize
9595
fig = Figure(**kwargs)

0 commit comments

Comments
 (0)