wonambi.widgets.analysis module

Dialogs for analyses, such as power spectra, PAC, event parameters

class wonambi.widgets.analysis.AnalysisDialog(parent)[source]

Bases: ChannelDialog

Dialog for specifying various types of analyses: per event, per epoch or per entire segments of signal. PSD, PAC, event metrics. Option to transform signal before analysis. Creates a pickle object.

parent

the main window

Type:

instance of QMainWindow

nseg

number of segments in current selection

Type:

int

band_help(opt=None)[source]
button_clicked(button)[source]

Action when button was clicked.

Parameters:

button (instance of QPushButton) – which button was pressed

check_all_local()[source]

Check or uncheck all local event parameters.

check_all_local_prep()[source]

Check or uncheck all enabled event pre-processing.

compute_evt_params()[source]

Compute event parameters.

compute_freq(csd=False)[source]

Compute frequency domain analysis.

Returns:

list of dict – each item is a dict where ‘data’ is an instance of ChanFreq for a single segment of signal, ‘name’ is the event type, if applicable, ‘times’ is a tuple of the start and end times in sec, ‘duration’ is the actual duration of the segment, in seconds (can be dissociated from ‘times’ if the signal was concatenated) and with ‘chan’ (str), ‘stage’ (str) and ‘cycle’ (int)

compute_freq_cross(csd, asd, output='coherence')[source]

Compute cross-spectrum, gain, phase shift and/or coherence.

Parameters:
  • csd (list of dict with 'data' key as instance of ChanFreq) – cross-spectral density, one channel

  • asd (list of dict with 'data' key as instance of ChanFreq) – autospectral density, two channels

  • output (str) – ‘coherence’ or ‘gainphase’

Returns:

tuple of list of dict with ‘data’ key as instance of ChanFreq – if coherence, tuple contains one dict if gainphase, tuple contains: xgain, ygain, phase

where xgain is gain with x as input and y as output

compute_pac()[source]

Compute phase-amplitude coupling values from data.

create_dialog()[source]

Create the dialog.

export_pac(xpac, fpha, famp, desc)[source]

Write PAC analysis data to CSV.

get_segments()[source]

Get segments for analysis. Creates instance of trans.Segments.

make_title(chan, cycle, stage, evt_type)[source]

Make a title for plots, etc.

plot_freq(x, y, title='', ylabel=None, scale='semilogy')[source]

Plot mean frequency spectrum and display in dialog.

Parameters:
  • x (list) – vector with frequencies

  • y (ndarray) – vector with amplitudes

  • title (str) – plot title

  • ylabel (str) – plot y label

  • scale (str) – semilogy, loglog or linear

report_fooof(x, y, suffix)[source]

Create FOOOF (fitting oscillations and 1/f) report.

Parameters:
  • x (ndarray) – vector with frequencies

  • y (ndarray) – vector with amplitudes

save_as()[source]

Dialog for getting name, location of data export file.

toggle_buttons()[source]

Enable and disable buttons, according to options selected.

toggle_concatenate()[source]

Enable and disable concatenation options.

toggle_freq()[source]

Enable and disable frequency domain options.

toggle_pac()[source]

Enable and disable PAC options.

transform_data(data)[source]

Apply pre-processing transformation to data, and add it to data dict.

Parameters:

data (instance of Segments) – segments including ‘data’ (ChanTime)

Returns:

instance of Segments – same object with transformed data as ‘trans_data’ (ChanTime)

uncheck_all_local()[source]

Uncheck ‘all local’ box when a local event is unchecked.

update_evt_types()[source]

Update the event types list when dialog is opened.

update_nseg()[source]

Update the number of segments, displayed in the dialog.

class wonambi.widgets.analysis.PlotCanvas(parent=None, width=5, height=4, dpi=100)[source]

Bases: object

Widget for showing plots.

plot(x, y, title, ylabel, scale='semilogy', idx_lim=(1, -1))[source]

Plot the data.

Parameters:
  • x (ndarray) – vector with frequencies

  • y (ndarray) – vector with amplitudes

  • title (str) – title of the plot, to appear above it

  • ylabel (str) – label for the y-axis

  • scale (str) – ‘log y-axis’, ‘log both axes’ or ‘linear’, to set axis scaling

  • idx_lim (tuple of (int or None)) – indices of the data to plot. by default, the first value is left out, because of assymptotic tendencies near 0 Hz.

class wonambi.widgets.analysis.PlotDialog(parent=None)[source]

Bases: QDialog

Dialog for displaying plots.

create_dialog()[source]

Create the basic dialog.