Python application to track physiological parameters during surgery.
It logs information about the subject of the experiment and the drugs to be injected during the surgery. Note that the software has the ability to control syringe pumps to perform injections with the click of a button.
Main screen showing the controls to inject drugs, and the graphs showing the physiological parameters logged during the surgery
Main window showing all the information automatically saved to a text log file.
The software needs a configuration file in JSON format to run. The global structure of the file is:
{
"base-folder": str,
The folder in which the logs are going to be saved
"create-sub-folder": true|false,
Whether to create a separate sub-folder for every day of experiment. If `true`, a new folder with the name
'YYYY-MM-DD/' will be created in base-folder
"log-filename": str,
This is the name of the file in which the surgical log
is saved (without path)
"measurements-output-period-min": float,
The period (in minutes) with which the trend measurements are written to the log file
"acquisition-modules": list,
This is a list of modules used for data acquisition.
See list of supported modules and configuration options below
"channels": list,
List of channels and their configuration. See below for details
"syringe-pump":
"serial-ports": list,
This is a list of serial ports to open in order to communicate with the syringe pump(s).
Contains a list of parameters to pass to serial.Serial(). See https://pythonhosted.org/pyserial/pyserial_api.html#native-ports
for a complete list.
"pumps": list
List of syringe pumps and their configuration. See list of supported
modules and their configuration below.
}
Each element of the list must contain the following items:
{
"module-name": str;
Name of the module to use. See the list below
"sampling-rate": float;
Sampling rate for the acquisition (in Hz)
"module-args": section;
Section containing the parameters needed to create the modules. See below for each module's options.
}
Available data acquisition modules are:
This module is intended for testing and debugging. It is a dummy modules that does not require external hardware.
It reads a CSV file (or any file that can be parsed by numpy.loadtxt
),
and outputs the content at the given sampling rate.
The arguments to supply in "module-args"
are:
filename
- the path to the file to read (default./media/file_streamer_data.txt
)genfromtxt_kws
- optional arguments passed tonumpy.genfromtxt
. See the documentation for a list of possible arguments.
This module allows the use of NI cards supported by the nidaqmx python library. Currently, only tested on Windows.
The arguments to supply in "module-args"
are:
device
- the name of the physical device to use (e.g."Dev1"
)channels
- a list of physical channels to sample from (e.g.["ai0","ai7","ai2"]
)input_modes
- a list (same length aschannels
) of terminal configurations (e.g.["RSE", "MRSE", "DEFAULT"]
). Valid configurations areDEFAULT
,RSE
,NRSE
,DIFFERENTIAL
andPSEUDODIFFERENTIAL
.buffer_size
- size of the buffer used to store the data in between each read (default 1000).
This module allows the use of Measurement Computing devices supported by the MCC Universal Library (uldaq).
The arguments to supply in "module-args"
are:
device
- the device number (e.g.0
). This corresponds to the index of the device as returned byuldaq.get_daq_device_inventory(InterfaceType.ANY)
. See the documentation on device discovery for more information.channels
- a list of channel numbers to sample from (e.g.[0, 7, 3]
).input_modes
- a list (same length aschannels
) of input modes (e.g.['SINGLE_ENDED','SINGLE_ENDED','DIFFERENTIAL']
). Valid input modes areDIFFERENTIAL
,SINGLE_ENDED
, andPSEUDO_DIFFERENTIAL
.input_ranges
- a list (same length aschannels
) of input range (e.g.['BIP5VOLTS', 'BIP10VOLTS', 'UNI10VOLTS']
). See the documentation for a list of valid input ranges.buffer_size
- size of the buffer used to store the data in between each read (default 1000).
No longer supported under Python 3
Each channel is configured by the following intructions:
acquisition-module-index
- int - Index of the acquisition module to use for this channel (as defined by its position in the list of acquisition modules declared in the section "Data acquisition modules")channel-index
- int - Index corresponding to this channel's data in the relevant stream. WARNING: this is not the physical channel number as entered in channel list in the acquisition configuration, but the index of the channel in the list of channels.window-size
- float - Width of the window of data to display (in seconds).label
- string - Channel title.units
- string - Real world unit for the channel.scale
- float - used to convert the value in volts to the value in real worl units:Units = scale x volts + offset
.offset
- float - used to convert the value in volts to the value in real worl units:Units = scale x volts + offset
.autoscale
- true/false - Whether to automatically adjust the y-axis limit to fit with the data limits.ymin
- float - Lower y-axis limit. Only usefull if autoscale is off.ymax
- float - Upper y-axis linit. Only usefull if autoscale is off.line-color
- variable - color of the data line. Accepts any argument that can be passed topyqtgraph.mkColor()
line-width
- float - line thickness.persistence
- int - Number of past traces to keep. Older traces fade towards the background color.trigger-mode
- string - Sets whether new data is shown immediately upon reaching the right-hand side of the screen ('AUTO'
), or whether the waveform must first cross a threshold value (see below) in the upward ('RISING'
) or downward direction ('FALLING'
).trigger-level
- float - Threshold value (in channel units).auto-trigger-level
- true/false - Whether the trigger threshold is automatically calculated based on the historical data. The value is calculated as 75% of the range of the data if the threshold mode isRISING
, and 25% of the range if it isFALLING
.trend-window-size
- float - Width of the window of trend data (in seconds).trend-period
- Period over which to calculate the trend value (in seconds).trend-function
- string - Function used to calculate the trend value. Valid values are:'HR'
calculates heart rate based on QRS detection'max'
returns the maximum of the data,'min'
returns the minimum of the data,'lastPeak'
returns the value of the latest detected peak in the data,'avgPeak'
returns the average of the peak values detected in the data,'average'
returns the average of the data
trend-function-args
- arguments passed totrend-function
. See the code for thetrend_*
functions in the GUI.scope module.trend-units
- string - Units of the trend datatrend-autoscale
- true/false - Whether to automatically adjust the y-axis limit of the trend window to fit with the data limits.trend-ymin
- float - Lower y-axis limit of the trend window. Only usefull if autoscale is off.trend-ymax
- float - Lower y-axis limit of the trend window. Only usefull if autoscale is off.alarm-enabled
- true/false - Whether an alarm should sound when the trend data is outside the lower and higher limits.alarm-low
- float - The lower threshold for the alarm.alarm-high
- float - the upper threshold for the alarm.alarm-sound-file
- string - path to an OGG or a WAV sound file that is being played when the alarm is triggered.alarmBGColor
- var - Color of the window when the alarm is triggered.
PhysioMonitor can control serial pumps through serial communication. Currently, the following models are supported:
- fake pump, for testing purposes
- Aladdin pump
- Harvard Apparatus Model 11 plus (old model)
- Harvard Apparatus Model 11 Elite Single
Parameters:
list of serial ports to open. Each of the element contains parameters that can be passed to serial.Serial().
Each element of the list must contain the following items:
{
"display-name": str,
Name of the pump, displayed in various places in the GUI
"module-name": str,
Name of the module to use. One of "demo", "aladdin" or "model11plus".
"serial-port": int,
index of the serial port to use to control that syringe pump.
"module-args": section,
Section containing the parameters needed to create the modules. See below for each module's options.
}
Available modules are:
Fake pump, for testing purposes. "module-args" is empty
Module for Aladdin syringe pumps.
The arguments to supply in "module-args"
are:
adress
: unique network address to identify the pump to the computer. Network addresses are from 00 to 99. If the network consists of only 1 pump, set the pump’s address to 0.
Module for Harvard Apparatus Model 11 plus (old model). "module-args" is empty.
Module for Harvard Apparatus Model 11 Elite Single "module-args" is empty.
- create a virtual environement for PhysioMonitor:
$ python3 -m venv ~/physio-env
- clone the repository
$ git clone https://github.com/MarinManuel/PhysioMonitor.git
- install pre-requisites
$ physio-venv/bin/pip install -r PhysioMonitor/requirements.txt
- edit
PhysioMonitor.json
- run PhysioMonitor
cd ~/PhysioMonitor
~/physio-venv/bin/python ./PhysioMonitor.py -c ./PhysioMonitor.json
PhysioMonitor should work with any NI instrument card that works with the nidaqmx
python module.
- Install the NI linux driver. See instruction at this location.
sudo apt install ./ni-ubuntu2004firstlook-drivers-stream.deb
sudo apt update
sudo apt install ni-daqmx
sudo dkms autoinstall
- reboot