Features module

Features.export_plot(info, plot_type, size=None, line_types=None, dpi=600)[source]

Creates matplolib plot and exports it into png image, according to the prepared info in dearpygui.

If plot_type is '2D' or 'CC' (Timeline/normal PSD or cross-correlation):
  • signals: list of dicts

  • colors: list, rgba codes

If plot_type is '3D' or '3DC' (spectrogram or coherogram):
  • signals: list of tuples.

  • colors: str, name of colormap

If plot_type is 'Bar' or 'Events' (phase-amplitude coupling or event summary):
  • signals: list of dicts.

  • colors: list, rgba codes

If plot_type is 'SMP' (Show Mean Power over time):
  • signals: dict, 'Y1': signals plotted on left y axis, 'Y2': signals plotted on right y axis.

  • colors: list, rgba codes

If plot_type is 'Pie' (phase-amplitude coupling or event summary):
  • signals: single list of values.

  • colors: list, rgba codes

Parameters:
  • info -- signals (list), labels (list of signal's labels), colors (list), title (str, name of plot), axis (list, names of axis), limits (list, range of axis)

  • plot_type -- str, type of plot: '2D' (Timeline/PSD), 'CC' (cross-correlation), '3D' (spectrogram), '3DC' (coherogram), 'Bar' (phase-amplitude coupling), 'Events' (event summary), 'Pie' (event summary count)

  • size -- tuple, width and height of original plot. Optional, default to None, width and height are set to default fig sizes of matplotlib

  • line_types -- list, type of line plotted in dpg. Optional, default to None.

Features.export_signals(info, filename, tfd=False)[source]

Writes into "Signals_{filename}.csv" file, signals contained in info dictionary.

Parameters:
  • info -- dict, keys are columns

  • filename -- str, name of file

  • tfd -- Optional. Default to False, if True exports 3D signals (spectrogram/coherogram)

Features.extract_psd_features(p, band, bands=None)[source]

Extracts features from spectral density, or coherence, methods. Returns dictionary.

Features: - Mean Power (mean, std. dev) - % Mean Power (mean, std. dev) - Sum Power (AUC) - % Sum Power (AUC) - Peak Power (power, frequency)']

Parameters:
  • p -- dict, computed PSD ('X' = freqs, 'Y' = psd values)

  • band -- list, band[0] = str, band name; band[1] = list, [f0,f1]

Returns:

dict, {feature: value}

Features.extract_timeline_features(p)[source]

Extracts features from timeline recordings, returned into a dictionary.

Features: - Mean Power (mean, std. dev) - Peak Power - Peak Time - Sensing Freq. (Hz)

Parameters:

p -- dict, computed PSD ('X' = time array, 'Y' = lfp timeline values)

Returns:

dict, {feature: value}

Features.get_sum_mean_power(p, band=None)[source]

Calculates and returns the sum of all band's mean power

Parameters:
  • p -- dict, computed PSD ('X' = freqs, 'Y' = psd values)

  • bands -- dict, 'band name': [f0,f1]

Returns:

float

Features.mean_power_all_bands(stream, bands)[source]

Computes mean power for frequency bands over a stream of events.

Parameters:
  • stream -- Description

  • bands -- Description

Returns:

dict, {band: mean}

Features.mean_power_band(log, band)[source]

Calculates and returns a dictionary of band-respective mean

Parameters:
  • stream -- dict, signal information 'X'/'Frequency' --> x axis; 'Y'/'Power' --> y axis

  • bands -- dict, 'band name': [f0,f1]

Returns:

np.array, mean power

Features.peak_per_band(stream, bands)[source]

Retrives all peak values and positions, in stream, for each band.

Parameters:
  • stream -- dict, signal information 'X'/'Frequency' --> x axis; 'Y'/'Power' --> y axis

  • bands -- dict, 'band name': [f0,f1]

Features.peak_power(stream)[source]

From stream dictionary, return tuple with peak value and peak position.

Parameters:

stream -- dict, signal information 'X'/'Frequency' --> x axis; 'Y'/'Power' --> y axis

Features.std_dev_streams(streams, bands)[source]

Calculates and returns a dictionary of band-respective standard deviation

Parameters:
  • stream -- dict, signal information 'X'/'Frequency' --> x axis; 'Y'/'Power' --> y axis

  • bands -- dict, 'band name': [f0,f1]

Returns:

dict, 'band name': float standard deviation