Skip to main content

SimNorth

Contrastive self-supervised representation learning for ultrasound frames.

SimNorth maps frames onto the unit hypersphere with three objectives:

  1. Alignment — two augmented views of the same frame are pulled together.
  2. Uniformity — randomly paired views are pushed apart with a rank-based weighting, so the most-similar (likely true-negative) random pairs are penalized the most.
  3. North / light house — a set of fixed anchor points ("light houses") on the sphere attract their nearest embeddings, organizing the learned manifold around well-separated anchors.

Built on PyTorch Lightning 2.x with MLflow experiment tracking.

Install

pip install -e .
# or
pip install -r requirements.txt

Data format

A CSV or Parquet table with one row per frame and a column of image paths (default img_path), resolved relative to --mount_point. Frames are read with SimpleITK; single-channel frames are promoted to 3 channels.

Usage

Optionally pre-compute well-separated light house anchors:

python pretrain_lighthouse.py --n_lights 64 --emb_dim 128 --out lights.pkl

Train:

python train.py \
    --csv_train train.parquet --csv_valid valid.parquet --csv_test test.parquet \
    --mount_point /data/frames \
    --base_encoder efficientnet_b0 --emb_dim 128 --hidden_dim 64 --n_lights 64 \
    --batch_size 256 --epochs 200 --lr 1e-4 \
    --lights lights.pkl \
    --tracking_uri file:./mlruns --experiment_name SimNorth --run_name effnet_b0

If --lights is omitted, anchors are initialized uniformly at random.

Inspect runs:

mlflow ui --backend-store-uri ./mlruns

Package layout

simnorth/
├── nets/
│   ├── simnorth.py    # SimNorth, ProjectionHead, GaussianNoise
│   └── lighthouse.py  # LightHouse anchor optimizer
├── data/
│   ├── dataset.py     # USDataset, USDataModule
│   └── transforms.py  # paired augmentation transforms
└── callbacks/
    └── image_logger.py  # logs augmented-view grids to MLflow
train.py                  # training entrypoint (MLflow)
pretrain_lighthouse.py    # optional anchor pre-optimization

Provenance

Extracted and modernized from the us-famli-pl research codebase (nets/contrastive.py, contrastive_learning.py). Compared to the original:

  • Upgraded from pytorch_lightning to the lightning 2.x API.
  • Switched experiment logging from Neptune to MLflow.
  • SimNorth takes explicit hyperparameters instead of an args namespace.
  • Fixed a copy-paste bug in the north loss where the second view's nearest index was taken from the first view (z_1_n now uses the z_1 index).

Metadata

Release files for simnorth 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for simnorth 0.1.0
File Size Uploaded
simnorth-0.1.0.tar.gz 9.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for simnorth 0.1.0
File Interpreter ABI Platform
simnorth-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 20.4 kB

Release files / simnorth-0.1.0.tar.gz

Download URL simnorth-0.1.0.tar.gz
Size 9.7 kB
Tags Source
SHA-256 checksum
How to use checksums
083b3cf48978b3f509f7e833f6718da322bdf24fac736fe83ad3b5bd0476dd71
BLAKE2b-256 checksum
How to use checksums
c49a8b46a316cccad810e5ff640f23406d9ea2f1e1e2f16efc6d9d94e701dd07
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jun 1, 2026.

Transparency log

Release files / simnorth-0.1.0-py3-none-any.whl

Download URL simnorth-0.1.0-py3-none-any.whl
Size 10.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
9b40fbb3875fc2c4f0e0356ff9c9a06ccccb0f5e7c17ddb1df765db57bdd45a2
BLAKE2b-256 checksum
How to use checksums
6ab0665cf7f451c2a636cab4e75c357fb705a263b2cc425419ded3d73e1f8341
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jun 1, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page