fsleyes.plotting.histogramseries¶
- This module provides the
HistogramSeries, ImageHistogramSeries,ComplexHistogramSeries, andMeshHistogramSeriesclasses, used by theHistogramPanelfor plotting histogram data.
Two standalone functions are also defined in this module:
-
class
fsleyes.plotting.histogramseries.HistogramSeries(overlay, overlayList, displayCtx, plotCanvas)[source]¶ Bases:
fsleyes.plotting.dataseries.DataSeriesA
HistogramSeriesgenerates histogram data from an overlay. It is the base class for theImageHistogramSeriessandMeshHistogramSeriesclasses.-
nbins= <MagicMock name='mock.Int()' id='4116300320'>¶ Number of bins to use in the histogram. This value is overridden by the
autoBinsetting.
-
autoBin= <MagicMock name='mock.Boolean()' id='4117273880'>¶ If
True, the number of bins used for eachHistogramSeriesis calculated automatically. Otherwise,HistogramSeries.nbinsbins are used.
-
ignoreZeros= <MagicMock name='mock.Boolean()' id='4117273880'>¶ If
True, zeros are excluded from the calculated histogram.
-
includeOutliers= <MagicMock name='mock.Boolean()' id='4117273880'>¶ If
True, values which are outside of thedataRangeare included in the histogram end bins.
-
dataRange= <MagicMock name='mock.Bounds()' id='4116394552'>¶ Specifies the range of data which should be included in the histogram. See the
includeOutliersproperty.
-
__init__(overlay, overlayList, displayCtx, plotCanvas)[source]¶ Create a
HistogramSeries.- Parameters
overlay – The overlay from which the data to be plotted is retrieved.
overlayList – The
OverlayListinstance.displayCtx – The
DisplayContextinstance.plotCanvas – The
HistogramPanelthat owns thisHistogramSeries.
-
destroy()[source]¶ This needs to be called when this
HistogramSeriesinstance is no longer being used.
-
setHistogramData(data, key)[source]¶ 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.
-
onDataRangeChange()[source]¶ May be implemented by sub-classes. Is called when the
dataRangechanges.
-
getData()[source]¶ Overrides
DataSeries.getData().Returns a tuple containing the
(x, y)histogram data.
-
property
binWidth¶ Returns the width of one bin for this
HistogramSeries.
-
getVertexData()[source]¶ 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.
-
property
numHistogramValues¶ Returns the number of values which were used in calculating the histogram.
-
__dataRangeChanged(*args, **kwargs)¶ Called when the
dataRangeproperty changes, and also by the__initProperties()and__volumeChanged()methods.
-
__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)[source]¶ Bases:
fsleyes.plotting.histogramseries.HistogramSeriesAn
ImageHistogramSeriesinstance manages generation of histogram data for anImageoverlay.-
showOverlay= <MagicMock name='mock.Boolean()' id='4117273880'>¶ 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='4116394552'>¶ Data range to display with the
showOverlaymask.
-
__init__(*args, **kwargs)[source]¶ Create an
ImageHistogramSeries. All arguments are passed through toHistogramSeries.__init__().
-
destroy()[source]¶ Must be called when this
ImageHistogramSeriesis no longer needed. Removes some property listeners, and callsHistogramSeries.destroy().
-
redrawProperties()[source]¶ Overrides
DataSeries.redrawProperties(). TheHistogramSeriesdata does not need to be re-plotted when theshowOverlayorshowOverlayRangeproperties change.
-
onDataRangeChange()[source]¶ Overrides
HistogramSeries.onDataRangeChange(). Makes sure that theshowOverlayRangelimits are synced to theHistogramSeries.dataRange.
-
__volumeChanged(*args, **kwargs)¶ Called when the
volumeproperty changes, and also by the__init__()method.Passes the data to the
HistogramSeries.setHistogramData()method.
-
__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.
-
__module__= 'fsleyes.plotting.histogramseries'¶
-
-
class
fsleyes.plotting.histogramseries.ComplexHistogramSeries(*args, **kwargs)[source]¶ Bases:
fsleyes.plotting.histogramseries.ImageHistogramSeriesThre
ComplexHistogramSeriesclass is a specialisation of theImageHistogramSeriesfor images with a complex data type.See also the
ComplexTimeSeriesandComplexPowerSpectrumSeriesclasses.-
plotReal= <MagicMock name='mock.Boolean()' id='4117273880'>¶
-
plotImaginary= <MagicMock name='mock.Boolean()' id='4117273880'>¶
-
plotMagnitude= <MagicMock name='mock.Boolean()' id='4117273880'>¶
-
plotPhase= <MagicMock name='mock.Boolean()' id='4117273880'>¶
-
__init__(*args, **kwargs)[source]¶ Create a
ComplexHistogramSeries. All arguments are passed through to theImageHistogramSeriesconstructor.
-
extraSeries()[source]¶ Returns a list containing an
ImaginaryHistogramSeries,MagnitudeHistogramSeries, and/orPhaseHistogramSeries, depending on the values of theplotImaginary,plotMagnitude, andplotPhaseproperties.
-
getData()[source]¶ Overrides
HistogramSeries.setHistogramData(). IfplotRealisFalse, returns(None, None). Otherwise returns the parent class implementation.
-
setHistogramData(data, key)[source]¶ Overrides
HistogramSeries.setHistogramData(). The real component of the data is passed to the parent class implementation.
-
__module__= 'fsleyes.plotting.histogramseries'¶
-
-
class
fsleyes.plotting.histogramseries.ImaginaryHistogramSeries(*args, **kwargs)[source]¶ Bases:
fsleyes.plotting.histogramseries.ImageHistogramSeriesClass which plots the histogram of the imaginary component of a complex-valued image.
-
setHistogramData(data, key)[source]¶ 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.
-
__module__= 'fsleyes.plotting.histogramseries'¶
-
-
class
fsleyes.plotting.histogramseries.MagnitudeHistogramSeries(*args, **kwargs)[source]¶ Bases:
fsleyes.plotting.histogramseries.ImageHistogramSeriesClass which plots the histogram of the magnitude of a complex-valued image.
-
setHistogramData(data, key)[source]¶ 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.
-
__module__= 'fsleyes.plotting.histogramseries'¶
-
-
class
fsleyes.plotting.histogramseries.PhaseHistogramSeries(*args, **kwargs)[source]¶ Bases:
fsleyes.plotting.histogramseries.ImageHistogramSeriesClass which plots the histogram of the phase of a complex-valued image.
-
setHistogramData(data, key)[source]¶ 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.
-
__module__= 'fsleyes.plotting.histogramseries'¶
-
-
class
fsleyes.plotting.histogramseries.MeshHistogramSeries(*args, **kwargs)[source]¶ Bases:
fsleyes.plotting.histogramseries.HistogramSeriesA
MeshHistogramSeriesinstance manages generation of histogram data for aMeshoverlay.-
__module__= 'fsleyes.plotting.histogramseries'¶
-
__init__(*args, **kwargs)[source]¶ Create a
MeshHistogramSeries. All arguments are passed through toHistogramSeries.__init__().
-
destroy()[source]¶ Must be called when this
MeshHistogramSeriesis no longer needed. CallsHistogramSeries.destroy()and removes some property listeners.
-
__vertexDataChanged(*a)¶ Called when the
MeshOpts.vertexDataorMeshOpts.vertexDataIndexproperties change. Updates the histogram data viaHistogramSeries.setHistogramData().
-
-
fsleyes.plotting.histogramseries.histogram(data, nbins, histRange, dataRange, includeOutliers=False, count=True)[source]¶ 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
xhistogram data (bin edges)The
yhistogram dataThe total number of values that were used in the histogram calculation
-
fsleyes.plotting.histogramseries.autoBin(data, dataRange)[source]¶ 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.