paprica.viewer

Module containing classes and functions relative to Viewing.

By using this code you agree to the terms of the software license agreement.

© Copyright 2020 Wyss Center for Bio and Neuro Engineering – All rights reserved

paprica.viewer.apr_to_napari_Image(apr: _pyaprwrapper.data_containers.APR, parts: (<class '_pyaprwrapper.data_containers.ShortParticles'>, <class '_pyaprwrapper.data_containers.FloatParticles'>), mode: str = 'constant', level_delta: int = 0, **kwargs)[source]

Construct a napari ‘Image’ layer from an APR. Pixel values are reconstructed on the fly via the APRSlicer class.

Parameters
  • apr (pyapr.APR) – Input APR data structure

  • parts (pyapr.FloatParticles or pyapr.ShortParticles) – Input particle intensities

  • mode (str (default: 'constant')) –

    Interpolation mode to reconstruct pixel values. Supported values are

    constant: piecewise constant interpolation smooth: smooth interpolation (via level-adaptive separable smoothing). Note: significantly slower than constant. level: interpolate the particle levels to the pixels

  • level_delta (int) – Sets the resolution of the reconstruction. The size of the image domain is multiplied by a factor of 2**level_delta. Thus, a value of 0 corresponds to the original pixel image resolution, -1 halves the resolution and +1 doubles it. (default: 0)

Returns

out – An Image layer of the APR that can be viewed in napari.

Return type

napari.layers.Image

paprica.viewer.apr_to_napari_Labels(apr: _pyaprwrapper.data_containers.APR, parts: _pyaprwrapper.data_containers.ShortParticles, mode: str = 'constant', level_delta: int = 0, **kwargs)[source]

Construct a napari ‘Layers’ layer from an APR. Pixel values are reconstructed on the fly via the APRSlicer class.

Parameters
  • apr (pyapr.APR) – Input APR data structure

  • parts (pyapr.FloatParticles or pyapr.ShortParticles) – Input particle intensities

  • mode (str (default: 'constant')) –

    Interpolation mode to reconstruct pixel values. Supported values are

    constant: piecewise constant interpolation smooth: smooth interpolation (via level-adaptive separable smoothing). Note: significantly slower than constant. level: interpolate the particle levels to the pixels

  • level_delta (int) – Sets the resolution of the reconstruction. The size of the image domain is multiplied by a factor of 2**level_delta. Thus, a value of 0 corresponds to the original pixel image resolution, -1 halves the resolution and +1 doubles it. (default: 0)

Returns

out – A Labels layer of the APR that can be viewed in napari.

Return type

napari.layers.Image

paprica.viewer.compare_stitching(stitcher1, stitcher2, loc=None, n_proj=0, dim=0, downsample=2, color=False, rel_map=False)[source]

Compare two stitching at a given position loc for a given dimension dim.

Parameters
  • stitcher1 (tileStitcher) – stitcher object 1

  • stitcher2 (tileStitcher) – stitcher object 2

  • loc (int) – position in the given dimension

  • dim (int) – dimension to use for comparison

  • n_proj (int) – number of plane to perform the max-projection

  • downsample (int) – downsampling factor for the reconstruction

  • color (bool) – option to display in color

  • rel_map (bool) – overlay reliability map on the reconstructed data

Return type

None

paprica.viewer.display_apr(apr, parts, **kwargs)[source]

Display an APR using Napari from previously loaded data.

Parameters
  • apr (pyapr.APR) – Input APR data structure

  • parts (pyapr.FloatParticles, pyapr.ShortParticles) – Input particle intensities

  • kwargs (dict) – optional parameters for Napari

Return type

None

paprica.viewer.display_apr_from_path(path, **kwargs)[source]

Display an APR using Napari from a filepath.

Parameters
  • path (string) – path to APR to be displayed

  • kwargs (dict) – optional parameters for Napari

Return type

None

paprica.viewer.display_heatmap(heatmap, atlas=None, data=None, log=False)[source]

Display a heatmap (e.g. cell density) that can be overlaid on intensity data and atlas.

Parameters
  • heatmap (ndarray) – array containing the heatmap to be displayed

  • atlas (ndarray) – array containing the atlas which will be automatically scaled to the heatmap

  • data (ndarray) – array containing the data.

  • log (bool) – plot in logscale (only used for 2D).

