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 with HistogramPanel views. In addition to the behaviour provided by PlotProfile, the HistogramProfile implements the overlayRange mode, which allows the user to select the HistogramSeries.showOverlayRange, for the currently selected overlay, by clicking and dragging on the plot. This behaviour is only enabled when the HistogramSeries.showOverlay property True.

For each plotted HistogramSeries, the HistogramProfile class creates and manages a HistogramOverlay (which shows a 3D overlay of the voxels included in the histogram), and a RangePolygon (which shows the 3D overlay range on the plot). The user can click and drag on the plot to adjust the extent of the RangePolygon, which is linked to the mask Image managed by the HistogramOverlay.

__init__(viewPanel, overlayList, displayCtx)[source]

Create a HistogramProfile.

Parameters
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 a HistogramOverlay and a RangePolygon for the series.

__deregisterHistogramSeries(hs)

Called when a HistogramSeries is no longer to be plotted. Destroys the HistogramOverlay and RangePolygon associated with the series.

__selectedOverlayChanged(*a)

Called when the DisplayContext.selectedOverlay changes. Makes sure that a HistogramOverlay and RangePolygon exist for the newly selected overlay.

__updateShowOverlayRange(datax, which=False)

Called by the overlayRange mouse event handlers. Updates the HistogramSeries.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 a matplotlib.patches.Polygon which is used to display a data range over a HistogramSeries plot.

Whenever any property on the HistogramSeries changes (and on calls to updatePolygon()), the vertices of a polygon spanning the HistogramSeries.showOverlayRange property are generated.

The RangePolygon automatically adds and removes itself to the PlotPanel.artists list of the owning HistogramPanel according to the values of the HistogramSeries.showOverlay and DataSeries.enabled properties.

__init__(hs, hsPanel, *args, **kwargs)[source]

Create a RangePolygon.

Parameters

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() via idle.idle().

updatePolygon(*a, **kwa)[source]

Called whenever any property changes on the HistogramSeries, and called manually by the HistogramProfile.

Adds/removes this RangePolygon to the PlotPanel.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 a ProxyImage overlay which displays the voxels that are included in a histogram plot. The user can toggle the display of this overlay via the HistogramSeries.showOverlay property.

__init__(histSeries, overlay, displayCtx, overlayList)[source]

Create a HistogramOverlay.

Parameters
  • histSeries – The HistogramSeries instance which owns this HistobgramOverlay.

  • overlay – The Image overlay associated with this HistogramOverlay.

  • 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 the NiftiOpts.volume property (as Opts instances are destroyed/re-created when the overlayType 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, the HistogramSeries.showOverlay property is updated accordingly.

__showOverlayChanged(*args, **kwargs)

Called when the HistogramSeries.showOverlay property changes.

Adds/removes a 3D mask Image to the OverlayList, which highlights the voxels that have been included in the histogram. The MaskOpts.threshold property is bound to the HistogramSeries.showOverlayRange property, so the masked voxels are updated whenever the histogram overlay range changes, and vice versa.

Parameters

force – If True, and HistogramSeries.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>, '__annotations__': {}})
__module__ = 'fsleyes.profiles.histogramprofile'
__weakref__

list of weak references to the object (if defined)