pykrait.visualization package#

Submodules#

pykrait.visualization.image_overlays module#

pykrait.visualization.image_overlays.compute_offset_lines(p1: Tuple[int, int], p2: Tuple[int, int], pixel_shift: int = 10) Tuple[Tuple[Tuple[int, int], Tuple[int, int]], Tuple[Tuple[int, int], Tuple[int, int]]][source]#

Computes two parallel lines offset by pixel_shift based on the points p1 and p2.

Returns the endpoints of the two offset lines: (p1_for, p2_for, p1_rev, p2_rev) where p1_for and p2_for are the endpoints of the line offset in the “forward” direction (perpendicular to the line from p1 to p2), and p1_rev and p2_rev are the endpoints of the line offset in the “reverse” direction.

Parameters:
  • p1 (tuple) – point 1 (x1, y1)

  • p2 (tuple) – point 2 (x2, y2)

  • pixel_shift (int, optional) – shift by which to separate the parallel lines, defaults to 10

Returns:

_description_

Return type:

Tuple[tuple, tuple, tuple, tuple]

pykrait.visualization.image_overlays.create_heatmap_image(masks: ndarray, peak_series: ndarray, cmap: str = 'magma', maxpeaks: int = 20, savepath: str = None) Figure[source]#

generates a heatmap for the underlying calcium video where each cell is colored according to its number of peaks.

Parameters:
  • masks (np.ndarray) – mask image

  • peak_series (np.ndarray) – peak series of shape T x n_rois where 1 denotes a peak

  • cmap (str, optional) – colormap to draw, defaults to “magma”

  • maxpeaks (int, optional) – upper bound for peak cutoff, defaults to 20

  • savepath (str, optional) – path where to save, defaults to None

Returns:

returns the matplotlib figure

Return type:

Figure

pykrait.visualization.image_overlays.create_synchronicity_image(tproj: ndarray, masks: ndarray, synchronous_peaks_matrix: ndarray, max_value: int = 7, pixel_shift: int = 15, savepath: str = None) Figure[source]#

_summary_

Parameters:
  • tproj (np.ndarray) – image to superimpose synchronicity traces on, typically the temporal projection of the calcium video

  • masks (np.ndarray) – mask image of the cell ROIs as label image

  • synchronous_peaks_matrix (np.ndarray) – matrix containing the number of synchronous peaks between each pair of cells

  • max_value (int, optional) – maximum value to display in the colormap, defaults to 6

  • pixel_shift (int, optional) – shift by which to separate the parallel lines, defaults to 15

  • savepath (str, optional) – path where to save the generated image, defaults to None

Returns:

the generated figure

Return type:

Figure

pykrait.visualization.image_overlays.draw_arrow(ax: Axes, p1: tuple[float, float], p2: tuple[float, float], color='k', lw: int = 1, mutation_scale: int = 10)[source]#

Robust, backend-safe arrow drawing. Avoids FancyArrowPatch (can crash under Qt/Agg).

Module contents#