Return type

None

paprica.viewer.display_layers(layers)[source]

Display a list of layers using Napari.

Parameters

layers (list[napari.Layer]) – list of layers to display

Returns

viewer – napari viewer.

Return type

napari.Viewer

paprica.viewer.display_layers_pyramidal(layers, level_delta)[source]

Display a list of layers using Napari.

Parameters

layers (list[napari.Layer]) – list of layers to display

Returns

viewer – napari viewer.

Return type

napari.Viewer

paprica.viewer.display_segmentation(apr, parts, mask, pyramidal=True, **kwargs)[source]

This function displays an image and its associated segmentation map. It uses napari to lazily generate the pixel data from APR on the fly.

Parameters
  • apr (pyapr.APR) – apr object

  • parts (pyapr.ParticleData) – particle object representing the image

  • mask (pyapr.ParticleData) – particle object representing the segmentation mask/connected component

Return type

None

paprica.viewer.reconstruct_colored_projection(apr, parts, loc=None, dim=0, n_proj=0, downsample=1, threshold=None, plot=True)[source]

Compare two stitching at a given position loc for a given dimension dim.

Parameters
  • apr (pyapr.APR) – apr tree object

  • parts (pyapr.ParticleData) – apr particles

  • loc (int) – position in the given dimension

  • dim (int) – dimension to use for comparison

  • n_proj (int) – number of plane to perform the max-projection

  • downsample (int) – downsampling factor for the reconstruction

  • color (bool) – option to display in color

  • rel_map (bool) – overlay reliability map on the reconstructed data

Return type

None

paprica.viewer.resolution_callback(viewer, value)[source]
class paprica.viewer.tileViewer(tiles, database, segmentation: bool = False, cells=None, atlaser=None)[source]

Bases: object

Class to display the registration and segmentation using Napari.

__init__(tiles, database, segmentation: bool = False, cells=None, atlaser=None)[source]
Parameters
  • tiles (tileParser) – tileParser object containing the dataset to be displayed.

  • database ((pd.Dataframe, string, tileStitcher)) – database containing the tile positions.

  • segmentation (bool) – option to also display the segmentation (connected component) data.

  • cells (ndarray) – cells center to be displayed.

  • atlaser (tileAtlaser) – tileAtlaser object containing the Atlas to be displayed.

_get_tile_position(row, col)[source]

Parse tile position in the database.

_is_tile_loaded(row, col)[source]

Returns True is tile is loaded, False otherwise.

_load_tile(row, col)[source]

Load the tile at position [row, col].

check_stitching(downsample=8, color=False, **kwargs)[source]

Function to display the stitched dataset using napari.

Parameters
  • downsample (int) – downsampling parameter for APRSlicer (1: full resolution, 2: 2x downsampling, 4: 4x downsampling..etc)

  • color (bool) – option to display in color

  • kwargs (dict) – dictionary passed to Napari for custom option

Return type

None

display_all_tiles(pyramidal=True, downsample=1, color=False, **kwargs)[source]

Display all parsed tiles.

Parameters
  • pyramidal (bool) – option to have a slider that controls the displayed resolution

  • downsample (int) – downsampling parameter for APRSlicer (1: full resolution, 2: 2x downsampling, 4: 4x downsampling..etc)

  • kwargs (dict) – dictionary passed to Napari for custom option

Return type

None

display_tiles(coords, pyramidal=True, downsample=1, color=False, **kwargs)[source]

Display tiles at position coords.

Parameters
  • coords (list) – list of tuples (row, col) containing the tile coordinate to display.

  • downsample (int) – downsampling parameter for APRSlicer (1: full resolution, 2: 2x downsampling, 4: 4x downsampling..etc)

  • kwargs (dict) – dictionary passed to Napari for custom option

  • color (bool) – option to display in color

Return type

None

get_layers_all_tiles(downsample=1, **kwargs)[source]

Display all parsed tiles.

Parameters
  • downsample (int) – downsampling parameter for APRSlicer (1: full resolution, 2: 2x downsampling, 4: 4x downsampling..etc)

  • kwargs (dict) – dictionary passed to Napari for custom option

Returns

layers – list of layers to be displayed by Napari

Return type

list[napari.Layer]