pwspy.dataTypes.ExtraReflectanceCube

class pwspy.dataTypes.ExtraReflectanceCube(data, wavelengths, metadata)[source]

Bases: pwspy.dataTypes._data.ICBase

This class represents a 3D data cube of the extra reflectance in a PWS system.

Parameters
  • data (ndarray) – A 3D array of the extra reflectance in the system. It’s values are in units of reflectance (between 0 and 1).

  • wavelengths (Tuple[float, …]) – The wavelengths associated with each 2D slice along the 3rd axis of the data array.

  • metadata (ERMetaData) – Metadata

metadata

metadata

Type

ERMetaData

data

data

Type

ndarray

classmethod decodeHdf(d)

Load a new instance of ICBase from an h5py.Dataset

Parameters

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

Returns

(data: The 3D array of data, index: A tuple containing the index)

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.

Parameters
  • 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.

classmethod fromHdfDataset(d, filePath=None)[source]

Load the ExtraReflectanceCube from d, an HDF5 dataset.

Parameters
  • d (Dataset) – The h5py.Dataset to load the cube from.

  • filePath (Optional[str]) – The path to the HDF file that the dataset came from.

Return type

ExtraReflectanceCube

Returns

A new instance of ExtraReflectanceCube loaded from HDF.

classmethod fromHdfFile(directory, name)[source]

Load an ExtraReflectanceCube from an HDF5 file. name should be the file name, excluding the ‘_ExtraReflectance.h5’ suffix.

Parameters
  • directory (str) – The path to the folder containing the HDF file.

  • name (str) – The name that the cube was saved as.

Return type

ExtraReflectanceCube

Returns

A new instance of ExtraReflectanceCube loaded from HDF.

classmethod fromMetadata(md)[source]

Load an ExtraReflectanceCube from an ERMetaData object corresponding to an HDF5 file.

Parameters

md (ERMetaData) – The metadata to be used for loading the data file.

getMeanSpectra(mask=None)

Calculate the average spectra within a region of the data.

Parameters

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]

Returns

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

plotMean()
Return type

Tuple[Figure, Axes]

Returns

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)
Parameters
  • 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]

Returns

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.

Parameters

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

ndarray

Returns

An array of vertices of the polygon drawn.

selectRectangleROI(displayIndex=None)

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

Parameters

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.

Returns

An array of the 4 XY vertices of the rectangle.

Return type

np.ndarray

toHdfDataset(g)[source]

Save the ExtraReflectanceCube to an HDF5 dataset. g should be an h5py Group or File.

Parameters

g (Group) – The h5py.Group to save to.

Return type

Group

toHdfFile(directory, name)[source]

Save an ExtraReflectanceCube to an HDF5 file. The filename will be name with the ‘_ExtraReflectance.h5’ suffix.

Parameters
  • directory (str) – The path to the folder to save the HDF file to.

  • name (str) – The name that the cube should be saved as.

property index

Returns: The values of the datacube’s index

Return type

Tuple[float, …]

property wavelengths

Returns: The wavelengths corresponding to each element along the 3rd axis of self.data.

Return type

Tuple[float, …]