iss_preprocess.coppafish package

Submodules

iss_preprocess.coppafish.utils module

iss_preprocess.coppafish.utils.annulus(r0, r_xy) ndarray

Gets structuring element used to assess if spot isolated. :param r0: Inner radius within which values are all zero. :param r_xy: Outer radius in xy direction.

Can be float not integer because all values with radius < r_xy1 and > r0 will be set to 1.

Parameters:

r_z – Outer radius in z direction. Size in z-pixels. None means 2D annulus returned.

Returns:

int [2*floor(r_xy1)+1, 2*floor(r_xy1)+1, 2*floor(r_z1)+1].

Structuring element with each element either 0 or 1.

adapted from coppafish

iss_preprocess.coppafish.utils.ftrans2(b, t=None) ndarray

Produces a 2D convolve kernel that corresponds to the 1D convolve kernel, b, using the transform, t. Copied from [MATLAB ftrans2](https://www.mathworks.com/help/images/ref/ftrans2.html).

Parameters:
  • bfloat [Q]. 1D convolve kernel.

  • tfloat [M x N]. Transform to make b a 2D convolve kernel. If None, McClellan transform used.

Returns:

float [(M-1)*(Q-1)/2+1 x (N-1)*(Q-1)/2+1].

2D convolve kernel.

iss_preprocess.coppafish.utils.hanning_diff(r1: int, r2: int) ndarray

Gets difference of two hanning window 2D convolve kernel. Central positive, outer negative with sum of 0. :param r1: radius in pixels of central positive hanning convolve kernel. :param r2: radius in pixels of outer negative hanning convolve kernel.

Returns:

float [2*r2+1 x 2*r2+1].

Difference of two hanning window 2D convolve kernel.

iss_preprocess.coppafish.utils.scaled_k_means(x: ndarray, initial_cluster_mean: ndarray, score_thresh=0, min_cluster_size=10, n_iter=100)

Does a clustering that minimizes the norm of `x[i] - g[i] * cluster_mean[cluster_ind[i]]` for each data point `i` in `x`, where `g` is the gain which is not explicitly computed.

Parameters:
  • x`float [n_points x n_dims]`. Data set of vectors to build cluster means from.

  • initial_cluster_mean`float [n_clusters x n_dims]`. Starting point of mean cluster vectors.

  • score_threshfloat or give different score for each cluster as float [n_clusters] Scalar between `0` and `1`. Points in `x` with dot product to a cluster mean vector greater than this contribute to new estimate of mean vector.

  • min_cluster_size – If less than this many points assigned to a cluster, that cluster mean vector will be set to `0`.

  • n_iter – Maximum number of iterations performed.

Returns:

  • norm_cluster_mean - `float [n_clusters x n_dims]`.

    Final normalised mean cluster vectors.

  • cluster_eig_value - `float [n_clusters]`.

    First eigenvalue of outer product matrix for each cluster.

  • cluster_ind - `int [n_points]`.

    Index of cluster each point was assigned to. `-1` means fell below score_thresh and not assigned.

  • top_score - `float [n_points]`.

    top_score[i] is the dot product score between x[i] and norm_cluster_mean[cluster_ind[i]].

  • cluster_ind0 - `int [n_points]`.

    Index of cluster each point was assigned to on first iteration. `-1` means fell below score_thresh and not assigned.

  • top_score0 - `float [n_points]`.

    top_score0[i] is the dot product score between x[i] and initial_cluster_mean[cluster_ind0[i]].

Module contents