impy.utils package

Submodules

impy.utils.axesop module

impy.utils.axesop.add_axes(axes: Axes, shape: tuple[int, ...], key: ndarray, key_axes='yx')[source]

Stack key to make its shape key_axes-> axes.

impy.utils.axesop.complement_axes(axes, all_axes='ptzcyx') list[Union[str, impy.axes._axis.Axis]][source]
impy.utils.axesop.find_first_appeared(axes, include='', exclude='')[source]
impy.utils.axesop.slice_axes(axes: Axes, key)[source]
impy.utils.axesop.switch_slice(axes, all_axes, ifin=None, ifnot=':')[source]

impy.utils.deco module

impy.utils.deco.check_input_and_output(func: Literal[None], *, inherit_label_info: bool = False, only_binary: bool = False, need_labels: bool = False) Callable[[Callable[_P, _R]], Callable[_P, _R]][source]
impy.utils.deco.check_input_and_output(func: Callable[_P, _R], *, inherit_label_info: bool = False, only_binary: bool = False, need_labels: bool = False) Callable[_P, _R]
impy.utils.deco.check_input_and_output_lazy(func: Callable[_P, _R], *, only_binary: bool = False) Callable[_P, _R][source]
impy.utils.deco.check_input_and_output_lazy(func: Literal[None], *, only_binary: bool = False) Callable[[Callable[_P, _R], Callable[_P, _R]]]
impy.utils.deco.dims_to_spatial_axes(func: Callable[_P, _R]) Callable[_P, _R][source]

Decorator to convert input dims to correct spatial axes. Compatible with ImgArray and LazyImgArray e.g.) dims=None (default) -> “yx” or “zyx” depend on the input image dims=2 -> “yx” dims=3 -> “zyx” dims=”ty” -> “ty”

impy.utils.deco.same_dtype(func: Callable[_P, _R], asfloat: bool = False) Callable[_P, _R][source]
impy.utils.deco.same_dtype(func: Literal[None], asfloat: bool = False) Callable[[Callable[_P, _R]], Callable[_P, _R]]

Decorator to assure output image has the same dtype as the input image. This decorator is compatible with both ImgArray and LazyImgArray.

Parameters:

asfloat (bool, optional) – If input image should be converted to float first, by default False

impy.utils.gauss module

class impy.utils.gauss.DiagonalGaussian(params=None)[source]

Bases: Gaussian

asdict() dict[str, Any][source]
fit(data: ndarray, method: str = 'Powell', mask: ndarray | None = None)[source]
generate(shape: tuple) ndarray[source]
property mu
property ndim
property params

Get flattened parameters.

rescale(scale: float)[source]
property sg
shift(dxdy)[source]
class impy.utils.gauss.Gaussian[source]

Bases: object

mu_inrange(low, high)[source]
sg_inrange(low, high)[source]
class impy.utils.gauss.GaussianBackground(params=None)[source]

Bases: DiagonalGaussian

class impy.utils.gauss.GaussianParticle(params=None, initial_sg=1)[source]

Bases: DiagonalGaussian

impy.utils.gauss.diagonal_gaussian(r, *params)[source]
impy.utils.gauss.masked_square(params, func, r, z, mask)[source]
impy.utils.gauss.square(params, func, r, z)[source]

calculate ||z - func(x, y, *params)||^2 where x and y are determine by z.shape

impy.utils.misc module

impy.utils.misc.check_nd(x: T, ndim: int) Sequence[T][source]
impy.utils.misc.largest_zeros(shape) ndarray[source]

impy.utils.slicer module

impy.utils.slicer.axis_targeted_slicing(axes: tuple[str, ...], string: str) Tuple[slice | int, ...][source]

Make a conventional slices from an axis-targeted slicing string.

Parameters:
  • ndim (int) – Number of dimension of the array which will be sliced.

  • axes (str) – Axes of input ndarray.

  • string (str) – Axis-targeted slicing string. If an axis that does not exist in axes is contained, this function will raise ValueError.

Return type:

slices

impy.utils.slicer.solve_slicer(key: Any, axes: Axes) Tuple[slice | int, ...][source]
impy.utils.slicer.str_to_slice(v: str) list[int] | slice | int[source]

impy.utils.utilcls module

class impy.utils.utilcls.ImportOnRequest(name: str)[source]

Bases: object

Module contents