SpectrumPlotsο
Tip
See the π¨ Abstract Class - This class is abstract and cannot be used directly. Subclass it and implement the required methods. for usage examples.
- class sleepeegpy.base.SpectrumPlots[source]ο
Bases:
ABC
Plotting spectral data.
Methods:
Plot PSD per sleep stage.
Plots topomap for a sleep stage and a frequency band.
Plots topomap collage for multiple sleep stages and bands.
Saves SleepSpectrum objects to h5 files.
Attributes:
Instances of
SleepSpectrum
per sleep stage.-
psds:
dict
ο Instances of
SleepSpectrum
per sleep stage.
- plot_psds(picks, psd_range=(-40, 60), freq_range=(0, 60), dB=True, xscale='linear', axis=None, plot_sensors=False, save=False, legend_args=None, **plot_kwargs)[source]ο
Plot PSD per sleep stage.
- Parameters:
picks (
Iterable
[str
] |str
) β Channels to plot PSDs for. Refer tomne.io.Raw.pick()
.psd_range (
tuple
) β Range of y axis on PSD plot. Defaults to (-40, 60).freq_range (
tuple
) β Range of x axis on PSD plot. Defaults to (0, 40).dB β Whether transform PSD to dB. Defaults to True.
xscale (
str
) β Scale of the X axis, check available values atmatplotlib.axes.Axes.set_xscale()
. Defaults to βlinearβ.axis (
axis
) β Instance ofmatplotlib.axes.Axes
. Defaults to None.plot_sensors (
bool
) β Whether to plot sensor map showing which channels were used for computing PSD. Defaults to False.save (
bool
) β Whether to save the figure. Defaults to False.**plot_kwargs β Arguments passed to the
matplotlib.pyplot.plot()
. Have no effect if axis is provided.Defaults to None.
- plot_topomap(stage='REM', band={'Delta': (0, 4)}, dB=False, axis=None, save=False, topomap_args=None, cbar_args=None)[source]ο
Plots topomap for a sleep stage and a frequency band.
- Parameters:
stage (
str
) β One of the sleep_stages keys. Defaults to βREMβ.band (
dict
) β Name-value pair - with name=arbitrary name and value=(l_freq, h_freq). Defaults to {βDeltaβ: (0, 4)}.dB (
bool
) β Whether transform PSD to dB. Defaults to False.axis (
axis
) β Instance ofmatplotlib.axes.Axes
. Defaults to None.save (
bool
) β Whether to save the figure. Defaults to False.topomap_args (
dict
) β Arguments passed tomne.viz.plot_topomap()
.Defaults to None.cbar_args (
dict
) β Arguments passed tomatplotlib.pyplot.colorbar()
.Defaults to None.
- plot_topomap_collage(stages_to_plot='all', bands={'Alpha': (8, 12.49), 'Beta': (12.5, 29.99), 'Delta': (0, 3.99), 'Gamma': (30, 60), 'Sigma': (12.5, 15), 'Theta': (4, 7.99)}, dB=False, low_percentile=5, high_percentile=95, fig=None, save=False, topomap_args=None, cbar_args=None)[source]ο
Plots topomap collage for multiple sleep stages and bands.
- Parameters:
stages_to_plot (
tuple
) β Tuple of strings representing names from sleep_stages, e.g., (βREMβ, βN1β). If set to βallβ plots every stage provided in sleep_stages. Defaults to βallβ.bands (
dict
) β Dict of name-value pairs - with name=arbitrary name and value=(l_freq, h_freq). Defaults to { βDeltaβ: (0, 3.99), βThetaβ: (4, 7.99), βAlphaβ: (8, 12.49), βSigmaβ: (12.5, 15), βBetaβ: (12.5, 29.99), βGammaβ: (30, 60), }.dB (
bool
) β Whether transform PSD to dB. Defaults to False.sleep_stages β Mapping between sleep stages names and their integer representations. Defaults to {βWakeβ: 0, βN1β: 1, βN2β: 2, βN3β: 3, βREMβ: 4}.
low_percentile (
float
) β Set min color value by percentile of the band data. Defaults to 5.high_percentile (
float
) β Set max color value by percentile of the band data. Defaults to 95.fig (
figure
) β Instance ofmpl:matplotlib.pyplot.figure
. Defaults to None.save (
bool
) β Whether to save the figure. Defaults to False.topomap_args (
dict
) β Arguments passed tomne.viz.plot_topomap()
. Defaults to None.cbar_args (
dict
) β Arguments passed tomatplotlib.pyplot.colorbar()
. Defaults to None.
-
psds: