Imaging Oxygen Dips in Mouse Cortex: Semi-NMF for Signal Extraction
Using semi-NMF to find short-lived hypoxic pockets in noisy recordings of the mouse cortex.
My Bachelor’s thesis was about finding brief drops in oxygen in noisy recordings of the mouse cortex. Because the background also changes over time, simple thresholding did not work. We used semi-NMF instead.
Cover image from the related publication write-up.
The problem
I did the project with the Center for Translational Neuromedicine at the University of Copenhagen. A molecule injected into the brain emits light when it binds to oxygen, so brighter pixels mean more oxygen and darker pixels less. We called the brief dark regions “oxygen dips”; the Copenhagen team called them “hypoxic pockets” — they are the experts, after all.
At first, this sounds like a thresholding problem. It is not. The recordings are noisy, their background intensity changes over time, and the pockets grow, move, and fade. A fixed cutoff cannot reliably distinguish a pocket from a change in the background.
Our approach
We represented each video as a matrix of pixels over time. Matrix factorization was a natural fit, but detrending and denoising introduced negative values, so standard non-negative matrix factorization was no longer suitable. We used semi-NMF instead.
The factorization produces two parts:
- a 2D spatial factor (SP) showing where the dip appears, and
- a temporal factor (ST) showing how it changes.
We optimized the two factors in turn until the reconstruction error stopped improving:
\[S_P = \arg\min_{S_P \in \mathbb{R}_+^{p}} \left\| S_{MT}^\top - S_T S_P^\top \right\|_F^2 + \alpha \|S_P\|_1\] \[S_T = \arg\min_{S_T \in \mathbb{R}^{p}} \left\| S_{MT} - S_P S_T^\top \right\|_F^2\]For the sparse spatial update, we used LassoLars.
Result
Signal Extraction and Ground Truth
The data was noisy and the dips were not always well-defined, but the method still found them when they overlapped or had irregular shapes. The sparsity parameter $\alpha$ also gave our collaborators direct control over sensitivity: higher values suppress weaker dips, while lower values retain more of them.
You can read the full thesis here: Neuroscience Image Signal Segmentation and Extraction.
From thesis to paper
Working with the Copenhagen team and our patient, supportive supervisor, Prof. Dr. Michael Graber, was a highlight of the project. I am proud that our work contributed to the Science paper Oxygen imaging of hypoxic pockets in the mouse cerebral cortex.
Dr. Felix Beinlich wrote more about the biological work in his post about the paper.