Skip to content

Commit

Permalink
deprecation and python3.9 compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
Fafa87 committed Aug 19, 2023
1 parent 9e6357c commit e0432aa
Show file tree
Hide file tree
Showing 71 changed files with 40 additions and 22 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/run_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
python-version: ["2.7", "3.8"]
python-version: ["2.7", "3.8", "3.9", "3.10"]

steps:
- uses: actions/checkout@v3
Expand Down
2 changes: 1 addition & 1 deletion cellstar/core/seeder.py
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ def __init__(self, size=10):
self._init_grid()

def _init_grid(self):
self._grid = np.empty((self._size_x, self._size_y), dtype=np.object)
self._grid = np.empty((self._size_x, self._size_y), dtype=object)
self._grid.fill([])

def _resize(self, to_x, to_y):
Expand Down
4 changes: 2 additions & 2 deletions cellstar/parameter_fitting/pf_snake.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@

random.seed(1) # make it deterministic
import numpy as np
import scipy.ndimage.morphology as morph
import scipy.ndimage.measurements as measure
import scipy.ndimage as morph
import scipy.ndimage as measure

from cellstar.utils.calc_util import to_int
from cellstar.core.seed import Seed
Expand Down
2 changes: 1 addition & 1 deletion cellstar/utils/calc_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def loop_connected_components(mask):

if mask.sum() > 0:
labeled = sp_image.label(mask)[0]
components = sp_image.measurements.find_objects(labeled)
components = sp_image.find_objects(labeled)
c_fin = [(s[0].stop - s[0].start, s[0].stop - 1) for s in components]
if len(c_fin) > 1 and mask[0] and mask[-1]:
c_fin[0] = c_fin[0][0] + c_fin[-1][0], c_fin[0][1]
Expand Down
10 changes: 5 additions & 5 deletions cellstar/utils/image_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,18 +86,18 @@ def image_dilate(image, radius):
contain_pixel(image.shape, (ys[1] + radius, xs[1] + radius))
ys, xs = (lp[0], hp[0]), (lp[1], hp[1])
morphology_element = get_circle_kernel(radius)
dilated_part = sp.ndimage.morphology.binary_dilation(image[ys[0]:ys[1], xs[0]:xs[1]], morphology_element)
dilated_part = sp.ndimage.binary_dilation(image[ys[0]:ys[1], xs[0]:xs[1]], morphology_element)
image[ys[0]:ys[1], xs[0]:xs[1]] = dilated_part
return image


def image_dilate_with_element(image, n):
return sp.ndimage.morphology.grey_dilation(image, size=(n, n))
return sp.ndimage.grey_dilation(image, size=(n, n))


def image_erode(image, radius):
morphology_element = get_circle_kernel(radius)
return sp.ndimage.morphology.binary_erosion(image, morphology_element)
return sp.ndimage.binary_erosion(image, morphology_element)


def fill_foreground_holes(mask, kernel_size, minimal_hole_size, min_cluster_area_scaled, mask_min_radius_scaled):
Expand Down Expand Up @@ -159,10 +159,10 @@ def fill_holes(mask, kernel_size, minimal_hole_size):
else:
# shrink components and check if they fell apart
# close holes
components_slice = sp.ndimage.morphology.binary_closing(components_slice, morphology_element)
components_slice = sp.ndimage.binary_closing(components_slice, morphology_element)

# erode holes
components_slice = sp.ndimage.morphology.binary_erosion(components_slice, morphology_element)
components_slice = sp.ndimage.binary_erosion(components_slice, morphology_element)

# don't invade masked pixels
components_slice &= np.logical_not(new_mask[slice])
Expand Down
8 changes: 0 additions & 8 deletions requirements.txt

This file was deleted.

6 changes: 6 additions & 0 deletions requirements_py27.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
numpy==1.16.6
scipy==1.2.3
pillow==6.2.2
matplotlib==2.2.5
imageio==2.6.1
pathlib
6 changes: 6 additions & 0 deletions requirements_py38.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
numpy==1.17.5
scipy==1.5.3
pillow==6.2.2
matplotlib==2.2.5
imageio==2.6.1
pathlib
6 changes: 6 additions & 0 deletions requirements_py39.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
numpy==1.23.1
scipy==1.9.0
pillow==9.2.0
matplotlib==3.2.2
imageio==2.21.1
pathlib
16 changes: 12 additions & 4 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,16 @@
if sys.version_info[0] == 2:
numpy_version = "numpy>=1.16"
scipy_version = "scipy>=1.2.3"
pillow_version = "pillow<=6.2.2"
matplotlib_version = "matplotlib<=2.2.5"
imageio_version = "imageio<=2.6.1"
else:
numpy_version = "numpy>=1.17,<=1.23.5"
scipy_version = "scipy>=1.5.3"
pillow_version = "pillow<=9.2"
matplotlib_version = "matplotlib>=3.2.2"
imageio_version = "imageio>=2.21.1"


