Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion continuous_integration/environment-3.10.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ dependencies:
- flake8==6.0.0
- pytest==7.2.2
- pytest-cov==4.0.0
- pytest-flake8==1.1.1
- pytest-flake8==1.3.0
- pytest-timeout >=2.3.1
- dask==2024.4.1
- numpy==1.24.2
Expand Down
2 changes: 1 addition & 1 deletion continuous_integration/environment-3.11.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ dependencies:
- flake8==6.0.0
- pytest==7.2.2
- pytest-cov==4.0.0
- pytest-flake8==1.1.1
- pytest-flake8==1.3.0
- pytest-timeout >=2.3.1
- dask==2024.4.1
- numpy==1.24.2
Expand Down
2 changes: 1 addition & 1 deletion continuous_integration/environment-3.12.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ dependencies:
- flake8==7.0.0
- pytest==8.2.0
- pytest-cov==5.0.0
- pytest-flake8==1.1.1
- pytest-flake8==1.3.0
- pytest-timeout >=2.3.1
- dask==2024.4.1
- numpy==1.26.4
Expand Down
4 changes: 2 additions & 2 deletions continuous_integration/environment-3.9.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ dependencies:
- flake8==7.0.0
- pytest==8.2.0
- pytest-cov==5.0.0
- pytest-flake8==1.1.1
- pytest-flake8==1.3.0
- pytest-timeout >=2.3.1
- dask==2024.4.1
- numpy==1.26.4
Expand All @@ -21,4 +21,4 @@ dependencies:
- pandas==2.2.2
- twine==5.0.0
- pip:
- build==1.2.1
- build==1.2.1
2 changes: 1 addition & 1 deletion dask_image/ndfilters/_generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def generic_filter(image,
depth = _utils._get_depth(footprint.shape, origin)
depth, boundary = _utils._get_depth_boundary(footprint.ndim, depth, "none")

if type(image._meta) == np.ndarray:
if type(image._meta) is np.ndarray:
kwargs = {"extra_arguments": extra_arguments,
"extra_keywords": extra_keywords}
else: # pragma: no cover
Expand Down
1 change: 0 additions & 1 deletion dask_image/ndfilters/_threshold.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import dask.array as da
import numpy as np

from ..dispatch._dispatch_ndfilters import dispatch_threshold_local_mean
Expand Down
2 changes: 0 additions & 2 deletions dask_image/ndfourier/_utils.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
# -*- coding: utf-8 -*-

import functools
import operator
import numbers

import dask.array as da
Expand Down
15 changes: 6 additions & 9 deletions dask_image/ndinterp/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,6 @@
)
from ..ndfilters._utils import _get_depth_boundary

from ..dispatch._dispatch_ndinterp import (dispatch_affine_transform,
dispatch_asarray)

