SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2603.23794 · 2026

Sparse Autoencoders for Interpretable Medical Image Representation Learning

Sergios Gatidis, Robbie Holland, Vasiliki Sideri-Lampretsa, Philipp Wesp

arXiv · PDF · Open in the Atlas

Code that ran

8 of 11 samples (functions and classes) lifted from this paper's linked repositories executed on a synthesized input in Syntology's jail (0 of them constructed an object rather than computing a result; 0 honoured the contract we drafted, 0 violated it and 0 have no contract verdict; 8 failures of our instrument; 3 no recorded run), measured 2026-11-23; bodies inline only under a permissive licence as GitHub detects it. Not a reproduction of the paper's results.

"Ran" means the function executed on a synthesized input and returned a value. It is not a reproduction of the paper's results. This record, dated, as JSON: /api/ran/2603.23794.json · badge: /api/ran/2603.23794.svg

Each repository's role is a label: a classifier's output recorded on the link, or, where no role is recorded, what the Papers with Code archive marked. The line under it names its basis. Neither says who wrote the code.

RepositoryRoleRan
pwesp/sail canonical (classifier label)
classifier basis: census
8 ran · 3 no recorded run
FunctionStatusWhere it lives
clean_concept_description Ran
ran; our contract draft was wrong, not the code
pwesp/sail/src/autointerp.py
code served (permissive licence) · get_code("98d7b05264eec734")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned str. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import re

def clean_concept_description(text: str) -> str:
    """
    Remove common boilerplate phrases from VLM concept outputs.

    This is a safety net for cases where the VLM doesn't fully follow prompt instructions.

    Patterns removed:
    - "These images show/demonstrate/depict..."
    - "The images consistently/predominantly..."
    - "All images..."
    - Leading "Consistently", "Predominantly"

    Args:
        text: Raw VLM output

    Returns:
        Cleaned concept description
    """
    import re
    patterns = ['^These (?:axial |coronal |sagittal )?(?:CT |MRI |images? )?(?:consistently |predominantly )?(?:show|demonstrate|depict|feature|present)\\s+', '^The (?:images? |scans? )?(?:consistently |predominantly )?(?:show|demonstrate|depict|feature|present)\\s+', '^All (?:images? |scans? )?(?:consistently |predominantly )?(?:show|demonstrate|depict|feature|present)\\s+', '^(?:Consistently|Predominantly),?\\s+']
    cleaned = text
    for pattern in patterns:
        cleaned = re.sub(pattern, '', cleaned, flags=re.IGNORECASE)
    if cleaned and cleaned[0].islower():
        cleaned = cleaned[0].upper() + cleaned[1:]
    return cleaned.strip()


