fsleyes.plotting.histogramseries¶
- This module provides the
HistogramSeries, ImageHistogramSeries, andMeshHistogramSeriesclasses, used by theHistogramPanelfor plotting histogram data.
Two standalone functions are also defined in this module:
-
class
fsleyes.plotting.histogramseries.HistogramSeries(overlay, overlayList, displayCtx, plotPanel)¶ Bases:
fsleyes.plotting.dataseries.DataSeriesA
HistogramSeriesgenerates histogram data from an overlay. It is the base class for theImageHistogramSeriessandMeshHistogramSeriesclasses.-
nbins= <MagicMock name='mock.Int()' id='139845843069248'>¶ Number of bins to use in the histogram. This value is overridden by the
autoBinsetting.
-
autoBin= <MagicMock name='mock.Boolean()' id='139845844115072'>¶ If
True, the number of bins used for eachHistogramSeriesis calculated automatically. Otherwise,HistogramSeries.nbinsbins are used.
-
ignoreZeros= <MagicMock name='mock.Boolean()' id='139845844115072'>¶ If
True, zeros are excluded from the calculated histogram.
-
includeOutliers= <MagicMock name='mock.Boolean()' id='139845844115072'>¶ If
True, values which are outside of thedataRangeare included in the histogram end bins.
-
dataRange= <MagicMock name='mock.Bounds()' id='139845843098144'>¶ Specifies the range of data which should be included in the histogram. See the
includeOutliersproperty.
-
__init__(overlay, overlayList, displayCtx, plotPanel)¶ Create a
HistogramSeries.Parameters: - overlay – The overlay from which the data to be plotted is retrieved.
- overlayList – The
OverlayListinstance. - displayCtx – The
DisplayContextinstance. - plotPanel – The
HistogramPanelthat owns thisHistogramSeries.
-
destroy()¶ This needs to be called when this
HistogramSeriesinstance is no longer being used.
-
setHistogramData(data, key)¶ Must be called by sub-classes whenever the underlying histogram data changes.
Parameters: - data – A
numpyarray containing the data that the histogram is to be calculated on. Pass inNoneto indicate that there is currently no histogram data. - key – Something which identifies the
data, and can be used as adictkey.
- data – A
-
getData()¶ Overrides
DataSeries.getData().Returns a tuple containing the
(x, y)histogram data.
-
getVertexData()¶ Returns a
numpyarray of shape(N, 2), which contains a set of “vertices” which can be used to display the histogram data as a filled polygon.
-
getNumHistogramValues()¶ Returns the number of values which were used in calculating the histogram.
-
_HistogramSeries__dataRangeChanged(*args, **kwargs)¶ Called when the
dataRangeproperty changes, and also by the__initProperties()and__volumeChanged()methods.
-
_HistogramSeries__histPropsChanged(*a)¶ Called internally, and when any histogram settings change. Re-calculates the histogram data.
-
__module__= 'fsleyes.plotting.histogramseries'¶
-
-
class
fsleyes.plotting.histogramseries.ImageHistogramSeries(*args, **kwargs)¶ Bases:
fsleyes.plotting.histogramseries.HistogramSeriesAn
ImageHistogramSeriesinstance manages generation of histogram data for anImageoverlay.-
showOverlay= <MagicMock name='mock.Boolean()' id='139845844115072'>¶ If
True, a maskProxyImageoverlay is added to theOverlayList, which highlights the voxels that have been included in the histogram. The mask image is managed by theHistogramProfileinstance, which manages histogram plot interaction.
-
showOverlayRange= <MagicMock name='mock.Bounds()' id='139845843098144'>¶ Data range to display with the
showOverlaymask.
-
__init__(*args, **kwargs)¶ Create an
ImageHistogramSeries. All arguments are passed through toHistogramSeries.__init__().
-
destroy()¶ Must be called when this
ImageHistogramSeriesis no longer needed. Removes some property listeners, and callsHistogramSeries.destroy().
-
redrawProperties()¶ Overrides
DataSeries.redrawProperties(). TheHistogramSeriesdata does not need to be re-plotted when theshowOverlayorshowOverlayRangeproperties change.
-
onDataRangeChange()¶ Overrides
HistogramSeries.onDataRangeChange(). Makes sure that theshowOverlayRangelimits are synced to theHistogramSeries.dataRange.
-
_ImageHistogramSeries__overlayTypeChanged(*a)¶ Called when the
Display.overlayTypechanges. When this happens, theDisplayOptsinstance associated with the overlay gets destroyed and recreated. This method de-registers and re-registers property listeners as needed.
-
_ImageHistogramSeries__volumeChanged(*args, **kwargs)¶ Called when the
volumeproperty changes, and also by the__init__()method.Passes the data to the
HistogramSeries.setHistogramData()method.
-
__module__= 'fsleyes.plotting.histogramseries'¶
-
-
class
fsleyes.plotting.histogramseries.MeshHistogramSeries(*args, **kwargs)¶ Bases:
fsleyes.plotting.histogramseries.HistogramSeriesA
MeshHistogramSeriesinstance manages generation of histogram data for aMeshoverlay.-
_MeshHistogramSeries__vertexDataChanged(*a)¶ Called when the
MeshOpts.vertexDataorMeshOpts.vertexDataIndexproperties change. Updates the histogram data viaHistogramSeries.setHistogramData().
-
__module__= 'fsleyes.plotting.histogramseries'¶
-
__init__(*args, **kwargs)¶ Create a
MeshHistogramSeries. All arguments are passed through toHistogramSeries.__init__().
-
destroy()¶ Must be called when this
MeshHistogramSeriesis no longer needed. CallsHistogramSeries.destroy()and removes some property listeners.
-
-
fsleyes.plotting.histogramseries.histogram(data, nbins, histRange, dataRange, includeOutliers=False, count=True)¶ Calculates a histogram of the given
data.Parameters: - data – The data to calculate a histogram foe
- nbins – Number of bins to use
- histRange – Tuple containing the
(low, high)data range that the histogram is to be calculated on. - dataRange – Tuple containing the
(min, max)range of values in the data - includeOutliers – If
True, the outermost bins will contain counts for values which are outside thehistRange. Defaults toFalse. - count – If
True(the default), the raw histogram counts are returned. Otherwise they are converted into probabilities.
Returns: A tuple containing:
- The
xhistogram data (bin edges) - The
yhistogram data - The total number of values that were used in the histogram calculation
-
fsleyes.plotting.histogramseries.autoBin(data, dataRange)¶ Calculates the number of bins which should be used for a histogram of the given data. The calculation is identical to that implemented in the original FSLView.
Parameters: - data – The data that the histogram is to be calculated on.
- dataRange – A tuple containing the
(min, max)histogram range.