with open("README.rst") as f:
long_description = f.read()
Expand Down Expand Up @@ -40,6 +47,7 @@ def run(self):
"Programming Language :: Python :: 2.7",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Topic :: Scientific/Engineering :: Bio-Informatics",
"Topic :: Scientific/Engineering :: Image Recognition",
"Topic :: Scientific/Engineering"
Expand All @@ -51,9 +59,9 @@ def run(self):
install_requires=[
numpy_version,
scipy_version,
"pillow<=6.2.2",
"matplotlib<=2.2.5",
"imageio<=2.6.1",
pillow_version,
matplotlib_version,
imageio_version,
"pathlib"
],
keywords=["brightfield", "yeast", "segmentation", "adapting"],
Expand All @@ -68,5 +76,5 @@ def run(self):
"pytest"
],
url="https://github.com/Fafa87/cellstar",
version="2.0.2"
version="2.0.3"
)
Binary file added tests/expected/rank_fitting/background.tif
Binary file not shown.
Binary file added tests/expected/rank_fitting/brighter.tif
Binary file not shown.
Binary file added tests/expected/rank_fitting/brighter_original.tif
Binary file not shown.
Binary file added tests/expected/rank_fitting/cell_border_mask.tif
Binary file not shown.
Binary file added tests/expected/rank_fitting/cell_content_mask.tif
Binary file not shown.
Binary file added tests/expected/rank_fitting/darker.tif
Binary file not shown.
Binary file added tests/expected/rank_fitting/darker_original.tif
Binary file not shown.
Binary file added tests/expected/rank_fitting/foreground_mask.tif
Binary file not shown.
Binary file not shown.
Binary file added tests/expected/rank_fitting/image_mask.tif
Binary file not shown.
Binary file added tests/expected/rank_fitting/seeds_0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tests/expected/rank_fitting/seeds_1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tests/expected/rank_fitting/seeds_2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tests/expected/rank_fitting/seeds_3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tests/expected/rank_fitting/seeds_4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tests/expected/rank_fitting/seeds_5.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tests/expected/rank_fitting/snakes_rainbow_1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tests/expected/rank_fitting/snakes_rainbow_2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tests/expected/rank_fitting/snakes_rainbow_3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tests/expected/rank_fitting/snakes_rainbow_4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tests/expected/rank_fitting/snakes_rainbow_5.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file modified tests/expected/sample_brightfield/brighter.tif
Binary file not shown.
Binary file not shown.
Binary file modified tests/expected/sample_brightfield/cell_border_mask.tif
Binary file not shown.
Binary file modified tests/expected/sample_brightfield/cell_content_mask.tif
Binary file not shown.
Binary file modified tests/expected/sample_brightfield/darker.tif
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified tests/expected/sample_brightfield/image_back_difference.tif
Binary file not shown.
Binary file added tests/expected/sample_brightfield/image_mask.tif
Binary file not shown.
Binary file added tests/expected/sample_brightfield/seeds_0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tests/expected/sample_brightfield/seeds_1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tests/expected/sample_brightfield/seeds_2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tests/expected/sample_brightfield/seeds_3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tests/expected/sample_brightfield/segmented.tif
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tests/expected/synthetic/background.tif
Binary file not shown.
Binary file modified tests/expected/synthetic/brighter.tif
Binary file not shown.
Binary file added tests/expected/synthetic/brighter_original.tif
Binary file not shown.
Binary file modified tests/expected/synthetic/cell_border_mask.tif
Binary file not shown.
Binary file modified tests/expected/synthetic/cell_content_mask.tif
Binary file not shown.
Binary file modified tests/expected/synthetic/darker.tif
Binary file not shown.
Binary file added tests/expected/synthetic/darker_original.tif
Binary file not shown.
Binary file added tests/expected/synthetic/foreground_mask.tif
Binary file not shown.
Binary file modified tests/expected/synthetic/image_back_difference.tif
Binary file not shown.
Binary file added tests/expected/synthetic/image_mask.tif
Binary file not shown.
Binary file added tests/expected/synthetic_3/background.tif
Binary file not shown.
Binary file modified tests/expected/synthetic_3/brighter.tif
Binary file not shown.
Binary file added tests/expected/synthetic_3/brighter_original.tif
Binary file not shown.
Binary file modified tests/expected/synthetic_3/cell_border_mask.tif
Binary file not shown.
Binary file modified tests/expected/synthetic_3/cell_content_mask.tif
Binary file not shown.
Binary file modified tests/expected/synthetic_3/darker.tif
Binary file not shown.
Binary file added tests/expected/synthetic_3/darker_original.tif
Binary file not shown.
Binary file added tests/expected/synthetic_3/foreground_mask.tif
Binary file not shown.
Binary file modified tests/expected/synthetic_3/image_back_difference.tif
Binary file not shown.
Binary file added tests/expected/synthetic_3/image_mask.tif
Binary file not shown.

0 comments on commit e0432aa

Please sign in to comment.