API Documentation#
API reference for the neurovlm module.
Table of Contents#
Inference#
The legacy high-level interface remains available for text, NIfTI, and retrieval workflows.
|
Unified interface for text-to-brain and brain-to-text. |
|
Container for brain retrieval or generation outputs. |
|
Container for text retrieval scores and metadata. |
|
Chainable wrapper around a top-k brain result table. |
Structured runtime#
Task-oriented tensor inference selects the family, task, domain, variant, and released checkpoint or local run explicitly. CNN domain tasks default to the mixed baseline; fine-tuning is explicit.
|
Resolve and load an inference pipeline. |
|
A resolved model pipeline with consistent tensor-level methods. |
|
Resolved inference selection, suitable for logs and manifests. |
Data#
Fetches from huggingface and loads.
Fetching#
|
Fetch NeuroVLM data from Hugging Face repositories. |
|
Alias to _load_* functions in retrieval resources. |
Embeddings#
Pre-computed latent vectors for text and neuroimages.
|
Alias to _load_latent* functions in retrieval resources. |
Masker#
Nifti masker need to resample and mask neuroimages.
Masker alias. |
Atlas-free CNN datasets#
Published split JSONLs and their shared volume tensor. Legacy per-row local paths are ignored.
|
A split view over the shared atlas-free CNN volume tensor. |
|
Lazily provide validated train, validation, and test dataset views. |
|
Return all three atlas-free CNN split views with shared resources. |
Models#
Base models for autoencoder, projection heads, and specter. Pretrained models return from load_model or calling .from_pretrained on model classes.
|
Autoencoder for neuro-vectors. |
|
Align latent tensors. |
|
Wrapper for Specter model. |
|
Load a packaged model by legacy name or structured fields. |
The structured selectors are defined in the model registry:
|
Supported model architecture families. |
|
Public task identifiers shared by training and inference code. |
|
Datasets with released domain-specific CNN checkpoints. |
|
Canonical variants of released model artifacts. |
|
An immutable, fully resolved model artifact specification. |
|
Resolve a legacy alias or structured selection to a canonical spec. |
Atlas-Free CNN#
Installable 3D CNN architectures and conversion helpers for the MLP and CNN
input spaces. Pretrained instances are returned by load_model.
|
Brain and text encoders aligned in a shared normalized space. |
|
Generate a dense brain volume from a precomputed SPECTER2 embedding. |
|
Convert cropped CNN volumes to the packaged MLP masker's flat space. |
Scatter packaged MLP flat vectors into cropped CNN volume space. |
Loss Functions#
The pretrained models used InfoNCELoss or MSELoss. Additional options include FocalLoss or TruncatedLoss.
|
Compute symmetric InfoNCE loss between paired image/brain and text embeddings. |
|
|
|
Training#
Standardized task runners#
Typed runners share artifact, metric, checkpoint, provenance, and resume conventions.
|
Typed configuration for mixed pretraining or domain fine-tuning. |
|
Configuration for one domain-specific Stage 3 branch. |
|
Configuration for one domain-specific Stage 4 projector branch. |
|
|
|
|
|
|
Train the retained contrastive heads for brain-to-text retrieval. |
|
|
Train and evaluate a mixed or explicitly fine-tuned CNN autoencoder. |
|
Train, select, and fully evaluate one CNN contrastive branch. |
|
Train a fresh Stage 4 projector with a frozen, provenance-bound AE. |
|
|
|
|
|
|
|
Train symmetric InfoNCE while selecting the brain-to-text direction. |
|
Train only Q-Former parameters against a frozen causal LM. |
Model comparison#
Shared MLP/CNN reconstruction, retrieval, and generation comparisons. The default matrix uses mixed-baseline CNN checkpoints; fine-tuned rows are an explicit opt-in.
|
|
|
|
|
Return MLP plus mixed-baseline CNN selections for a task. |
|
Compare AE reconstruction in each family's declared spatial space. |
|
Evaluate paired full-split retrieval with family-native text preprocessing. |
|
Compare generated maps with paired rows and family-native text inputs. |
Metrics#
Performance metrics.
|
|
|
|
|
Compute dice score. |
|
Compute dice score of top k. |
|
Elementwise Bernoulli negative log-likelihood (cross-entropy), in nats. |
|
y_true: (N, D) floats in [0,1] logits: (N, D) raw logits from decoder (before sigmoid) |