No description
Find a file
2023-07-03 13:04:38 +02:00
__pycache__
connection improvement and stability 2023-07-03 13:04:38 +02:00
settings improvement and stability 2023-07-03 13:04:38 +02:00
utils improvement and stability 2023-07-03 13:04:38 +02:00
Electrode_selection.txt improvement and stability 2023-07-03 13:04:38 +02:00
EStiMo_GUI.py improvement and stability 2023-07-03 13:04:38 +02:00
README.md improvement and stability 2023-07-03 13:04:38 +02:00
requirements.txt Structure 2023-06-14 14:25:52 +02:00

EStiMo

EStiMo is a sophisticated software developed for the purpose of real-time monitoring during Transcranial Magnetic Stimulation (TMS) sessions. This is accomplished by conducting a real-time analysis of Electroencephalography (EEG) signals. Its operational mechanics are contingent on a suite of features that are computed online and visually represented on the display interface. The computation of these values takes place in between the trains of TMS.

Installation

EStiMo is designed to be conveniently portable and as such, does not necessitate a typical installation procedure. However, the pre-requisite for running this software smoothly is a Python 3 environment, ideally version 3.8. Alongside Python, several other libraries are necessary for full functionality, including: time, matplotlib, mne, inspect, sys, os, random, scipy, PyQt5, multiprocessing, pandas, json, cycler, traceback, and csv. The EStiMo package is comprised of 6 distinct Python script files namely: FirstWindow.py, Functions.py, NeurOne.py, RDA.py, and EStiMo_GUI.py. Additionally, there are certain auxiliary files that facilitate the running of the software. The 'TMS_protocol.txt' file includes the default settings for the application. The 'electrode_selection.txt' file contains the directories for files related to electrode placement. Lastly, the package also includes a csv file that possesses a square matrix, which is integral for defining the relationships between the various channels.

Establishing Connection with NeurOne

The EStiMo software connects to NeurOne utilizing a serial port. The application anticipates data as input from the device. The final channel is intended to function as a stimulus channel, which returns a value of 0 in the absence of triggers and alternate values when triggers are present. For further specifics regarding the connection setup, kindly refer to the NeurOne user manual.

Establishing Connection with Brain Products Systems

The software forms a connection with Brain Products systems via the Remote Data Access (RDA) protocol, which is an integral part of the Brain Products Recorder. Hence, the Recorder is a necessary requirement. The connection is made via the ethernet port. Detailed information about the RDA protocol and connection process can be found in the Brain Product user manual.

Commencing with EStiMo

To start the EStiMo program, simply execute the EStiMo_GUI.py file using Python 3. This can be accomplished through an Integrated Development Environment (IDE) such as Spyder or a console. Upon execution, the initial settings window will appear. These settings can be manually altered, or a configuration file (a txt file with a specific structure) could be imported instead. The montage can be adjusted by importing a csv file containing a matrix of size (n_channels, n_channels). On the right side of the interface, the channels are displayed. Their positions correspond to the actual positions on the cap, guided by the file indicated at the top of the screen. This layout can be changed if needed. It should be noted that when changing, two files must be selected: one depicting the original cap layout, and the other containing only the channels used for feature computation. If all channels are needed, the same file can be loaded twice.

Example: From 10-10 EEG montage, only 12 channels are used. In that case, as a first file the whole 10-10 montage should be loaded, and as a second a file containing only chosen 12 electrodes.

Then, channels can be manually selected or deselected to include or exclude them from the feature extraction process. Selected channels are highlighted in blue. The left side of the interface offers adjustable settings and options. At the top of the window, the "Features and connection" bar can be selected, offering a choice of features for the connection setup. Once the settings are appropriately adjusted, the "Run program" button can be clicked to start the software.

Calibration

The software includes a calibration function. During this process, it looks at the data to set a baseline for all used features. During calibration, the software calculates the mean value of all channels every second. Once calibration is over, it sets the thresholds (by default) at 10% of the distance between min a max, over, and below the maximum and minimum value recorded during the calibration.

Measurements

