Skip to content

Add porosity_threshold function to find percolation threshold #1091

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
Jun 24, 2025
178 changes: 0 additions & 178 deletions magnet_on_bentheimer.py

This file was deleted.

24 changes: 12 additions & 12 deletions src/porespy/filters/_funcs.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import scipy.ndimage as spim
from skimage.morphology import reconstruction
from skimage.segmentation import clear_border
from skimage.morphology import ball, disk, square, cube, diamond, octahedron

Check failure on line 10 in src/porespy/filters/_funcs.py

View workflow job for this annotation

GitHub Actions / ruff

Ruff (F401)

src/porespy/filters/_funcs.py:10:67: F401 `skimage.morphology.octahedron` imported but unused

Check failure on line 10 in src/porespy/filters/_funcs.py

View workflow job for this annotation

GitHub Actions / ruff

Ruff (F401)

src/porespy/filters/_funcs.py:10:58: F401 `skimage.morphology.diamond` imported but unused
from porespy.tools import (
_check_for_singleton_axes,
get_slices_grid,
Expand All @@ -16,7 +16,7 @@
extract_subsection,
ps_disk,
ps_ball,
ps_round,

Check failure on line 19 in src/porespy/filters/_funcs.py

View workflow job for this annotation

GitHub Actions / ruff

Ruff (F401)

src/porespy/filters/_funcs.py:19:5: F401 `porespy.tools.ps_round` imported but unused
get_tqdm,
get_edt,
)
Expand Down Expand Up @@ -282,7 +282,7 @@
im: npt.NDArray,
labels: npt.NDArray,
mode: Literal['maximum', 'minimum', 'median', 'mean', 'size',
'standard_deviations', 'variance'] = "max",

Check failure on line 285 in src/porespy/filters/_funcs.py

View workflow job for this annotation

GitHub Actions / ruff

Ruff (E241)

src/porespy/filters/_funcs.py:285:41: E241 Multiple spaces after comma
):
r"""
Floods/fills each region in an image with a single value based on the
Expand Down Expand Up @@ -688,21 +688,21 @@
then parallel processing does not occur. `2` is equivalent to
`[2, 2, 2]` for a 3D image. The number of cores used is specified in
`porespy.settings.ncores` and defaults to all cores.

parallel_kw : dict
Dictionary containing the settings for parallelization by chunking. The
optional settings include divs (scalar or list of scalars,
default = 1), overlap (scalar or list of scalars, unused in this func),
and cores (scalar, default is all available cores).

Divs is the number of times to divide the image for parallel
processing. If `1` then parallel processing does not occur. `2` is
equivalent to `[2, 2, 2]` for a 3D image.

Overlap is the amount of overlap to apply between chunks. In this
function, the overlap is controlled by the distance transform and
cannot be altered in any way.

Cores is the number of cores that will be used to parallel process all
domains. If ``None`` then all cores will be used but user can specify
any integer values to control the memory usage. Setting value to 1 will
Expand Down Expand Up @@ -865,21 +865,21 @@
equivalent to `[2, 2, 2]` for a 3D image. The number of cores
used is specified in `porespy.settings.ncores` and defaults to
all cores.

parallel_kw : dict
Dictionary containing the settings for parallelization by chunking. The
optional settings include divs (scalar or list of scalars,
default = 1), overlap (scalar or list of scalars, unused in this func),
and cores (scalar, default is all available cores).

Divs is the number of times to divide the image for parallel
processing. If `1` then parallel processing does not occur. `2` is
equivalent to `[2, 2, 2]` for a 3D image.

Overlap is the amount of overlap to apply between chunks. In this
function, the overlap is controlled by the distance transform and
cannot be altered in any way.

Cores is the number of cores that will be used to parallel process all
domains. If ``None`` then all cores will be used but user can specify
any integer values to control the memory usage. Setting value to 1 will
Expand Down Expand Up @@ -1200,7 +1200,7 @@

def chunked_func(
func,
parallel_kw = {"divs": 2, "overlap": None, "cores": None},

Check failure on line 1203 in src/porespy/filters/_funcs.py

View workflow job for this annotation

GitHub Actions / ruff

Ruff (E251)

src/porespy/filters/_funcs.py:1203:18: E251 Unexpected spaces around keyword / parameter equals

Check failure on line 1203 in src/porespy/filters/_funcs.py

View workflow job for this annotation

GitHub Actions / ruff

Ruff (E251)

src/porespy/filters/_funcs.py:1203:16: E251 Unexpected spaces around keyword / parameter equals
im_arg=["input", "image", "im"],
strel_arg=["strel", "structure", "footprint"],
**kwargs,
Expand All @@ -1221,23 +1221,23 @@
func : function handle
The function which should be applied to each chunk, such as
`spipy.ndimage.binary_dilation`.

parallel_kw : dict
Dictionary containing the settings for parallelization by chunking. The
optional settings include divs (scalar or list of scalars,
default = [2, 2, 2]), overlap (scalar or list of scalars, optional),
and cores (scalar, default is all available cores).

Divs is the number of times to divide the image for parallel
processing. If `1` then parallel processing does not occur. `2` is
equivalent to `[2, 2, 2]` for a 3D image.

Overlap is the amount of overlap to include when dividing up the image.
This value will almost always be the size (i.e. raduis) of the
structuring element. If not specified then the amount of overlap
is inferred from the size of the structuring element, in which
case the `strel_arg` must be specified.

Cores is the number of cores that will be used to parallel process all
domains. If ``None`` then all cores will be used but user can specify
any integer values to control the memory usage. Setting value to 1 will
Expand Down
Loading
Loading