Getting started with OpenICE: Setting up OpenICE on linux environment

OpenICE is an application built by the MDPnP (Medical Device Plug and Play) group out of Harvard/Partners Healthcare in Boston, MA. The lab’s focus is to build applications that increase interoperability success.

Although broken at the time of this writing, their website generally featured a web application demo that demonstrated real time streaming of operating room devices (think physiological monitors and ventilators) to a browser.

The last OpenICE update was >1.5 years ago but it is still possible to make use of the tools that have been created.

I had trouble getting their code in GitHub to work appropriately. The simulated devices could be called up but the supervisor which includes apps to actually do something with the data coming from devices would crash on my linux machine. I was advised to build from source. Below are instructions that worked.

1. Setup the correct Java environment.

I had the most up to date java environment when I was building from source and that wouldn’t work. I was instructed to only use Java 8 Oracle update 60 which is an older version. 

  1. Download the JDK for your linux version
  2. Un-tar the version you downloaded and place where you like. I placed mine in /opt/ folder
  3. Use the following commands to install this java version as an alternative available
  4. sudo update-alternatives --install /usr/bin/java java /opt/jdk1.8.0_60/bin/java 1
    sudo update-alternatives --install /usr/bin/javac javac /opt/jdk/jdk1.8.0_60/bin/javac 1

    substitute your path for the location you placed your version. Then you must set that version as the used version using:

  5. sudo update-alternatives --config java

    this will prompt you to give a number for the version you’d want to use as a default. Select the version and confirm that it is set by seeing the * next to the number.

 

2. Get the code to build
  1. Clone the repository located at:
  2.  git clone https://github.com/mdpnp/mdpnp.git.

 

3.  Build with Gradle
  1. Build by using the following command in your cloned github repository
  2. ./gradlew

 

What’s next?

  • OpenICE should really be something that works and is ready to go. The code hasn’t been updated so may some inspired individual could take the reigns in having it work on all platforms out of the gate?
  • Build information should specify the JDK needed more clearly or be able to be built with something other than Java Oracle like OpenJDK.

 

Now on to seeing if I can get Hello OpenICE to work…

Interactive Manual of Anesthesiology: Difficult Airway Algorithm

I am in the process of revitalizing an old project that got left behind during the busyness of residency. It is an interactive manual for things associated with perioperative care. My goal is to launch several tools that are helpful for anesthesiologists at the point of real time care.

The first item to launch is a simple app for the difficult airway algorithm.

Check out the app here.

See the behance portfolio item here

Send  me your feedback!

 

Now Listening for Spotify/Linux: Auto publish what song you’re listening to in realtime

Here is a quick python script to update a file with what you’re listening to on spotify on Ubuntu/Linux in real time. It updates every 30 seconds.

Tested with Python 3, Ubuntu 16.04 and Spotify Linux Client (no longer maintained).

This saves to a txt file locally which you can then use to cURL to an online server to broadcast your current playing song (Adele on repeat anyone??).

import dbus
import sched, time
#s = sched.scheduler(time.time, time.sleep)
currentTrack = ""
currentArtist = ""

session_bus = dbus.SessionBus()
spotify_bus = session_bus.get_object("org.mpris.MediaPlayer2.spotify",
 "/org/mpris/MediaPlayer2")
spotify_properties = dbus.Interface(spotify_bus,
 "org.freedesktop.DBus.Properties")

def getsong():
 metadata = spotify_properties.Get("org.mpris.MediaPlayer2.Player", "Metadata")
 # The property Metadata behaves like a python dict
 #for key, value in metadata.items():
 #print(key, value)

 # To just print the title
 global currentTrack
 currentTrack = metadata['xesam:title']

 global currentArtist
 currentArtist = ','.join(metadata['xesam:albumArtist'])

 if currentArtist != '' :
 f = open('./nowlisten.txt', 'w')
 output = currentTrack+' - '+currentArtist #format output here
 print(output)
 f.write(output)
 f.close()

 time.sleep(30)

while True:
 getsong()

 

 

Streaming Databases for physiological data (EKG, ABP, SPO2 etc)

My current research project is a design and implementation of a remote anesthesia monitoring application. Building such an application has many potential uses including tele-anesthesia and for in-house staff supervising multiple anesthetists: the opportunity to be alerted when something goes awry.

I decided to focus on building a mobile application using fullstack javascript for interactivity and decided on meteor, angular2, ionic2 and python for some backend work. While testing my app I needed to figure out how to simulate real time physiologic data.

I grabbed data from physionet an awesome database of physiological “stuff”. They have waveforms of data from real patients collected and annotated. How to use physionet is an entirely different article which I will detail at another point but the short story is that I grabbed a subset of one of the databases, exported it to a CSV file, edited the headers for standardization across my app and used the ‘elapsed time’ column to create essentially a unique index based on time that I could use to grab and stream data in order.

With many data points my data looked like this in a .csv file

