Inspiration

For the past year, I have been working in a hospital's neurosurgery department, focusing on studying and treating patients with intractable drug-resistant epilepsy. To determine the best course of treatment, these patients are implanted with electrodes that reach deep into their brain for multiple weeks, allowing neurologists to determine the seizure onset location by observing their neurons' activity. I have observed that for 1 in every 3 of my patients, the surgery is unsuccessful in determining the best next steps for their treatment, meaning they took the risk of having 12 holes drilled into their skull and 96 microwires implanted into their brain for no reward.

During the surgery, the neurosurgeons only have access to the physical location of the electrodes, which provides little information about the epilepsy onset region. I believe that the success rate of the surgery could be much improved if they could also see the activity of individual neurons, allowing them to correct their initial location estimates and better determine where to implant. A more informed implantation area with a higher yield of neuronal activity would also reduce the amount of time the electrodes must remain in the patient's brain for observation and data collection after the surgery.

What it does

RT-Treat is a real-time analysis software that connects to the electrodes implanted in the patients' brain, receiving live streams of hundreds of neuronal signals in parallel. The software automatically analyzes hundreds of neurons' activity in parallel. This includes determining how many neurons are present, where the neurons are most active, and when they send signals to communicate with each other. Then, RT-Treat generates easy-to-understand plots that are continuously updated to provide the most pertinent information succinctly without confusing the neurosurgeons and prolonging the surgery.

How I built it

With C++, I use a proprietary API to connect to the electrodes and receive their signals in real time. There is one C++ process for each of 96 electrodes, and each process sends its data through TCP to a unique Python process which identifies with sub-millisecond precision when a neuron releases a signal and when. This involves a custom algorithm built from carefully chosen components of many different algorithms published in the neuroscience literature to achieve maximum performance with minimum latency. Each Python process also plots the relevant information when deemed necessary.

Challenges I ran into

The API to connect the electrodes does not work with Python (which is most familiar to me and easiest to write analysis pipelines on), so I had to use a custom C++ script as a intermediary between the electrodes and my analyses, resulting in 3 asynchronous processes running for each of the total 96 electrodes in parallel. Ensuring that the signal was properly communicated with millisecond latency all the way from electrode to graphed figure was extremely difficult.

Additionally, creating the algorithm to decode the raw neural signals (which are just a one-dimensional voltages over time) in real time required a huge amount of planning and debugging. The algorithms and analyses commonly used in the neuroscience literature are designed to be used after all of the data has been collected and often take hours to run, meaning I had to cleverly alter them and write my own to ensure the software could provide feedback to the neurosurgeons during the experiment.

It was difficult to decide exactly what should be shown to the neurosurgeons. Too much information would clutter their minds and distract them from the surgery while too little would not be much help. In the end, I decided on a simple layout with the neurons' waveforms as a middle ground.

Accomplishments that I'm proud of

I am very proud of RT-Treat being able to analyze neural signals and create figures showing the results in real time. It is one of the first software systems in the world (and the first in the United States) to do this. Almost all neurologists and neuroscientists use slow computationally expensive algorithms to analyze their data after the surgery or recording session has long passed.

What I learned

I learned how to create highly asynchronous and parallel processes that communicate with each other for millisecond response time and how to design new algorithms to analyze neural signals in real time.

What's next for RT-Treat: Real-time neuronal analysis for epilepsy treatment

I will show this demo to my research professor and head neurosurgeon to hear their thoughts. If they like it, we will go through the necessary steps (ensuring the software is robust, obtaining IRB approval, etc.) to test RT-Treat on real patients during real surgeries. If that goes well, we will create a company selling this software and real-time analysis software in general to other hospitals and companies making brain computer interfaces. While RT-Treat in its current form is for a particular use case, the general principle of analyzing neural signals in real time can be applied to many other areas of neuroscience, such as non-invasive EEG recordings. Further, all current brain-computer-interface technology uses neural signals averaged across hundreds or even thousands of neurons, resulting in low resolution decoding of user intent. On the contrary, RT-Treat deciphers the responses of individual neurons. Applying this to brain computer interfaces could result in a revolution in the field.

Built With

Share this project:

Updates