Tissue Segmentation

← Back to projects

Context: Machine Learning Engineer Intern · Functional Genomics Laboratory Regensburg · 2024
Focus: Unsupervised learning · High-dimensional scientific data · Spatial clustering

I developed a machine-learning workflow for identifying tissue regions and molecular patterns in DESI mass-spectrometry imaging (DESI-MSI) data.

The task combined scientific data engineering with unsupervised learning: raw molecular-intensity measurements first had to be cleaned and transformed into an analysis-ready representation before PCA and K-means clustering could reveal spatial structure.

View the public implementation on GitHub →

Project snapshot

MetricResult
Data-footprint reduction40%
PCA selection criterion95% explained variance
Tissue segmentation4-cluster K-means
ValidationConsistency across follow-up scans
Public sample PCA result15 components ≈ 99% explained variance
Learning settingUnsupervised

The challenge

Mass-spectrometry imaging records a molecular spectrum at each spatial coordinate. This creates a high-dimensional dataset in which every point can contain many molecular-intensity features.

The goal was to identify spatially coherent tissue-related regions without manually annotated tissue labels.

The main challenges were therefore:

Data preparation

I built Python-based preprocessing steps for cleaning, restructuring and analysing the MSI data.

Through data cleaning, redundancy removal and optimized export, the high-dimensional data footprint was reduced by approximately 40% before downstream analysis.

The public implementation supports several exported MSI table structures, including:

After preprocessing, each observation is represented by spatial coordinates and a vector of molecular-intensity features.

Raw DESI-MSI export
Cleaning and restructuring
Spatial coordinates + molecular features
PCA
K-means clustering
Spatial cluster map
Follow-up scan comparison

Dimensionality reduction with PCA

The molecular feature space was reduced with Principal Component Analysis before clustering.

For the internship analysis, I used a 95% explained-variance threshold to retain the dominant molecular variation while reducing the dimensionality of the clustering problem.

The public repository also includes cumulative explained-variance analysis. On one included sample dataset, approximately 15 principal components were sufficient to explain 99% of the variance.

PCA explained variance

Tissue-region detection with K-means

I applied K-means clustering with four clusters to identify spatially distinct tissue and molecular-density regions.

Cluster assignments were then mapped back to the original X/Y coordinates to generate spatial segmentation maps.

The public implementation also includes an elbow-method workflow for inspecting within-cluster sum of squares across candidate values of k.

Elbow method

A representative spatial cluster map from the public implementation:

DESI-MSI cluster map

Validation across follow-up scans

Because this was an unsupervised segmentation task, the work was not evaluated with a conventional labelled classification accuracy.

Instead, I checked whether the identified tissue regions and anomalous molecular patterns remained consistent across follow-up scan series, using molecular-density distributions and spatial visualisations to compare the results.

This made the clustering output useful for scientific interpretation rather than treating K-means labels as an end result by themselves.

Engineering the workflow

The public version was structured as a reusable Python project rather than a single analysis notebook.

It separates the workflow into dedicated modules for:

The repository also separates raw data, processed data and generated figures, making the analysis easier to reproduce and extend.

What I contributed

What this project demonstrates

This project shows my ability to work with high-dimensional, noisy scientific data where the correct ML workflow starts before model fitting.

It combines data engineering, dimensionality reduction, unsupervised learning, quantitative inspection, spatial visualisation and domain-driven validation.

Core technologies: Python · pandas · NumPy · scikit-learn · PCA · K-means · Matplotlib · Scientific Computing · Mass-Spectrometry Imaging

View source on GitHub →

← Back to projects