IntensityTable

class starfish.core.intensity_table.intensity_table.IntensityTable(data=<NA>, coords=None, dims=None, name=None, attrs=None, indexes=None, fastpath=False)[source]

IntensityTable is a container for spot or pixel features extracted from image data. It is the primary output from starfish SpotFinder methods.

An IntensityTable records the numeric intensity of a set of features in each (round, channel) tile in which the feature is identified. The IntensityTable has shape (n_feature, n_channel, n_round).

Some SpotFinder methods identify a position and search for Gaussian blobs in a small radius, only recording intensities if they are found in a given tile. Other :py:class:SpotFinder: approaches find blobs in a max-projection and measure them everywhere. As a result, some IntensityTables will be dense, and others will contain np.nan entries where no feature was detected.

Examples

Create an IntensityTable using the SyntheticData factory:

>>> from starfish.core.test.factories import SyntheticData
>>> sd = SyntheticData(n_ch=3, n_round=4, n_codes=2, n_spots=3)
>>> codes = sd.codebook()
>>> sd.intensities(codebook=codes)
<xarray.IntensityTable (features: 3, r: 4, c: 3)>
array([[[1., 0., 0.],
        [0., 1., 0.],
        [0., 0., 1.],
        [0., 1., 0.]],

       [[1., 0., 0.],
        [0., 1., 0.],
        [0., 0., 1.],
        [0., 1., 0.]],

       [[1., 0., 0.],
        [0., 1., 0.],
        [0., 0., 1.],
        [0., 1., 0.]]], dtype=float32)
Coordinates:
    z         (features) int64 8 6 2
    y         (features) float64 14.61 41.9 3.935
    x         (features) float64 11.0 42.42 5.249
    radius    (features) float64 nan nan nan
  * features  (features) int64 0 1 2
  * r         (r) int64 0 1 2 3
  * c         (c) int64 0 1 2
Attributes
has_physical_coords

Returns True if this table’s features have physical-space loci.

Methods

concatenate_intensity_tables(intensity_tables)

Parameters

from_image_stack(image_stack[, crop_x, …])

Generate an IntensityTable from all the pixels in the ImageStack

from_spot_data(intensities, spot_attributes, …)

Creates an IntensityTable from a (features, channel, round) array and a SpotAttributes object.

get_log()

Deserialize and return a list of pipeline components that have been applied throughout a starfish session to create this :py:class:IntensityTable:.

open_netcdf(filename)

Load an IntensityTable from Netcdf.

synthetic_intensities(codebook[, num_z, …])

Creates an IntensityTable with synthetic spots, that correspond to valid codes in a provided codebook.

to_features_dataframe()

Generates a dataframe of the underlying features metadata.

to_netcdf(filename)

Save an IntensityTable as a Netcdf File.

zeros(spot_attributes, round_labels, ch_labels)

Create an empty intensity table with pre-set shape whose values are zero.

static concatenate_intensity_tables(intensity_tables, overlap_strategy=None)[source]
Parameters
intensity_tables: List[IntensityTable]

List of IntensityTables to be combined.

overlap_strategy
Return type

IntensityTable

classmethod from_image_stack(image_stack, crop_x=0, crop_y=0, crop_z=0)[source]

Generate an IntensityTable from all the pixels in the ImageStack

Parameters
crop_xint

Number of pixels to crop from both top and bottom of x.

crop_yint

Number of pixels to crop from both top and bottom of y.

crop_zint

Number of pixels to crop from both top and bottom of z.

image_stackImageStack

ImageStack containing pixels to be treated as intensities.

Returns
IntensityTable :

IntensityTable containing one intensity per pixel (across channels and rounds).

Return type

IntensityTable

classmethod from_spot_data(intensities, spot_attributes, round_values, ch_values, *args, **kwargs)[source]

Creates an IntensityTable from a (features, channel, round) array and a SpotAttributes object.

Parameters
intensitiesxr.DataArray

Intensity data.

spot_attributesSpotAttributes

Table containing spot metadata. Must contain the values specified in Axes.X, Y, Z, and RADIUS.

ch_valuesSequence[int]

The possible values for the channel number, in the order that they are in the ImageStack 5D tensor.

round_valuesSequence[int]

The possible values for the round number, in the order that they are in the ImageStack

args :

Additional arguments to pass to the xarray constructor.

kwargs :

Additional keyword arguments to pass to the xarray constructor.

Returns
IntensityTable :

IntensityTable containing data from passed intensities, annotated by spot_attributes

Return type

IntensityTable

get_log()[source]

Deserialize and return a list of pipeline components that have been applied throughout a starfish session to create this :py:class:IntensityTable:.

property has_physical_coords

Returns True if this table’s features have physical-space loci.

classmethod open_netcdf(filename)[source]

Load an IntensityTable from Netcdf.

Parameters
filenamestr

File to load.

Returns
IntensityTable
Return type

IntensityTable

classmethod synthetic_intensities(codebook, num_z=12, height=50, width=40, n_spots=10, mean_fluor_per_spot=200, mean_photons_per_fluor=50)[source]

Creates an IntensityTable with synthetic spots, that correspond to valid codes in a provided codebook.

Parameters
codebookCodebook

Starfish codebook object.

num_zint

Number of z-planes to use when localizing spots.

heightint

y dimension of each synthetic plane.

widthint

x dimension of each synthetic plane.

n_spotsint

Number of spots to generate.

mean_fluor_per_spotint

Mean number of fluorophores per spot.

mean_photons_per_fluorint

Mean number of photons per fluorophore.

Returns
IntensityTable
Return type

IntensityTable

to_features_dataframe()[source]

Generates a dataframe of the underlying features metadata. This is guaranteed to contain the features x, y, z, and radius.

Returns
pd.DataFrame
Return type

DataFrame

to_netcdf(filename)[source]

Save an IntensityTable as a Netcdf File.

Parameters
filenamestr

Name of Netcdf file.

Return type

None

classmethod zeros(spot_attributes, round_labels, ch_labels)[source]

Create an empty intensity table with pre-set shape whose values are zero.

Parameters
spot_attributesSpotAttributes

Table containing spot metadata. Must contain the values specified in Axes.X, Y, Z, and RADIUS.

round_labelsSequence[int]

The possible values for the round number, in the order that they are in the ImageStack 5D tensor.

ch_labelsSequence[int]

The possible values for the channel number, in the order that they are in the ImageStack 5D tensor.

Returns
IntensityTable :

IntensityTable filled with zeros.

Return type

IntensityTable

starfish.core.intensity_table.intensity_table_coordinates.transfer_physical_coords_to_intensity_table(*, intensity_table, image_stack=None, spots=None)[source]

Transfers physical coordinates from either an Imagestack or SpotFindingResults to an intensity table

  1. Creates three new coords on the intensity table (xc, yc, zc)

  2. For every spot:
    • Get pixel x,y values

    • Calculate the physical x,y values

    • Assign those values to the coords arrays for this spot

Return type

IntensityTable