visiannot.visiannot.components.Signal

Module defining Signal

Summary

Classes

visiannot.visiannot.components.Signal.Signal(…)

Class defining a signal to plot in ViSiAnnoT

API

Class Signal

Methods:

downSample(data, factor)

Downsamples the input data by the specified factor using mean

downsampleSignal(new_freq)

Sets the instance with a new signal frequency

getData()

Get method

getDataInRange(first_frame_ms, last_frame_ms)

Returns the signal data in the range defined by first_frame_ms:last_frame_ms

getFreq()

Get method

getLegendText()

Get method

getMaxPoints()

Get method

getPlotStyle()

Get method

setSignal(*args, **kwargs)

Sets the instance with new values

class visiannot.visiannot.components.Signal.Signal(data, freq, max_points=inf, plot_style=None, legend_text='')[source]

Bases: object

Class defining a signal to plot in ViSiAnnoT

The signal data can be accessed with the methods Signal.getData() and Signal.getDataInRange().

The attributes have the prefix _, so one should call the get methods to access them.

Parameters
  • data (numpy array) – signal data, shape (n_{samples}) if regularly sampled (i.e. freq != 0), or (n_{samples}, 2) if not regularlay sampled (i.e. freq == 0), then first column contains the timestamp in milliseconds and the second column contains the data

  • freq (int or float) – signal frequency, set it to 0 if not regularly sampled

  • max_points (int) – maximum number of points to display in ViSiAnnoT (used in Signal.getDataInRange())

  • plot_style (dict) – plot style of the signal, see https://pyqtgraph.readthedocs.io/en/latest/graphicsItems/plotdataitem.html for details

  • legend_text (str) – legend associated to the signal plot

static downSample(data, factor)[source]

Downsamples the input data by the specified factor using mean

Parameters
  • data (numpy array) – signal data to downsample, shape (n_{frames},)

  • factor (int) – downsampling factor, make sure that n_{frames}/factor is an integer

Returns

downsampled signal data, shape (n_{frames}/factor,)

Return type

numpy array

downsampleSignal(new_freq)[source]

Sets the instance with a new signal frequency

Once the signal data is downsampled, the method calls the method Signal.setSignal().

NB: make sure that this method is called only if the signal is regularly sampled.

Parameters

new_freq (int or float) – new frequency of the signal, make sure that it is littler than the current frequency

getData()[source]

Get method

Returns

signal data, shape (n_{samples}, 2) (even if regularly sampled), first column contains the timestamp in milliseconds and the second column contains the data

Return type

numpy array

getDataInRange(first_frame_ms, last_frame_ms)[source]

Returns the signal data in the range defined by first_frame_ms:last_frame_ms

Parameters
  • first_frame_ms (int) – first frame of the range in milliseconds

  • last_frame_ms (int) – last frame of the range in milliseconds

Returns

signal data in the range [first_frame_ms:last_frame_ms]

Return type

numpy array

getFreq()[source]

Get method

Returns

signal frequency (0 if not regularly sampled)

Return type

int

getLegendText()[source]

Get method

Returns

legend associated to the signal plot

Return type

str

getMaxPoints()[source]

Get method

Returns

maximum number of points to display in ViSiAnnoT

Return type

int

getPlotStyle()[source]

Get method

Returns

plot style, might be None

Return type

dict

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

Sets the instance with new values

It calls the constructor.

Parameters
  • args – positional arguments of the constructor of Signal

  • kwargs (keyword arguments of the constructor of Signal) –