__all__ = [
"affine_transform",
"rotate",
Expand Down Expand Up @@ -263,9 +260,9 @@ def rotate(
The array is rotated in the plane defined by the two axes given by the
`axes` parameter using spline interpolation of the requested order.

Chunkwise processing is performed using `dask_image.ndinterp.affine_transform`,
for which further parameters supported by the ndimage functions can be
passed as keyword arguments.
Chunkwise processing is performed using
`dask_image.ndinterp.affine_transform`, for which further parameters
supported by the ndimage functions can be passed as keyword arguments.

Notes
-----
Expand Down Expand Up @@ -386,10 +383,10 @@ def rotate(
matrix_nd = np.eye(ndim)
offset_nd = np.zeros(ndim)

for o_x,idx in enumerate(axes):
for o_x, idx in enumerate(axes):

matrix_nd[idx,axes[0]] = rot_matrix[o_x,0]
matrix_nd[idx,axes[1]] = rot_matrix[o_x,1]
matrix_nd[idx, axes[0]] = rot_matrix[o_x, 0]
matrix_nd[idx, axes[1]] = rot_matrix[o_x, 1]

offset_nd[idx] = offset[o_x]

Expand Down
21 changes: 15 additions & 6 deletions dask_image/ndmeasure/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,11 @@

from . import _utils
from ._utils import _label
from ._utils._find_objects import _array_chunk_location, _find_bounding_boxes, _find_objects
from ._utils._find_objects import (
_array_chunk_location,
_find_bounding_boxes,
_find_objects,
)

__all__ = [
"area",
Expand Down Expand Up @@ -242,12 +246,17 @@ def find_objects(label_image):
arrays.append(delayed(_find_bounding_boxes)(block, array_location))

bag = db.from_sequence(arrays)
result = bag.fold(functools.partial(_find_objects, label_image.ndim), split_every=2).to_delayed()
result = bag.fold(
functools.partial(_find_objects, label_image.ndim), split_every=2
).to_delayed()
meta = dd.utils.make_meta([(i, object) for i in range(label_image.ndim)])
result = delayed(compute)(result)[0] # avoid the user having to call compute twice on result
# avoid the user having to call compute twice on result
result = delayed(compute)(result)[0]

with dask_config.set({'dataframe.convert-string': False}):
result = dd.from_delayed(result, meta=meta, prefix="find-objects-", verify_meta=False)
result = dd.from_delayed(
result, meta=meta, prefix="find-objects-", verify_meta=False
)

return result

Expand Down Expand Up @@ -327,7 +336,8 @@ def label(image, structure=None, wrap_axes=None):
[0,1,0]]

wrap_axes : tuple of int, optional
Whether labels should be wrapped across array boundaries, and if so which axes.
Whether labels should be wrapped across array boundaries, and if so
which axes.
This feature is not present in `ndimage.label`.
Examples:
- (0,) only wrap across the 0th axis.
Expand Down Expand Up @@ -381,7 +391,6 @@ def label(image, structure=None, wrap_axes=None):
relabeled = _label.relabel_blocks(block_labeled, new_labeling)
n = da.max(relabeled)


return (relabeled, n)


Expand Down
10 changes: 8 additions & 2 deletions dask_image/ndmeasure/_utils/_find_objects.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,13 @@ def _find_bounding_boxes(x, array_location):
result = {}
for val in unique_vals:
positions = np.where(x == val)
slices = tuple(slice(np.min(pos) + array_location[i], np.max(pos) + 1 + array_location[i]) for i, pos in enumerate(positions))
slices = tuple(
slice(
np.min(pos) + array_location[i],
np.max(pos) + 1 + array_location[i]
)
for i, pos in enumerate(positions)
)
result[val] = slices
column_names = [i for i in range(x.ndim)] # column names are: 0, 1, ... nD
return pd.DataFrame.from_dict(result, orient='index', columns=column_names)
Expand All @@ -46,7 +52,7 @@ def _combine_slices(slices):


def _merge_bounding_boxes(x, ndim):
"""Merge the bounding boxes describing objects over multiple image chunks."""
"Merge the bounding boxes describing objects over multiple image chunks."
x = x.dropna()
data = {}
# For each dimension in the array,
Expand Down
13 changes: 8 additions & 5 deletions dask_image/ndmeasure/_utils/_label.py
Original file line number Diff line number Diff line change
Expand Up @@ -243,14 +243,17 @@ def _chunk_faces(chunks, shape, structure, wrap_axes=None):
for pos_structure_coord in np.array(np.where(structure)).T:

# only consider forward neighbors
if min(pos_structure_coord) < 1 or \
max(pos_structure_coord) < 2: continue
if min(pos_structure_coord) < 1 or max(pos_structure_coord) < 2:
continue

neigh_block = [curr_block[dim] + pos_structure_coord[dim] - 1
for dim in range(ndim)]
neigh_block = [
curr_block[dim] + pos_structure_coord[dim] - 1
for dim in range(ndim)
]

if max([neigh_block[dim] >= block_summary.shape[dim]
for dim in range(ndim)]): continue
for dim in range(ndim)]):
continue

# get current slice index
ind_curr_block = block_summary[tuple(curr_block)]
Expand Down
Loading
Loading