fsleyes.plugins.tools.sampleline

This module provides the SampleLineAction class, which allows the user to open a SampleLinePanel. The SampleLinePanel is a FSLeyes control which allows the user to draw a line on the canvases of an OrthoPanel, and plot the data along that line from the currently selected Image overlay.

fsleyes.plugins.tools.sampleline.sampleAlongLine(data, start, end, resolution, order)[source]

Samples from data, along a line between start and end.

Parameters
  • data – 3D array

  • start – Start coordinate

  • end – End coordinate

  • resolution – Number of points to sample

  • order – Interpolation (see scipy.ndimage.map_coordinates)

Returns

Tuple containing: - 1D Numpy array containing the sampled values - (3, N) numpy array containing the coordinates for

each sample

class fsleyes.plugins.tools.sampleline.SampleLineAction(overlayList, displayCtx, ortho)[source]

Bases: fsleyes.actions.togglecontrolpanel.ToggleControlPanelAction

The SampleLineAction simply shows/hides a SampleLinePanel.

static supportedViews()[source]

The SampleLineAction is restricted for use with OrthoPanel views.

__init__(overlayList, displayCtx, ortho)[source]

Create a SampleLineAction.

destroy()[source]

Called when the OrthoPanel that owns this action is closed. Clears references, removes listeners, and calls the base class destroy method.

__selectedOverlayChanged(*a)

Called when the selected overlay changes. Enables/disables this action (and hence the bound Tools menu item) depending on whether the overlay is an image.

__run()

Open/close a SampleLinePanel.

__module__ = 'fsleyes.plugins.tools.sampleline'
class fsleyes.plugins.tools.sampleline.SampleLineDataSeries(overlay, overlayList, displayCtx, plotCanvas, index, start, end)[source]

Bases: fsleyes.plotting.dataseries.DataSeries

The SampleLineDataSeries represents data that is sampled along a straight line through a 3D volume from an Image overlay.

SampleLineDataSeries objects are created by the SampleLinePanel.

interp = <MagicMock name='mock.Choice()' id='4117029600'>

How to interpolate the sampled data when it is plotted. The value is used directly as the order parameter to the scipy.ndimage.map_coordinates function.

resolution = <MagicMock name='mock.Int()' id='4116300320'>

The number of points (uniformly spaced) to sample along the line.

normalise = <MagicMock name='mock.Choice()' id='4117029600'>

Whether to normalise all plotted data along the x, or y, or both, axes.

__init__(overlay, overlayList, displayCtx, plotCanvas, index, start, end)[source]

Create a SampleLineDataSeries.

Parameters
  • overlay – The Image overlay to sample from

  • overlayList – The OverlayList

  • displayCtx – A DisplayContext instance

  • plotCanvas – The PlotCanvas that is plotting this DataSeries.

  • index – Volume index, for images with more than 3 dimensions (see NiftiOpts.index())

  • start – Start of sampling line, in voxel coordinates

  • end – End of sampling line, in voxel coordinates

property coords

Return a (3, n) array containing the voxel coordinates of each sampled point for the most recently generated data, or None if no data has been sampled yet.

__refreshData(*a)

Called when resolution, interp or normalise change. Re-samples the data from the image.

__module__ = 'fsleyes.plugins.tools.sampleline'
class fsleyes.plugins.tools.sampleline.SampleLinePanel(parent, overlayList, displayCtx, ortho)[source]

Bases: fsleyes.controls.controlpanel.ControlPanel

The SampleLinePanel is a FSLeyes control which can be used in conjunction with an OrthoPanel view. It allows the user to draw a line on an OrthoPanel canvas, and plot the voxel intensities, along that line, from the currently selected Image overlay.

The SampleLineProfile class implements user interaction, and the PlotCanvas class is used for plotting.

interp = <MagicMock name='mock.Choice()' id='4009896688'>
resolution = <MagicMock name='mock.Int()' id='4009895512'>
normalise = <MagicMock name='mock.Choice()' id='4009896592'>
lineStyle = <MagicMock name='mock.Choice()' id='4009895632'>
static supportedViews()[source]

Overrides ControlMixin.supportedViews(). The SampleLinePanel is only intended to be added to OrthoPanel views.

static ignoreControl()[source]

Tells FSLeyes not to add the SampleLinePanel as an option to the Settings menu. Instead, the SampleLineAction is added as an option to the Tools menu.

static profileCls()[source]

Returns the SampleLineProfile class, which needs to be activated in conjunction with the SampleLinePanel.

static defaultLayout()[source]

Returns a dictionary containing layout settings to be passed to ViewPanel.togglePanel.

__init__(parent, overlayList, displayCtx, ortho)[source]

Create a SampleLinePanel.

Parameters
colour = <MagicMock name='mock.Colour()' id='4009897648'>
lineWidth = <MagicMock name='mock.Choice()' id='4009895248'>
destroy()[source]

Called when this SampleLinePanel is no longer needed. Clears references, and calls ControlPanel.destroy().

property canvas

Return a reference to the PlotCanvas that is used to plot sampled data from lines that the user has drawn.

addDataSeries()[source]

Holds/persists the most recently sampled line to the plot.

removeDataSeries()[source]

Removes the most recently held/persisted line from the plot.

export()[source]

Prompts the user to save the sampled data to a file.

screenshot()[source]

Creates and runs a ScreenshotAction, which propmts the user to save the plot to a file.

__bindToDataSeries(ds, bind=True)

Binds/unbinds the GUI widgets (colour, resolution), etc to/from the given SampleLineDataSeries instance.

__updateInfo()

Called while the mouse is being dragged. Updates the information about the sampling line (e.g. start/end voxel coordinates) that is displayed at the top of the SampleLinePanel.

__onMouseDown(*a)

Called on mouse down events on an OrthoPanel canvas. Calls __updateInfo().

__onMouseDrag(*a)

Called on mouse drag events on an OrthoPanel canvas. Calls __updateInfo().

__onMouseUp(*a)

Called on mouse up events on an OrthoPanel canvas. Samples and plots data from the currently selected overlay along the drawn sample line.

__draw()

Passed as the drawFunc to the PlotCanvas. Calls PlotCanvas.drawDataSeries().

__module__ = 'fsleyes.plugins.tools.sampleline'
class fsleyes.plugins.tools.sampleline.ExportSampledDataDialog(parent, series)[source]

Bases: __main__.docbuilder.run.<locals>.MockClass

The ExportSampledDataDialog is used by the SampleLinePanel.export() method to ask the user which sample data they want to save, and whether they want to save the sample point coordinates to file as well as the samples themselves.

__init__(parent, series)[source]

Create an ExportSampledDataDialog.

Parameters
  • parentwx parent object

  • series – Sequence of SampleLineDataSeries instances. Must contain at least one series. If there is more than one series, the user is asked to choose one.

__module__ = 'fsleyes.plugins.tools.sampleline'
__onOk(ev)

Called when the ok button is pushed. Closes the dialog.

__onCancel(ev)

Called when the cancel button is pushed. Closes the dialog.

GetCoordinates()[source]

Return one of 'none', 'voxel', or 'world', denoting the user’s preference for saving coordinates to the file.

GetSeries()[source]

Return the SampleLineDataSeries that was selected.