Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
uschmidt83 committed Jul 29, 2021
2 parents 1cd2213 + b96c22e commit 53c14ea
Show file tree
Hide file tree
Showing 9 changed files with 29 additions and 14 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/cibuildwheel.yml
Expand Up @@ -43,7 +43,7 @@ jobs:
CIBW_BUILD: "cp3?-*"
CIBW_SKIP: "cp35-*"
# install fork of 'delocate' to work around bug
CIBW_BEFORE_BUILD: python -m pip install git+https://github.com/uschmidt83/delocate.git@patch-1
# CIBW_BEFORE_BUILD: python -m pip install git+https://github.com/uschmidt83/delocate.git@patch-1
# TODO: make it work for 10.9 (required libstdc++.dylib and libgomp.dylib from gcc compiled for 10.15)
MACOSX_DEPLOYMENT_TARGET: 10.15
CIBW_BUILD_VERBOSITY: 1
Expand Down
9 changes: 8 additions & 1 deletion .github/workflows/tests.yml
@@ -1,6 +1,13 @@
name: Test

on: [push, pull_request]
on:
push:
branches-ignore:
- wheels
pull_request:
branches:
- master
- dev

jobs:
test:
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
@@ -1,3 +1,3 @@
[build-system]
requires = ["setuptools>=40.8.0", "wheel", "numpy==1.19.3"]
requires = ["setuptools>=40.8.0", "wheel", "oldest-supported-numpy"]
build-backend = "setuptools.build_meta"
2 changes: 2 additions & 0 deletions setup.py
Expand Up @@ -97,6 +97,8 @@ def build_extension(self, ext):
'Topic :: Scientific/Engineering',
'License :: OSI Approved :: BSD License',

'Operating System :: OS Independent',

'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: 3.8',
Expand Down
8 changes: 5 additions & 3 deletions stardist/__init__.py
@@ -1,9 +1,11 @@
from __future__ import absolute_import, print_function

import warnings
import pathlib
def format_Warning(message, category, filename, lineno, line=''):
def format_warning(message, category, filename, lineno, line=''):
import pathlib
return f"{pathlib.Path(filename).name} ({lineno}): {message}\n"
warnings.formatwarning = format_Warning
warnings.formatwarning = format_warning
del warnings

from .version import __version__

Expand Down
8 changes: 4 additions & 4 deletions stardist/models/model2d.py
Expand Up @@ -59,18 +59,18 @@ def __getitem__(self, i):

X, Y = tuple(zip(*tuple(self.augmenter(_x, _y) for _x, _y in zip(X,Y))))


prob = np.stack([edt_prob(lbl[self.b][self.ss_grid[1:3]]) for lbl in Y])
# prob = np.stack([edt_prob(lbl[self.b]) for lbl in Y])
# prob = prob[self.ss_grid]

if self.shape_completion:
Y_cleared = [clear_border(lbl) for lbl in Y]
_dist = np.stack([star_dist(lbl,self.n_rays,mode=self.sd_mode)[self.b+(slice(None),)] for lbl in Y_cleared])
dist = dist[self.ss_grid]
_dist = np.stack([star_dist(lbl,self.n_rays,mode=self.sd_mode)[self.b+(slice(None),)] for lbl in Y_cleared])
dist = _dist[self.ss_grid]
dist_mask = np.stack([edt_prob(lbl[self.b][self.ss_grid[1:3]]) for lbl in Y_cleared])
else:
# directly subsample with grid
# directly subsample with grid
dist = np.stack([star_dist(lbl,self.n_rays,mode=self.sd_mode, grid=self.grid) for lbl in Y])
dist_mask = prob

Expand Down
3 changes: 2 additions & 1 deletion stardist/utils.py
Expand Up @@ -13,6 +13,7 @@
from skimage.measure import regionprops
from csbdeep.utils import _raise
from csbdeep.utils.six import Path
from collections.abc import Iterable

from .matching import matching_dataset, _check_label_array

Expand Down Expand Up @@ -178,7 +179,7 @@ def sample_points(n_samples, mask, prob=None, b=2):

def calculate_extents(lbl, func=np.median):
""" Aggregate bounding box sizes of objects in label images. """
if isinstance(lbl,(tuple,list)) or (isinstance(lbl,np.ndarray) and lbl.ndim==4):
if (isinstance(lbl,np.ndarray) and lbl.ndim==4) or (not isinstance(lbl,np.ndarray) and isinstance(lbl,Iterable)):
return func(np.stack([calculate_extents(_lbl,func) for _lbl in lbl], axis=0), axis=0)

n = lbl.ndim
Expand Down
2 changes: 1 addition & 1 deletion stardist/version.py
@@ -1 +1 @@
__version__ = '0.7.1'
__version__ = '0.7.2'
7 changes: 5 additions & 2 deletions tests/test_model2D.py
Expand Up @@ -113,13 +113,16 @@ def test_optimize_thresholds(model2d):
np.testing.assert_almost_equal(res["nms"] , 0.3, decimal=3)


def test_stardistdata(n_classes = None, classes = 1):
@pytest.mark.parametrize('n_classes, classes', [(None,(1,1)),(2,(1,2))])
@pytest.mark.parametrize('shape_completion',(False,True))
def test_stardistdata(shape_completion, n_classes, classes):
np.random.seed(42)
from stardist.models import StarDistData2D
img, mask = real_image2d()
s = StarDistData2D([img, img], [mask, mask],
grid = (2,2),
n_classes = n_classes, classes = (classes,classes),
n_classes = n_classes, classes = classes,
shape_completion = shape_completion, b = 8,
batch_size=1, patch_size=(30, 40), n_rays=32, length=1)
a, b = s[0]
return a,b, s
Expand Down

0 comments on commit 53c14ea

Please sign in to comment.