Skip to main content

Open source retina model architectures and training setups

Project description

OpenRetina

Ruff mypy pytorch lightning hydra DOI

huggingface

Open-source repository containing neural network models of the retina. The models in this repository are inspired by and contain adapted code of sinzlab/neuralpredictors. Accompanying preprint: openretina: Collaborative Retina Modelling Across Datasets and Species.

Installation

openretina supports installation via pip.

# (Recommended) using a package manager like uv
uv pip install openretina

# Or directly via pip if you prefer
pip install openretina

If you want to train your own models, run Jupyter notebooks, contribute to the project, or modify the source code of openretina, we recommend to install from source. Consider using uv, a fast and flexible project and package manager. If you are not familiar with uv, check out their simple quickstart guide.

git clone git@github.com:open-retina/open-retina.git
cd open-retina

# Sync with uv
uv sync --extra dev

# Alternatively, install in editable mode via pip. 
pip install -e .[dev]

Test openretina by downloading a model and running a forward pass:

import torch
from openretina.models import *

model = load_core_readout_from_remote("hoefling_2024_low_res", "cpu")
responses = model.forward(torch.rand(model.stimulus_shape(time_steps=50)))

Contributing

Before raising a PR please run:

# Fix formatting of python files
make fix-formatting

# Run type checks and unit tests
make test-all

Design decisions and structure

With this repository we provide already pre-trained retina models that can be used for inference and intepretability out of the box, and dataloaders together with model architectures to train new models. For training new models, we rely on pytorch lightning in combination with hydra to manage the configurations for training and dataloading.

The openretina package is structured as follows:

  • modules: pytorch modules that define layers and losses
  • models: pytorch lightning models that define models that can be trained and evaluated (i.e. models from specific papers)
  • data_io: dataloaders to manage access of data to be used for training
  • insilico: Methods perform insilico experiments with above models
    • stimulus_optimization: optimize inputs for neurons of above models according to interpretable objectives (e.g. most exciting inputs)
    • future options: gradient analysis, data analysis
  • utils: Utility functions that are used across above submodules

Related papers and data sources

The paper Most discriminative stimuli for functional cell type clustering explains the discriminatory stimulus objective we showcase in notebooks/most_discriminative_stimulus.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

openretina-1.1.0.tar.gz (197.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

openretina-1.1.0-py3-none-any.whl (226.0 kB view details)

Uploaded Python 3

File details

Details for the file openretina-1.1.0.tar.gz.

File metadata

  • Download URL: openretina-1.1.0.tar.gz
  • Upload date:
  • Size: 197.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for openretina-1.1.0.tar.gz
Algorithm Hash digest
SHA256 54673d57f1ab90b6e83985bc5d03a5d736da050ef4975e0c486c4c000b0080b2
MD5 32f79905ec0b4d31bab226b65ca62a38
BLAKE2b-256 6b88e58a1488cb006b74d6c32e8e8b8d8ff3be9326e2bf37dd102b6b841c1781

See more details on using hashes here.

Provenance

The following attestation bundles were made for openretina-1.1.0.tar.gz:

Publisher: publish-to-pypi.yml on open-retina/open-retina

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file openretina-1.1.0-py3-none-any.whl.

File metadata

  • Download URL: openretina-1.1.0-py3-none-any.whl
  • Upload date:
  • Size: 226.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for openretina-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 584b893e95aeb7059519811b8397a6c9bac4113cb66dea344b9753f777d1646f
MD5 09de4ed60cbaa83e67943d256f115ee9
BLAKE2b-256 1742b707267984bf77e2f32a94926d5d8f3569af268d3fdf9c7a94a314ebd41a

See more details on using hashes here.

Provenance

The following attestation bundles were made for openretina-1.1.0-py3-none-any.whl:

Publisher: publish-to-pypi.yml on open-retina/open-retina

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page