fsleyes.plotting.powerspectrumseries

This module provides DataSeries sub-classes which are used by the PowerSpectrumPanel for plotting power spectra.

The following classes are provided:

PowerSpectrumSeries

The PowerSpectrumSeries encapsulates a power spectrum data series from an overlay.

VoxelPowerSpectrumSeries

The VoxelPowerSpectrumSeries class encapsulates the power spectrum of a single voxel from a 4D Image overlay.

ComplexPowerSpectrumSeries

This class is the frequency-spectrum equivalent of the ComplexTimeSeries class - see it for more details.

ImaginaryPowerSpectrumSeries

An ImaginaryPowerSpectrumSeries represents the power spectrum of the imaginary component of a complex-valued image.

MagnitudePowerSpectrumSeries

An MagnitudePowerSpectrumSeries represents the magnitude of a complex-valued image.

PhasePowerSpectrumSeries

An PhasePowerSpectrumSeries represents the phase of a complex-valued image.

MelodicPowerSpectrumSeries

The MelodicPowerSpectrumSeries class encapsulates the power spectrum of the time course for a single component of a MelodicImage.

fsleyes.plotting.powerspectrumseries.calcPowerSpectrum(data)[source]

Calculates a power spectrum for the given one-dimensional data array.

Parameters:

data – Numpy array containing the time series data

Returns:

If data contains real values, the magnitude of the power spectrum is returned. If data contains complex values, the complex power spectrum is returned.

fsleyes.plotting.powerspectrumseries.calcFrequencies(nsamples, sampleTime, dtype)[source]

Calculates the frequencies of the power spectrum for the given data.

Parameters:
  • nsamples – Number of samples in the input time series data

  • sampleTime – Time between each data point

  • dtype – Data type - the calculation differs depending on whether the data is real or complex.

Returns:

A numpy array containing the frequencies of the power spectrum for data

fsleyes.plotting.powerspectrumseries.magnitude(data)[source]

Returns the magnitude of the given complex data.

fsleyes.plotting.powerspectrumseries.phase(data)[source]

Returns the phase of the given complex data.

fsleyes.plotting.powerspectrumseries.normalise(data, dmin=None, dmax=None, nmin=-1, nmax=1)[source]

Returns data, rescaled to the range [nmin, nmax].

If dmin and dmax are provided, the data is normalised with respect to them, rather than being normalised by the data minimum/maximum.

fsleyes.plotting.powerspectrumseries.phaseCorrection(spectrum, freqs, p0, p1)[source]

Applies phase correction to the given complex power spectrum.

Parameters:
  • spectrum – Complex-valued power spectrum

  • freqs – Spectrum frequency bins

  • p0 – Zero order phase correction term

  • p1 – First order phase correction term

Returns:

The corrected power spectrum.

class fsleyes.plotting.powerspectrumseries.PowerSpectrumSeries[source]

Bases: object

The PowerSpectrumSeries encapsulates a power spectrum data series from an overlay. The PowerSpectrumSeries class is a base mixin class for all other classes in this module.

varNorm

If True, the fourier-transformed data is normalised to the range [0, 1] before plotting.

Note

The ComplexPowerSpectrumSeries applies normalisation differently.

property sampleTime

Returns the time between time series samples for the overlay data.

__dict__ = mappingproxy({'__module__': 'fsleyes.plotting.powerspectrumseries', '__doc__': 'The ``PowerSpectrumSeries`` encapsulates a power spectrum data series\n    from an overlay. The ``PowerSpectrumSeries`` class is a base mixin class\n    for all other classes in this module.\n    ', 'varNorm': <fsleyes_props.properties_types.Boolean object>, 'sampleTime': <property object>, '__dict__': <attribute '__dict__' of 'PowerSpectrumSeries' objects>, '__weakref__': <attribute '__weakref__' of 'PowerSpectrumSeries' objects>, '__annotations__': {}})
__module__ = 'fsleyes.plotting.powerspectrumseries'
__weakref__

list of weak references to the object

class fsleyes.plotting.powerspectrumseries.VoxelPowerSpectrumSeries(*args, **kwargs)[source]

Bases: VoxelDataSeries, PowerSpectrumSeries

The VoxelPowerSpectrumSeries class encapsulates the power spectrum of a single voxel from a 4D Image overlay. The voxel is dictated by the DisplayContext.location property.

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

Create a VoxelPowerSpectrumSeries. All arguments are passed to the VoxelDataSeries.__init__() method. A ValueError is raised if the overlay is not a 4D Image.

currentVoxelData(location)[source]

Overrides VoxelDataSeries.currentVoxelData(). Retrieves the data at the specified location, then performs a fourier transform on it and returnes the result.

getData()[source]

Returns the (xdata, ydata) to be plotted from the current voxel location.

__annotations__ = {}
__module__ = 'fsleyes.plotting.powerspectrumseries'
class fsleyes.plotting.powerspectrumseries.ComplexPowerSpectrumSeries(*args, **kwargs)[source]

Bases: VoxelPowerSpectrumSeries

This class is the frequency-spectrum equivalent of the ComplexTimeSeries class - see it for more details.

plotReal

A property which encapsulates a bool value.

plotImaginary

A property which encapsulates a bool value.

plotMagnitude

A property which encapsulates a bool value.

plotPhase

A property which encapsulates a bool value.

zeroOrderPhaseCorrection

Apply zero order phase correction to the power spectrum of the complex data.

firstOrderPhaseCorrection

