fsleyes.plotting.histogramseries
¶
- This module provides the
HistogramSeries
, ImageHistogramSeries
, andMeshHistogramSeries
classes, used by theHistogramPanel
for 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.DataSeries
A
HistogramSeries
generates histogram data from an overlay. It is the base class for theImageHistogramSeriess
andMeshHistogramSeries
classes.-
nbins
= <MagicMock name='mock.Int()' id='140736146715600'>¶ Number of bins to use in the histogram. This value is overridden by the
autoBin
setting.
-
autoBin
= <MagicMock name='mock.Boolean()' id='140736147064976'>¶ If
True
, the number of bins used for eachHistogramSeries
is calculated automatically. Otherwise,HistogramSeries.nbins
bins are used.
-
ignoreZeros
= <MagicMock name='mock.Boolean()' id='140736147064976'>¶ If
True
, zeros are excluded from the calculated histogram.
-
includeOutliers
= <MagicMock name='mock.Boolean()' id='140736147064976'>¶ If
True
, values which are outside of thedataRange
are included in the histogram end bins.
-
dataRange
= <MagicMock name='mock.Bounds()' id='140736144610832'>¶ Specifies the range of data which should be included in the histogram. See the
includeOutliers
property.
-
__init__
(overlay, overlayList, displayCtx, plotPanel)¶ Create a
HistogramSeries
.- Parameters
overlay – The overlay from which the data to be plotted is retrieved.
overlayList – The
OverlayList
instance.displayCtx – The
DisplayContext
instance.plotPanel – The
HistogramPanel
that owns thisHistogramSeries
.
-
destroy
()¶ This needs to be called when this
HistogramSeries
instance is no longer being used.
-
setHistogramData
(data, key)¶ Must be called by sub-classes whenever the underlying histogram data changes.
- Parameters
data – A
numpy
array containing the data that the histogram is to be calculated on. Pass inNone
to indicate that there is currently no histogram data.key – Something which identifies the
data
, and can be used as adict
key.
-
getData
()¶ Overrides
DataSeries.getData()
.Returns a tuple containing the
(x, y)
histogram data.
-
getVertexData
()¶ Returns a
numpy
array 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
dataRange
property 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.HistogramSeries
An
ImageHistogramSeries
instance manages generation of histogram data for anImage
overlay.-
showOverlay
= <MagicMock name='mock.Boolean()' id='140736147064976'>¶ If
True
, a maskProxyImage
overlay is added to theOverlayList
, which highlights the voxels that have been included in the histogram. The mask image is managed by theHistogramProfile
instance, which manages histogram plot interaction.
-
showOverlayRange
= <MagicMock name='mock.Bounds()' id='140736144610832'>¶ Data range to display with the
showOverlay
mask.
-
__init__
(*args, **kwargs)¶ Create an
ImageHistogramSeries
. All arguments are passed through toHistogramSeries.__init__()
.
-
destroy
()¶ Must be called when this
ImageHistogramSeries
is no longer needed. Removes some property listeners, and callsHistogramSeries.destroy()
.
-
redrawProperties
()¶ Overrides
DataSeries.redrawProperties()
. TheHistogramSeries
data does not need to be re-plotted when theshowOverlay
orshowOverlayRange
properties change.
-
onDataRangeChange
()¶ Overrides
HistogramSeries.onDataRangeChange()
. Makes sure that theshowOverlayRange
limits are synced to theHistogramSeries.dataRange
.
-
_ImageHistogramSeries__overlayTypeChanged
(*a)¶ Called when the
Display.overlayType
changes. When this happens, theDisplayOpts
instance 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
volume
property 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.HistogramSeries
A
MeshHistogramSeries
instance manages generation of histogram data for aMesh
overlay.-
_MeshHistogramSeries__vertexDataChanged
(*a)¶ Called when the
MeshOpts.vertexData
orMeshOpts.vertexDataIndex
properties 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
MeshHistogramSeries
is 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 dataincludeOutliers – 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
x
histogram data (bin edges)The
y
histogram dataThe 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.