fsleyes.actions.correlate

This module provides the PearsonCorrelateAction class, which is an Action that calculates seed-based correlation on 4D Image overlays.

class fsleyes.actions.correlate.CorrelateAction(overlayList, displayCtx, panel)[source]

Bases: fsleyes.actions.base.Action

The CorrelateAction is a base class for the PearsonCorrelateAction and PCACorrelateAction classes, which manages adding/removing correlation overlays to/from the OverlayList, and manages execution of the correlation.

When a 4D Image is selected and the CorrelateAction is invoked, a new 3D Image is created and added to the OverlayList - this image is referred to as a correlate overlay, and is used to store and display the correlation values.

__init__(overlayList, displayCtx, panel)[source]

Create a CorrelateAction.

Parameters:
destroy()[source]

Removes listeners from the DisplayContext and OverlayList, and calls Action.destroy().

calculateCorrelation(seed, data)[source]

Calculates correlation values between the given seed voxel (an (x, y, z) tuple) and all other voxels. This method must be implemented by sub-classes.

Parameters:
  • seed – An (x, y, z) tuple specifying the seed voxel
  • data – A 4D numpy array containing all of the data.
Returns:

A 3D numpy array containing the correlation values.

_CorrelateAction__clearCorrelateOverlays()

Called by __overlayListChanged(). Clears internal references to any obsolete correlate overlays.

_CorrelateAction__createCorrelateOverlay(overlay, data)

Creates a correlate overlay for the given overlay, adds it to the OverlayList, and initialises some display properties.

_CorrelateAction__overlayListChanged(*a)

Called when the OverlayList changes. Makes sure that there are no obsolete correlate overlays in the list, and calls __selectedOverlayChanged().

_CorrelateAction__runCorrelateAction()

Called when this Action is invoked. Calculates correlation values from the voxel at the current DisplayContext.location (relative to the currently selected overlay) to all other voxels, and updates the correlate overlay.

The correlation calculation and overlay update is performed on a separate thread (via idle.run()), with a call to calculateCorrelation().

_CorrelateAction__selectedOverlayChanged(*a)

Called when the selected overlay, or overlay list, changes.

Enables/disables this action depending on the nature of the selected overlay.

__module__ = 'fsleyes.actions.correlate'
class fsleyes.actions.correlate.PearsonCorrelateAction(overlayList, displayCtx, panel)[source]

Bases: fsleyes.actions.correlate.CorrelateAction

The PearsonCorrelateAction is a CorrelateAction which calculates Pearson correlation coefficient values between the seed voxel and all other voxels.

calculateCorrelation(seed, data)[source]

Calculates Pearson correlation between the data at the specified seed voxel, and all other voxels.

__module__ = 'fsleyes.actions.correlate'
fsleyes.actions.correlate.pearsonCorrelation(seed, data)[source]

Calculates Pearson correlation between the data at the specified seed voxel, and all other voxels.