t,ECG,ART,PAP,CVP,RR,CO2
0,-0.427,-14.608,-21.258,-22.768,-0.733,-0.074
0.003,-0.153,0,0.156,0.853,0.076,1.141
0.006,-0.14,1.002,1.611,2.457,0.133,1.227
0.008,-0.211,-2.504,-3.586,-3.26,-0.063,0.931
0.011,-0.191,-2.003,-2.911,-2.508,-0.037,0.969
0.014,-0.144,-0.417,-0.52,0.05,0.052,1.103
0.017,-0.165,-1.085,-1.507,-1.003,0.015,1.049
0.019,-0.198,-1.753,-2.599,-2.156,-0.024,0.988
0.022,-0.184,-1.252,-1.819,-1.304,0.004,1.031
0.025,-0.164,-1.002,-1.403,-0.903,0.019,1.052
0.028,-0.167,-1.336,-1.923,-1.454,0,1.025

I then used mongodb to put all this data in a collection that could be queried.  The trick to simulating the data is to use the current time to query the database quickly and push this queried and timestamped data into another database which as it is updated appears to be collecting data from a patient in real time.

See the video below for how it will appear in an app:

Elapses: Creating a Unity stopwatch indicator w/ Python

Elapses: Unity stopwatch app indicator

Though there are many productivity apps for tracking time when I  converted my desktop and laptop over to dual-boot Ubuntu (16.04)/Linux I wanted to take my favorite simple time tracking app Thyme with me but it was only for Mac.

Searches for a unity app indicator to go on the menu bar and show me how much time I had been spending on a task were fruitless. I found a few alarm apps with timers but I couldn’t get a stop-watch mode which was what I really wanted. As long as I could look up and see the time tracker without having to pull up another window I would be happy. Chrome (my browser of choice) has many timer/stop watch apps but these also required having another window open which would easily be hidden as I worked away.

So I decided to build my own unity stop watch indicator using python (using 2.7.x). The resources for the app indicator documentation (not very good or helpful) are here: https://unity.ubuntu.com/projects/appindicators/. Please note this resource is for python3 and we are using  python 2.7 here. Most of the code still applies though.

Start by checking if Python is installed and what version by opening a terminal window and typing:

python --version

If you don’t have python already you an install it from the terminal using:

sudo apt-get install python

Once python is installed you can install a library called python-appindicator.

sudo apt-get update
sudo apt-get install python-appindicator

You may also need:

sudo apt-get install wmctrl

This library will be needed for creating the actual app indicator.

Next, open your favorite editor (I use atom) or the python IDLE and start a new file. Add the code below:

import gobject
import gtk
import appindicator
import os, sys
import time
from datetime import timedelta

if __name__ == "__main__":

 saveseconds = 0 #global variable to save how many seconds the clock has run
 dir_path = os.path.dirname(os.path.realpath(__file__))
 source_id = ""

 def on_timer(args=None):
 savetime = int(time.time() - timestart) + saveseconds
 ind.set_label(str(timedelta(seconds=savetime)))
 return True

 def finish(args=None):
 sys.exit()
 return True

 def stoptime(args=None):
 #print(source_id)
 global saveseconds
 saveseconds += int(time.time() - timestart)
 gtk.timeout_remove(source_id)
 return True

 def starttime(args=None):
 global timestart
 timestart = time.time()
 global source_id
 source_id = gtk.timeout_add(1000, on_timer)
 #sets timer to run every 1s
 return True

 def cleartime(args=None):
 global saveseconds
 saveseconds = 0
 ind.set_label(str(timedelta(seconds=0)))
 gtk.timeout_remove(source_id)
 return True

 #format below is (id, icon_name, category, icon_theme_path)
 ind = appindicator.Indicator ("elapses", "hourglass", appindicator.CATEGORY_APPLICATION_STATUS, dir_path)
 ind.set_status (appindicator.STATUS_ACTIVE)
 ind.set_label("Elapses"); #name of program and initial display

 ##Setup Menu Items
 menu = gtk.Menu()

 stop = gtk.MenuItem("Stop")
 stop.connect("activate", stoptime) 
 stop.show()
 menu.append(stop)

 start = gtk.MenuItem("Start")
 start.connect("activate", starttime) 
 start.show()
 menu.append(start)

 clear = gtk.MenuItem("Clear")
 clear.connect("activate", cleartime) 
 clear.show()
 menu.append(clear)

 exit = gtk.MenuItem("Exit")
 exit.connect("activate", finish) 
 exit.show()
 menu.append(exit)

 ind.set_menu(menu) #set the menu with added items
 gtk.main()

Save this to a file with a .py extension. I named mine elapses.py. Edit the following line:

ind = appindicator.Indicator ("elapses", "hourglass", appindicator.CATEGORY_APPLICATION_STATUS, dir_path)

The format above follows: (id, icon_name, category, icon_theme_path).  To make the icon show up place a icon image file in the folder (dir_path) with your .py file and change the file name above. If you put it in another folder other than the current one, replace dir_path with the location of the icon.

To make this executable use the chmod function as such:

chmod +x elapses.py

To make a desktop launcher use (edit with your own paths) and save as elapses.desktop:

#!/usr/bin/env xdg-open

[Desktop Entry]
Encoding=UTF-8
Version=1.0
Type=Application
Terminal=false
Exec=python /YOURPATH/YOURLOCATION/TOFILE/elapses.py
Name=Elapses
Comment=Stop Watch
Icon=/YOURPATH/YOURLOCATION/TOFILE/DESKTOPICONIMAGE.svg

 

GitHub code will be uploaded soon!

 

Resources/Tutorials that helped me along the way:

http://candidtim.github.io/appindicator/2014/09/13/ubuntu-appindicator-step-by-step.html

https://gist.github.com/philayres/1309895