fsleyes.profiles.histogramprofile
¶
This module provides the HistogramProfile
class, an interaction
profile for the HistogramPanel
.
-
class
fsleyes.profiles.histogramprofile.
HistogramProfile
(viewPanel, overlayList, displayCtx)[source]¶ Bases:
fsleyes.profiles.plotprofile.PlotProfile
The
HistogramProfile
class is an interaction profile for use withHistogramPanel
views. In addition to the behaviour provided byPlotProfile
, theHistogramProfile
implements theoverlayRange
mode, which allows the user to select theHistogramSeries.showOverlayRange
, for the currently selected overlay, by clicking and dragging on the plot. This behaviour is only enabled when theHistogramSeries.showOverlay
propertyTrue
.For each plotted
HistogramSeries
, theHistogramProfile
class creates and manages aHistogramOverlay
(which shows a 3D overlay of the voxels included in the histogram), and aRangePolygon
(which shows the 3D overlay range on the plot). The user can click and drag on the plot to adjust the extent of theRangePolygon
, which is linked to the maskImage
managed by theHistogramOverlay
.-
__init__
(viewPanel, overlayList, displayCtx)[source]¶ Create a
HistogramProfile
.- Parameters
viewPanel – A
HistogramPanel
instance.overlayList – The
OverlayList
instance.displayCtx – The
DisplayContext
instance.
-
destroy
()[source]¶ Must be called when this
HistogramProfile
is no longer needed. Removes property listeners, and cleans some things up.
-
__overlayListChanged
(*a)¶ Called when the
OverlayList
changes. Cleans up some things related to overlays that are no longer in the list.
-
__registerHistogramSeries
(hs)¶ Called when a new
HistogramSeries
is plotted. Creates aHistogramOverlay
and aRangePolygon
for the series.
-
__deregisterHistogramSeries
(hs)¶ Called when a
HistogramSeries
is no longer to be plotted. Destroys theHistogramOverlay
andRangePolygon
associated with the series.
-
__selectedOverlayChanged
(*a)¶ Called when the
DisplayContext.selectedOverlay
changes. Makes sure that aHistogramOverlay
andRangePolygon
exist for the newly selected overlay.
-
__updateShowOverlayRange
(datax, which=False)¶ Called by the
overlayRange
mouse event handlers. Updates theHistogramSeries.showOverlayRange
.- Parameters
datax – X data coordinate corresponding to the mouse position.
which – Used to keep track of which value in the
showOverlayRange
property the user is currently modifying. On mouse down events, this method figures out which range should be modified, and returns either'lo'
or'hi'
. On subsequent calls to this method (on mouse drag and mouse up events), that return value should be passed back into this method so that the same value continues to get modified.
-
_overlayRangeModeLeftMouseDown
(ev, canvas, mousePos, canvasPos)[source]¶ Called on mouse down events in
overlayRange
mode. Calls the__updateShowOverlayRange()
method.
-
_overlayRangeModeLeftMouseDrag
(ev, canvas, mousePos, canvasPos)[source]¶ Called on mouse down events in
overlayRange
mode. Calls the__updateShowOverlayRange()
method.
-
_overlayRangeModeLeftMouseUp
(ev, canvas, mousePos, canvasPos)[source]¶ Called on mouse up events in
overlayRange
mode. Clears some internal state.
-
__module__
= 'fsleyes.profiles.histogramprofile'¶
-
-
class
fsleyes.profiles.histogramprofile.
RangePolygon
(hs, hsPanel, *args, **kwargs)[source]¶ Bases:
__main__.docbuilder.run.<locals>.MockClass
The
RangePolygon
class is amatplotlib.patches.Polygon
which is used to display a data range over aHistogramSeries
plot.Whenever any property on the
HistogramSeries
changes (and on calls toupdatePolygon()
), the vertices of a polygon spanning theHistogramSeries.showOverlayRange
property are generated.The
RangePolygon
automatically adds and removes itself to thePlotPanel.artists
list of the owningHistogramPanel
according to the values of theHistogramSeries.showOverlay
andDataSeries.enabled
properties.-
__init__
(hs, hsPanel, *args, **kwargs)[source]¶ Create a
RangePolygon
.- Parameters
hs – The
HistogramSeries
hsPanel – The
HistogramPanel
All other arguments are passed through to the
Polygon.__init__
method.
-
destroy
()[source]¶ Must be called when this
RangePolygon
is no longer needed.Removes property listeners and cleans up references.
-
asyncUpdatePolygon
(*a, **kwa)[source]¶ Asynchronously schedule
updatePolygon()
viaidle.idle()
.
-
updatePolygon
(*a, **kwa)[source]¶ Called whenever any property changes on the
HistogramSeries
, and called manually by theHistogramProfile
.Adds/removes this
RangePolygon
to thePlotPanel.artists
list and regenerates the polygon vertices as needed.
-
__module__
= 'fsleyes.profiles.histogramprofile'¶
-
-
class
fsleyes.profiles.histogramprofile.
HistogramOverlay
(histSeries, overlay, displayCtx, overlayList)[source]¶ Bases:
object
The
HistogramOverlay
class manages the creation, destruction, and display of aProxyImage
overlay which displays the voxels that are included in a histogram plot. The user can toggle the display of this overlay via theHistogramSeries.showOverlay
property.-
__init__
(histSeries, overlay, displayCtx, overlayList)[source]¶ Create a
HistogramOverlay
.- Parameters
histSeries – The
HistogramSeries
instance which owns thisHistobgramOverlay
.overlay – The
Image
overlay associated with thisHistogramOverlay
.displayCtx – The
DisplayContext
instance.overlayList – The
OverlayList
instance.
-
destroy
()[source]¶ Must be called when this
HistogramOverlay
is no longer needed. Removes property listeners and clears references.
-
__overlayTypeChanged
(*a)¶ Called when the
Display.overlayType
changes. De/re-registers a listener on theNiftiOpts.volume
property (asOpts
instances are destroyed/re-created when theoverlayType
changes).
-
__volumeChanged
(*a)¶ Called when the
NiftiOpts.volume
property changes. Makes sure that the 3d mask overlay is up to date (if it is being shown).
-
__overlayListChanged
(*a)¶ Called when the
OverlayList
changes.If a 3D mask overlay was being shown, and it has been removed from the
OverlayList
, theHistogramSeries.showOverlay
property is updated accordingly.
-
__showOverlayChanged
(*args, **kwargs)¶ Called when the
HistogramSeries.showOverlay
property changes.Adds/removes a 3D mask
Image
to theOverlayList
, which highlights the voxels that have been included in the histogram. TheMaskOpts.threshold
property is bound to theHistogramSeries.showOverlayRange
property, so the masked voxels are updated whenever the histogram overlay range changes, and vice versa.- Parameters
force – If
True
, andHistogramSeries.showOverlay is True
, the mask overlay is recreated even if one already exists.
-
__dict__
= mappingproxy({'__module__': 'fsleyes.profiles.histogramprofile', '__doc__': 'The ``HistogramOverlay`` class manages the creation, destruction, and\n display of a :class:`.ProxyImage` overlay which displays the voxels that\n are included in a histogram plot. The user can toggle the display of this\n overlay via the :attr:`.HistogramSeries.showOverlay` property.\n ', '__init__': <function HistogramOverlay.__init__>, 'destroy': <function HistogramOverlay.destroy>, '_HistogramOverlay__overlayTypeChanged': <function HistogramOverlay.__overlayTypeChanged>, '_HistogramOverlay__volumeChanged': <function HistogramOverlay.__volumeChanged>, '_HistogramOverlay__overlayListChanged': <function HistogramOverlay.__overlayListChanged>, '_HistogramOverlay__showOverlayChanged': <function HistogramOverlay.__showOverlayChanged>, '__dict__': <attribute '__dict__' of 'HistogramOverlay' objects>, '__weakref__': <attribute '__weakref__' of 'HistogramOverlay' objects>})¶
-
__module__
= 'fsleyes.profiles.histogramprofile'¶
-
__weakref__
¶ list of weak references to the object (if defined)
-