Apply first order phase correction to the power spectrum of the complex data.

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

Create a ComplexPowerSpectrumSeries. All arguments are passed through to the VoxelPowerSpectrumSeries constructor.

makeLabelBase()[source]

Returns a string to be used as the label prefix for this ComplexPowerSpectrumSeries instance, and for the imaginary, magnitude, and phase child series.

makeLabel()[source]

Returns a label to use for this data series.

getData(component='real')[source]

If plotReal is true, returns the real component of the power spectrum of the data at the current voxel. Otherwise returns (None, None).

Every time this method is called, the power spectrum is retrieved (see the VoxelPowerSpectrumSeries class), phase correction is applied if set, andthe data is normalised, if set. A tuple containing the (xdata, ydata) is returned, with ydata containing the requested component ( 'real', 'imaginary', 'magnitude', or 'phase').

This method is called by the ImaginarySpectrumPowerSeries, MagnitudeSpectrumPowerSeries, and PhasePowerSpectrumPowerSeries instances that are associated with this data series.

extraSeries()[source]

Returns a list of additional series to be plotted, based on the values of the plotImaginary, plotMagnitude and plotPhase properties.

__annotations__ = {}
__module__ = 'fsleyes.plotting.powerspectrumseries'
class fsleyes.plotting.powerspectrumseries.ImaginaryPowerSpectrumSeries(*args, **kwargs)[source]

Bases: DataSeries

An ImaginaryPowerSpectrumSeries represents the power spectrum of the imaginary component of a complex-valued image. ImaginaryPowerSpectrumSeries instances are created by ComplexPowerSpectrumSeries instances.

__init__(parent, *args, **kwargs)[source]

Create an ImaginaryPowerSpectrumSeries.

Parameters:

parent – The ComplexPowerSpectrumSeries which owns this ImaginaryPowerSpectrumSeries.

All other arguments are passed through to the DataSeries constructor.

makeLabel()[source]

Returns a string representation of this ImaginaryPowerSpectrumSeries instance.

getData()[source]

Returns the imaginary component of the power spectrum.

__annotations__ = {}
__module__ = 'fsleyes.plotting.powerspectrumseries'
class fsleyes.plotting.powerspectrumseries.MagnitudePowerSpectrumSeries(*args, **kwargs)[source]

Bases: DataSeries

An MagnitudePowerSpectrumSeries represents the magnitude of a complex-valued image. MagnitudePowerSpectrumSeries instances are created by ComplexPowerSpectrumSeries instances.

__init__(parent, *args, **kwargs)[source]

Create an ImaginaryPowerSpectrumSeries.

Parameters:

parent – The ComplexPowerSpectrumSeries which owns this ImaginaryPowerSpectrumSeries.

All other arguments are passed through to the DataSeries constructor.

makeLabel()[source]

Returns a string representation of this MagnitudePowerSpectrumSeries instance.

getData()[source]

Returns the magnitude of the complex power spectrum.

__annotations__ = {}
__module__ = 'fsleyes.plotting.powerspectrumseries'
class fsleyes.plotting.powerspectrumseries.PhasePowerSpectrumSeries(*args, **kwargs)[source]

Bases: DataSeries

An PhasePowerSpectrumSeries represents the phase of a complex-valued image. PhasePowerSpectrumSeries instances are created by ComplexPowerSpectrumSeries instances.

__init__(parent, *args, **kwargs)[source]

Create an ImaginaryPowerSpectrumSeries.

Parameters:

parent – The ComplexPowerSpectrumSeries which owns this ImaginaryPowerSpectrumSeries.

All other arguments are passed through to the DataSeries constructor.

makeLabel()[source]

Returns a string representation of this PhasePowerSpectrumSeries instance.

getData()[source]

Returns the phase of the complex power spectrum.

__annotations__ = {}
__module__ = 'fsleyes.plotting.powerspectrumseries'
class fsleyes.plotting.powerspectrumseries.MelodicPowerSpectrumSeries(*args, **kwargs)[source]

Bases: DataSeries, PowerSpectrumSeries

The MelodicPowerSpectrumSeries class encapsulates the power spectrum of the time course for a single component of a MelodicImage. The component is dictated by the NiftiOpts.volume property.

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

Create a MelodicPowerSpectrumSeries. All arguments are passed through to the PowerSpectrumSeries.__init__() method.

makeLabel()[source]

Returns a label that can be used for this MelodicPowerSpectrumSeries.

getData()[source]

Returns the power spectrum for the current component of the MelodicImage, as defined by the NiftiOpts.volume property.

__annotations__ = {}
__module__ = 'fsleyes.plotting.powerspectrumseries'
class fsleyes.plotting.powerspectrumseries.MeshPowerSpectrumSeries(*args, **kwargs)[source]

Bases: DataSeries, PowerSpectrumSeries

A MeshPowerSpectrumSeries object encapsulates the power spectrum for the data from a Mesh overlay which has some time series vertex data associated with it. See the MeshOpts.vertexData property.

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

Create a MeshPowerSpectrumSeries instance. All arguments are passed through to DataSeries.__init__().

__annotations__ = {}
__module__ = 'fsleyes.plotting.powerspectrumseries'
makeLabel()[source]

Returns a label to use for this MeshPowerSpectrumSeries on the legend.

__haveData()

Returns True if there is currently time series data to show for this MeshPowerSpectrumSeries, False otherwise.

getData()[source]

Returns the power spectrum of the data at the current location for the Mesh, or None, None if there is no data.