Signal analysis for brain surgery
During brain tumour surgery, the motor pathways are tested every few minutes with electrical pulses. For my bachelor thesis with the neurosurgery department of Inselspital Bern, I analysed 14,668 of these muscle responses and trained neural networks to recognise which muscle a signal comes from.
- Role
- Bachelor thesis, BFH
- Partner
- Inselspital Bern, neurosurgery
- When
- 2023
- Degree
- BSc Medical Informatics, with distinction
First prize, DMEA Berlin
Best bachelor thesis in digital health. A jury picks five finalists who pitch live on stage; second place went to the Max Planck Institute for Evolutionary Anthropology.
BFH press releasePrix d'excellence, best implementation
Awarded by the Spitalzentrum Biel to the best bachelor theses in medical informatics at BFH.
BFH press releaseJournal of Medical Internet Research
Peer-reviewed follow-up study with 201 patients from two hospitals, in which my approach was the best model at the second hospital. Co-author.
doi.org/10.2196/63937
- StimulateFive electrical pulses, 4 ms apart, run from the stimulator to corkscrew electrodes in the scalp and excite the motor cortex.
- ConductThe signal runs down the motor pathway, close to the tumour, and crosses to the other side of the body in the lower brainstem.
- RespondMuscles in the forearm, thumb, shin and foot twitch. Needle electrodes pick up the response and send it back.
- ReadThe four responses appear on the monitor: the arm after about 18 to 20 ms, the foot after about 40 ms.
- WarnIf a response shrinks to less than half of its baseline, the monitoring team warns the surgeon, who can pause or change course.
Why it matters
Tumours often grow next to the pathways that move the arms and legs. Damage to them can leave a patient paralysed. Motor evoked potentials (MEP) show during the operation whether these pathways still work, so the surgical team can react in time.
Reading them is hard. The signals vary a lot between patients and within one operation, and in practice mostly the amplitude is watched. Outcome data after surgery was not yet available, so the first question was simpler: can a model tell which muscle a signal comes from? That is the groundwork for models that predict deficits, and it can catch swapped electrodes. I also watched the monitoring live during a brain operation.
Try it
A simulation built on the values of my thesis: 100 ms per response, five pulses at the start, the typical peak latency of each muscle. Press Stimulate. Then drag the slider: it stands for surgery closer to the pathway of the hand. The thumb and forearm responses shrink, the leg responses barely change, and below half of the first response the warning appears.
Scalogram
How to read it. Each row is one muscle, from stimulation (0 ms) to 100 ms. The shaded strip (0 to 17.5 ms) holds the five stimulation pulses; this part is cut off before the analysis. The dotted line marks the typical peak latency of the muscle. Once a response gets clearly smaller, the first response appears as a grey dashed curve for comparison.
The scalogram below turns the selected response into an image: time from left to right, frequency from top (312 Hz) to bottom (21 Hz), darker means a stronger oscillation. It is drawn on the scale of the first response, so a weaker response looks paler. For training, each scalogram was normalised on its own. Click or tap a row to choose the muscle; the selected one stays marked in violet.
Generated signals, not recordings. The shape is simulated: a few phases plus small motor unit spikes, slightly different with every stimulation and new for every simulated patient. The latencies (medians from my thesis) and the processing follow the thesis. Percentages compare the peak to peak amplitude after 17.5 ms with the first stimulation. The muscle guess uses peak latency and main frequency, the two strongest features in the follow-up study; it is a simple rule, not the trained network.
Method and result
- Data.14,668 responses from 30 patients, four muscles each, 2,000 samples per response (100 ms at 20 kHz).
- Cleaning.Signals without a clear response were removed with the hospital's rule: at least 1 and fewer than 11 peaks above twice the standard deviation after the stimulation.
- Scalograms.Continuous wavelet transform with a Mexican hat wavelet, 224 logarithmic scales from 21 to 312 Hz, after cutting the first 17.5 ms of stimulation.
- A leak found with Grad-CAM.A first model reached 99.7 %. Grad-CAM showed it was reading the stimulation artefact, which is specific to each patient. I removed the artefact and tested only on patients the model had never seen.
- Result.VGG-19 with transfer learning 83 %, a small CNN trained from scratch 73 %. With the timing of the responses standardised, accuracy fell to 31 %: the latency carries most of the information.
- Seeing trends.Scalograms of consecutive stimulations made changes during an operation easier to spot than raw traces.
Follow-up study
The neurosurgery teams of Inselspital Bern and the Cantonal Hospital of Lucerne continued the work with 201 patients and 61,290 responses. The study compared random forests and neural networks on time series, on hand-picked features and on wavelet scalograms. My approach from the thesis, a 2D CNN on scalograms, gave the best result at the second hospital: trained in Bern and tested in Lucerne without changes, it reached 81.9 %.
The explainability analysis showed latency as the strongest feature, followed by the main frequency: distal muscles such as the thumb respond at higher frequencies. The authors propose such models as a safety check against swapped electrodes, and frequency as a candidate for new warning criteria. I am a co-author.
Parduzi, Q., Wermelinger, J., Koller, S. D., Sariyar, M., Schneider, U., Raabe, A., and Seidel, K. (2025). Explainable AI for intraoperative motor-evoked potential muscle classification in neurosurgery: bicentric retrospective study. Journal of Medical Internet Research, 27, e63937. doi.org/10.2196/63937