biosiglive.streaming package

Submodules

biosiglive.streaming.client module

This file define a wrapper for the socket client to receive data from the server.

class biosiglive.streaming.client.Client(server_ip: str, port: int, client_type: str = 'TCP', name: str = None)[source]

Bases: object

static client_sock(tcp_type: str)[source]

Create a client main.

Parameters:

tcp_type (str) – Type of the main.

Returns:

client – Client main.

Return type:

socket.socket

get_data(message: ~biosiglive.streaming.client.Message = <biosiglive.streaming.client.Message object>, buff: int = 32767)[source]

Get the data from server using the command.

Parameters:
  • message (Message) – Message to send to the server.

  • buff (int) – Size of the buffer.

Returns:

data – Data from server.

Return type:

dict

class biosiglive.streaming.client.Message(command: list | str = 'all', nb_frame_to_get: int = 1, down_sampling: dict = None, custom_cmd: str | list = None)[source]

Bases: object

biosiglive.streaming.server module

This file contains a wrapper for the socket server to send data to the server.

class biosiglive.streaming.server.Connection(ip: str = '127.0.0.1', port: int = 50000)[source]

Bases: object

This class is used to connect to the biosiglive server.

class biosiglive.streaming.server.OscClient(ip: str = '127.0.0.1')[source]

Bases: Connection

Class to create an OSC client.

send_data(data: dict, device_to_send: dict)[source]

Send the data to the client.

Parameters:
  • data (dict) – The data to send.

  • device_to_send (dict) – The device type to send the data to (emg or imu).

start()[source]

Start the client.

class biosiglive.streaming.server.Server(ip: str = '127.0.0.1', port: int = 50000, server_type: str = 'TCP')[source]

Bases: Connection

Class to create a server.

client_listening()[source]

Waiting for the client connection.

send_data(data: dict, connection: socket, message: dict = None)[source]

Send the data to the client.

Parameters:
  • data (dict) – The data to send.

  • connection (socket.socket) – The connection to send the data to.

  • message (dict) – The message received from the client.

start()[source]

Start the server.

biosiglive.streaming.stream_data module

This file contains a class that allows to stream data from a source and start some multiprocess

to process and disseminate. It is a work in progress so basic functions are available but need to be fine-tuned.

class biosiglive.streaming.stream_data.StreamData(stream_rate: int = 100)[source]

Bases: object

add_interface(interface: <biosiglive.interfaces.generic_interface.GenericInterface object at 0x7f81d58727e0>)[source]

Add an interface to the stream.

Parameters:

interface (GenericInterface) – Interface to add. Interface should inherit from the generic interface.

add_plot(plot: LivePlot | list, data_to_plot: str | list, raw: bool | list = None, multiprocess=False)[source]

Add a plot to the live data. Still Not working for now.

Parameters:
  • plot (Union[LivePlot, list]) – Plot to add.

  • data_to_plot (Union[str, list]) – Name of the data to plot.

  • raw (Union[bool, list]) – If True, the raw data will be plotted.

  • multiprocess (bool) – If True, if several plot each plot will be on a separate process. If False, each plot will be on the same one.

add_server(server_ip: str = '127.0.0.1', ports: int | list = 50000, client_type: str = 'TCP', device_buffer_size: int | list = None, marker_set_buffer_size: [<class 'int'>, <class 'list'>] = None)[source]

Add a server to the stream.

Parameters:
  • server_ip (str) – The ip address of the server.

  • ports (int or list) – The port(s) of the server.

  • client_type (str) – The type of client to use. Can be TCP.

  • device_buffer_size (int or list) – The size of the buffer for the devices.

  • marker_set_buffer_size (int or list) – The size of the buffer for the marker sets.

device_processing(device_idx: int)[source]

Process the data from the device

Parameters:

device_idx (int) – The index of the device in the list of devices.

open_server(server_idx: int)[source]

Open the server to send data from the devices.

plot_update(plot_idx: int = -1)[source]

Update the plots.

Parameters:

plot_idx (int) – index of the plot to update. If -1, all plots will be updated.

recons_kin(marker_set_idx: int)[source]

Compute inverse kinematics from markers.

Parameters:

marker_set_idx (int) – Index of the marker set in the list of markers.

save_streamed_data(interface_idx: int)[source]

Stream, process and save the data.

Parameters:

interface_idx (idx) – Interface index to use from the interface list. for now only one interface is supported.

start(save_streamed_data: bool = False, save_path: str = None, save_frequency: int = None)[source]

Start the stream.

Parameters:
  • save_streamed_data (bool) – If True, the streamed data will be saved.

  • save_path (str) – The path to save the streamed data.

  • save_frequency – The frequency at which the data will be saved.

stop()[source]

Stop the stream

biosiglive.streaming.utils module

biosiglive.streaming.utils.dic_merger(dic_to_merge, new_dic=None)[source]

Merge two dictionaries.

Parameters:
  • dic_to_merge (dict) – Dictionary to merge.

  • new_dic (dict) – Dictionary to merge with.

Returns:

Merged dictionary.

Return type:

dict

Module contents