class pwspy.dataTypes.ICRawBase(data, index, metadata, processingStatus=None, dtype=<class 'numpy.float32'>)[source]

Bases: pwspy.dataTypes._data.ICBase, abc.ABC

This class represents data cubes which are not derived from other data cubes. They represent raw acquired data that exists as data files on the computer. For this reason they may need to have hardware specific corrections applied to them such as normalizing out exposure time, linearizing camera counts, subtracting dark counts, etc. The most important change is the addition of metadata.

  • data (np.ndarray) – A 3-dimensional array containing the data. The dimensions should be [Y, X, Z] where X and Y are the spatial coordinates of the image and Z corresponds to the index dimension, e.g. wavelength, wavenumber, time, etc.

  • index (tuple) – A tuple containing the values of the index for the data. This could be a tuple of wavelength values, times (in the case of Dynamics), etc.

  • metadata (pwsdtmd.MetaDataBase) – The metadata object associated with this data object.

  • processingStatus (ProcessingStatus) – An object that keeps track of which processing steps and corrections have been applied to this object.

  • dtype (type) – the data type that the data should be stored as. The default is numpy.float32.

class ProcessingStatus(cameraCorrected=False, normalizedByExposure=False, extraReflectionSubtracted=False, normalizedByReference=False)[source]

Bases: object

Keeps track of which processing steps have been applied to an ICRawBase object. By default none of these things have been done for raw data

classmethod fromDict(d)[source]
Return type


correctCameraEffects(correction=None, binning=None)[source]

Subtracts the darkcounts from the data. count is darkcounts per pixel. binning should be specified if it wasn’t saved in the micromanager metadata. Both method arguments should be able to be loaded automatically from the metadata but for older data files they will need to be supplied manually.

  • correction (Optional[CameraCorrection]) – The cameracorrection object providing information on how to correct the data.

  • binning (Optional[int]) – The binning that the raw data was imaged at. 2 = 2x2 binning, 3 = 3x3 binning, etc.

classmethod decodeHdf(d)[source]

Load a new instance of ICRawBase from an h5py.Dataset


d (h5py.Dataset) – The dataset that the ICBase has been saved to


data: The 3D array of data index: A tuple containing the index metadata: A dictionary containing metadata. procStatus: The processing status of the object.

Return type

A tuple containing

filterDust(sigma, pixelSize)

Blurs the data cube in the X and Y dimensions. Often used to remove the effects of dust on a normalization.

  • sigma (float) – This specifies the radius of the gaussian filter used for blurring. The units of the value are determined by pixelSize

  • pixelSize (float) – The pixel size in microns. Settings this to 1 will effectively causes sigma to be in units of pixels rather than microns.


Calculate the average spectra within a region of the data.


mask (Union[Roi, ndarray, None]) – An optional other.Roi or boolean numpy array used to select pixels from the X and Y dimensions of the data array. If left as None then the full data array will be used as the region.

Return type

Tuple[ndarray, ndarray]


The average spectra within the region, the standard deviation of the spectra within the region

abstract static getMetadataClass()[source]
Return type



The metadata class associated with this subclass of ICRawBase


This is one of the first steps in most analysis pipelines. Data is divided by the camera exposure. This way two ImCube that were acquired at different exposure times will still be on equivalent scales.

abstract normalizeByReference(reference)[source]

Normalize the raw data of this data cube by a reference cube to result in data representing arbitrarily scaled reflectance.


reference (ForwardRef) – A reference acquisition. Usually an image taken from a blank piece of glass.

performFullPreProcessing(reference, referenceMaterial, extraReflectance, cameraCorrection=None)[source]

Use the subtractExtraReflection, normalizeByReference, correctCameraEffects, and normalizeByExposure methods to perform the standard pre-processing that is done before analysis.

Note: This will also end up applying corrections to the reference data. If you want to perform pre-processing on a whole batch of data then you should implement your own script based on what is done here.

  • reference ('self.__class__') – A data cube to be used as a reference for normalization. Usually an image of a blank dish with cell media or air.

  • referenceMaterial (Material) – The material that was imaged in the reference dish. The theoretically expected reflectance will be calculated assuming a “Glass/{Material}” reflective interface.

  • extraReflectance (ExtraReflectanceCube) – The data cube containing system internal reflectance calibration information about the specific system configuration that the data was taken with.

Return type

Tuple[Figure, Axes]


A figure and attached axes plotting the mean of the data along the index axis.

corresponds to the mean reflectance in most cases.

selIndex(start, stop)
  • start (float) – The beginning value of the index in the new object.

  • stop (float) – The ending value of the index in the new object.

Return type

Tuple[ndarray, Sequence]


A new instance of ICBase with only data from start to stop in the index.

selectLassoROI(displayIndex=None, clim=None)

Allow the user to draw a freehand ROI on an image of the acquisition.


displayIndex (Optional[int]) – Display a particular z-slice of the array for mask drawing. If None then the mean along Z is displayed.

Return type



An array of vertices of the polygon drawn.


Allow the user to draw a rectangular ROI on an image of the acquisition.


displayIndex (int) – is used to display a particular z-slice for mask drawing. If None then the mean along Z is displayed. Returns an array of vertices of the rectangle.


An array of the 4 XY vertices of the rectangle.

Return type


abstract subtractExtraReflection(extraReflection)[source]

Subtract the portion of the signal that is due to internal reflections of the optical system from the data.


extraReflection (ExtraReflectionCube) – A calculated data cube indicating in units of camera counts how much of the data is from unwanted internal reflections of the system.

toHdfDataset(g, name, fixedPointCompression=True)[source]

Save this object into an HDF dataset.

  • g (Group) – The h5py.Group object to create a new dataset in.

  • name (str) – The name of the new dataset.

  • fixedPointCompression (bool) – If True then the data will be converted from floating point to 16-bit fixed point. This results in approximately half the storage requirements at a very slight loss in precision.

Return type



A reference to the h5py.Group passed in as g.

property index

Returns: The values of the datacube’s index

Return type

Tuple[float, …]