The software provides a number of available features, and the user is able to add their own functions, written in Python. The measurements are averaged across channels and displayed as plots on the right side of the screen. Each plot's background will turn red if any of the thresholds are crossed. According to many publications, that might be an early indicator of an incoming seizure (see paper). However, these alerts can also be caused by other factors, like movement, blinking, bad connection between the electrode and the skull, too short calibration, or other artifacts. One common artifact can be a signal from the electrode under the TMS coil when it's pushed too hard.

Appendix

TMS_Protocol.txt structure

This file includes several settings that can be changed by adjusting the value that follows the colon. The settings you can change are:

  • time_between_trains: This is the time between consecutive trains, measured in seconds.
  • cut_time: This is the time segment of the signal between consecutive trains that is ignored. The signal is cut from both sides by half of the given value. This value should be set in seconds.
  • number_of_channels: This is the number of used channels, excluding the channels that represent the trigger indicator.
  • number_of_lines: This is the number of measurements from past segments that are presented during the readout phase.
  • eog_channel: This is the index of the EOG channel. It can be set as an index from the end by using the minus sign (please note that the last channel, or -1, is always reserved for the trigger indicator).
  • emg_channel: This is the index of the EMG channel. It can be set as an index from the end by using the minus sign (again, note that the last channel, or -1, is always reserved for the trigger indicator).
  • included_channels: These are the indexes of channels that are used to calculate features, from 0 (which is the first channel) to N (N represents the number of EEG channels). EOG, EMG, and trigger indicator channels are not included. Indexes correspond to the order of channels streamed from the EEG system. This should be filled as a list of integers.
  • names: These are the names of the channels that are streamed. This should be filled as a list of integers or strings.
  • alpha_range: This is the range of the alpha band in Hz. It should be filled as a list of integers (for example, [5, 16]).
  • beta_range: This is the range of the beta band in Hz. It should be filled as a list of integers (for example, [16,30]).
  • theta_range: This is the range of the theta band in Hz. It should be filled as a list of integers (for example, [4,8]).
  • expected_triggers: This is the number of triggers within a single train.
  • expected_time: This is the time of the single train, measured in milliseconds.

Example:

time_between_trains: 8
cut_time: 1
number_of_channels: 18
number_of_lines: 4
eog_channel: -3
emg_channel: -2
included_channels: [0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15]
names: [1,3,7,8,9,11,14,17,19,23,26,29,32,43,50,52, "EOG", "EMG"]
alpha_range: [8,15]
beta_range: [16,30]
theta_range: [4,8]
threshold_parameter: 2
expected_triggers: 10
expected_time: 2000
plot_len: 4

Structure of the Electrode_selection.txt

You can set paths for the files that contain spatial information in this file. The following are the available settings:

  • full_cap_file_path: This is the path to the file showing the spatial location for the full cap.
  • cap_file_path: This is the path to the file showing the spatial location only for the streamed channels.

The requirement for both files is purely based on practical reasons to make potential edits to the protocol easier. It's designed for users who only want to use a select number of channels from a larger EEG cap montage.

⚠️ Please note: If you're using the entire cap, set both settings to the same path. If you don't have access to any of these files, use one of them for both options. However, this might require manual adjustment in the program settings.

Spatial Locations file structure

The files with spatial locations are managed using the 'mne' library from Python. The function called mne.channels.read_custom_montage is utilized for this purpose. The coordinates are transformed into 2D space using the same library. The way this function reads the file depends on the file format:

eeglab: '.loc', '.locs', '.eloc'
hydrocel: '.sfp'
matlab: '.csd'
asa electrode: '.elc'
generic (Theta-phi in degrees): '.txt'
standard BESA spherical: '.elp'
brainvision: '.bvef'

⚠️ Please note: The software was tested only using generic format.

Montage file structure

The montage file is an N by N array that functions as an array multiplying the signal (array multiplication). This means the signal can be adjusted according to the user's needs, for example by setting a specific type of reference. The file should be in .csv format, and values should be separated by a comma. The indexes follow the Python standard, which is horizontally from left to right and vertically from top to bottom.