# Test inputs
ARGS = {
    "text": "These CT images demonstrate a nodule in the lower lobe. The findings are consistent with malignancy."
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
none outside the standard library — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type str — a str output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a str output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
extract_top_k_dense_features Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
pwesp/sail/src/fingerprint_retrieval.py
code served (permissive licence) · get_code("d3bca2d9014db5cd")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned tuple, ndim 2, dtype family float; no output shape is stated. The image it ran in was not recorded. If your copy returns the same type and ndim on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import numpy as np

# Create a small dense features array with shape (N, D) = (2, 4)
# This gives us 2 samples with 4-dimensional embeddings
dense_features = np.array([
    [0.1, -0.8, 0.3, -0.9],
    [0.5, 0.2, -0.6, 0.1]
], dtype=np.float32)

# Reference image index
array_idx = 0

# Number of top features to extract
k = 2

ARGS = {
    "dense_features": dense_features,
    "array_idx": array_idx,
    "k": k
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type tuple, ndim 2, dtype family float — a tuple output has no array shape of its own; none is stated
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
extract_top_k_sparse_features Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
pwesp/sail/src/fingerprint_retrieval.py
code served (permissive licence) · get_code("ff869560566344a4")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned tuple, ndim 2, dtype family float; no output shape is stated. The image it ran in was not recorded. If your copy returns the same type and ndim on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import numpy as np

# Create sparse features array with shape (N, D)
# N=3 samples, D=5 features
sparse_features = np.array([
    [0.1, 0.5, 0.0, 0.9, 0.2],
    [0.3, 0.2, 0.8, 0.1, 0.6],
    [0.0, 0.7, 0.4, 0.3, 0.5]
], dtype=np.float32)

# Index into the sparse_features array
array_idx = 1

# Number of top features to extract
k = 3

# Set of feature indices that are always active (to be excluded)
always_active_features = {0}

# Optional set of allowed features to restrict selection
allowed_features = {1, 2, 3, 4}

ARGS = {
    "sparse_features": sparse_features,
    "array_idx": array_idx,
    "k": k,
    "always_active_features": always_active_features,
    "allowed_features": allowed_features,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type tuple, ndim 2, dtype family float — a tuple output has no array shape of its own; none is stated
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
find_always_active_features Ran
ran; our contract draft was wrong, not the code
pwesp/sail/src/fingerprint_retrieval.py
code served (permissive licence) · get_code("dc0cee3539cfdc09")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned set. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import numpy as np

# Create a small sparse features array
# N=5 images, D=4 features
# Feature 0 is always active (>0)
# Feature 1 is sometimes 0
# Feature 2 is sometimes 0
# Feature 3 is always active (>0)
sparse_features = np.array([
    [1.0, 0.0, 0.5, 2.0],
    [1.0, 0.2, 0.0, 1.5],
    [0.5, 0.0, 0.3, 3.0],
    [2.0, 0.1, 0.0, 0.5],
    [0.3, 0.0, 0.2, 1.0]
], dtype=np.float32)

ARGS = {
    "sparse_features": sparse_features
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type set — a set output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a set output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
format_time Ran
ran; our contract draft was wrong, not the code
pwesp/sail/src/downstream_clf.py
code served (permissive licence) · get_code("444f91992acc54c4")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned str. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch

torch.manual_seed(0)

# The function format_time takes a single parameter: seconds (a float)
# It performs arithmetic operations and string formatting on this float
# No complex objects needed

ARGS = {
    'seconds': 125.7
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type str — a str output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a str output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
get_image_path Ran
ran; our contract draft was wrong, not the code
pwesp/sail/src/dataloading.py
code served (permissive licence) · get_code("4ef4b1e30ee8bb9c")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned PosixPath. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import tempfile
from pathlib import Path

class TotalSegmentatorLatentFeaturesDataset:
    def __init__(self, metadata):
        self.metadata = metadata

# Create temporary directory with a dummy image file
temp_dir = tempfile.mkdtemp()
image_path = Path(temp_dir) / "image_0.nii.gz"
image_path.touch()

# Create metadata dataset with image paths
metadata_dataset = TotalSegmentatorLatentFeaturesDataset(
    metadata={
        'image_path': [
            str(image_path),
            str(Path(temp_dir) / "image_1.nii.gz")
        ]
    }
)

# Create the second image file so it exists
(Path(temp_dir) / "image_1.nii.gz").touch()

array_idx = 0

ARGS = {
    'metadata_dataset': metadata_dataset,
    'array_idx': array_idx
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
none outside the standard library — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type PosixPath — a PosixPath output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a PosixPath output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
get_reference_metadata Ran
ran; our contract draft was wrong, not the code
pwesp/sail/src/dataloading.py
code served (permissive licence) · get_code("eba0805256b1bfc2")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned dict. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import numpy as np

class TotalSegmentatorLatentFeaturesDataset:
    """Mock dataset class matching the function's expected interface."""
    def __init__(self):
        # Create sample data with matching indices
        n_samples = 5
        
        # Arrays that will be indexed
        self.image_ids = np.array(['s0001', 's0001', 's0002', 's0003', 's0004'])
        self.slice_indices = np.array([0, 1, 0, 5, 10])
        self.modalities = np.array(['CT', 'CT', 'MRI', 'CT', 'MRI'])
        self.slice_orientations = np.array(['z', 'z', 'x', 'y', 'z'])
        
        # Metadata dictionary with all possible fields
        self.metadata = {
            'gender': np.array(['m', 'f', 'm', 'unknown', 'f']),
            'age': np.array([45.5, 62.0, None, 38.0, 71.5]),
            'pathology': np.array(['healthy', 'tumor', 'healthy', 'cyst', 'healthy']),
            'pathology_location': np.array(['none', 'liver', 'none', 'kidney', 'none']),
            'adrenal_gland_left': np.array([True, True, False, True, False]),
            'adrenal_gland_right': np.array([True, False, True, False, True]),
            'aorta': np.array([True, True, True, True, True]),
            'kidney_left': np.array([False, True, False, True, False]),
            'kidney_right': np.array([True, False, True, False, True]),
            'liver': np.array([True, True, True, False, True]),
            'lung_left': np.array([True, True, False, True, True]),
            'lung_right': np.array([True, True, False, True, True]),
            'heart': np.array([False, True, False, False, True]),
        }

# Create the mock dataset
metadata_dataset = TotalSegmentatorLatentFeaturesDataset()

# Define arguments for the function
ARGS = {
    'metadata_dataset': metadata_dataset,
    'image_id': 's0001',
    'slice_idx': 0,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type dict — a dict output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a dict output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
setup_target_group_logging Ran
ran; our contract draft was wrong, not the code
pwesp/sail/src/downstream_clf.py
code served (permissive licence) · get_code("14794569c3c48c42")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned PosixPath. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

from pathlib import Path
import tempfile

# Create a temporary directory for logging
temp_dir = tempfile.mkdtemp()
log_dir = Path(temp_dir)

# Define arguments for the function
ARGS = {
    "log_dir": log_dir,
    "target_group": "age_group"
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
none outside the standard library — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type PosixPath — a PosixPath output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a PosixPath output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
load_vlm_model Not yet run
unverified (harvested, no recorded run)
pwesp/sail/src/autointerp.py
code served (permissive licence) · get_code("b05325d59532790c")
How it ran

no invocation recorded.

map_organs_to_anatomical_regions Not yet run
unverified (harvested, no recorded run)
pwesp/sail/src/clinical_region_mapping.py
code served (permissive licence) · get_code("1489116d7926a86c")
How it ran

no invocation recorded.

setup_job_logging Not yet run
unverified (harvested, no recorded run)
pwesp/sail/src/downstream_clf.py
code served (permissive licence) · get_code("d2c0e7176210ae61")
How it ran

no invocation recorded.

Also present in other papers' code

Of 11 samples lifted from this paper's linked repositories, 11 carry a function identity and 0 do not. Of the 11 distinct functions with an identity, 0 are also present in other papers whose code we hold (0 with at least one paper dated earlier, 0 the same month, 0 later) and 11 are only here among the 52,977 papers whose code Syntology holds (as of 2026-09-26).

Only here means: among the 52,977 papers whose code Syntology holds (51,887 with lifted samples, 1,090 through their assemblies only), as of 2026-09-26, no other paper's lifted samples or current assembly bricks contain an identical function body after normalisation.

Presence, not direction: an identical function body in two papers' repositories does not say who wrote it, which came from which, or that either paper's method rests on it. Matching is exact after normalisation, so a renamed or edited function is not matched. Dates are when papers appeared, not when code was written. Only .py files the harvester lifted are covered; notebooks are not read. A new-style arXiv id YYMM.NNNN dates a paper to the month 20YY-MM; otherwise Paper.year dates it to the year; otherwise it is undated. Dates are when the paper appeared, not when the code was written. Read 2026-11-23.

Repositories linked to this paper

Some links come from the archived Papers with Code dataset (CC BY-SA 4.0): attribution and licence.

Abstract

Vision foundation models (FMs) achieve state-of-the-art performance in medical imaging. However, they encode information in abstract latent representations that clinicians cannot interrogate or verify. The goal of this study is to investigate Sparse Autoencoders (SAEs) for replacing opaque FM image representations with human-interpretable, sparse features. We train SAEs on embeddings from BiomedParse (biomedical) and DINOv3 (general-purpose) using 909,873 CT and MRI 2D image slices from the TotalSegmentator dataset. We find that learned sparse features: (a) reconstruct original embeddings with high fidelity (R 2 up to 0.941) and recover up to 87.8 % of downstream performance using only 10 features (99.4 % dimensionality reduction), (b) preserve semantic fidelity in image retrieval tasks, (c) correspond to specific concepts that can be expressed in language using large language model (LLM)-based autointerpretation. (d) bridge clinical language and abstract latent representations in zero-shot language-driven image retrieval. Our work indicates SAEs are a promising pathway towards interpretable, concept-driven medical vision systems. Code repository: https://github.com/pwesp/sail.

For agents

The same record, over MCP at https://syntology.ai/mcp:

get_harvested_code_for_paper("2603.23794")
get_code_for_paper("2603.23794")
have("2603.23794")

The run record, dated, one paper per request, free:

curl https://syntology.ai/api/ran/2603.23794.json

A badge for a README (the split and the date, never a ratio):

[![Syntology run record](https://syntology.ai/api/ran/2603.23794.svg)](https://syntology.ai/paper/2603.23794)

Connect an agent — have() is free.