Dataset¶
Constructors¶
Each of these returns a ready-to-use Dataset.
FlyWire (FAFB).
FlyWire
¶
FlyWire, the whole-brain FAFB reconstruction.
fw = connecto.FlyWire() # public release, mat 783 fw = connecto.FlyWire("production") # live, needs permissions
Source code in connecto/datasets/flywire.py
BANC - the Brain And Nerve Cord dataset.
BANC is the reason connecto treats backend and dataset as orthogonal: it is served
by CAVE (brain_and_nerve_cord_public, materialization 888) and by neuPrint
(banc:v888) - the same snapshot, two backends. So::
connecto.BANC() # neuPrint, the default
connecto.BANC(backend="cave") # CAVE - for the chunkedgraph and the L2 cache
which also gives us a real test that the normalisation is genuine rather than aspirational: both should return the same edges.
BANC
¶
FANC - the Female Adult Nerve Cord.
The female counterpart to MANC, but a CAVE dataset rather than a neuPrint one: an
editable segmentation with a chunkedgraph, so root IDs move and version="auto"
earns its keep.
Two things about FANC are not like the other CAVE datasets, and both are handled in the spec rather than in the backend:
- Its synapse table calls the confidence score
score, notcleft_score. Same concept, different name - hencescore_column. - Its annotations are long:
neuron_informationis one row per (neuron, tag), with the category intag2and the value intag. So a motor neuron carriestag2="primary class", tag="motor neuron". Pivoting it wide turns each category into a column, which is what the rest of connecto expects.
FANC is not public. It needs the FANC_edit group, so an unprivileged token gets a
403 - which connecto reports as a permission problem, not a bad token.
MICrONS - mouse visual cortex.
MICrONS is the forcing function that keeps connecto from quietly becoming a fly
library. It has no side, no fly-style super_class, and its cell types are
spread across several tables produced by different methods (a transformer model,
an SVM on nuclei, a hand-drawn column) rather than living in one canonical column.
So it ships with fields={} beyond the ID: annotations come back raw, with every
native column present and no invented type. That is the honest default. If you
want a type, say which table's opinion you want::
mic = connecto.MICrONS(annotations="mtypes")
mic.annotations.get(fields={"type": ("cell_type",)})
Aedes - the mosquito brain (Wei-Chung Lee lab).
The CAVE datastack is bare: a synapse table, a nucleus table, and no annotation table
at all - no column that means "type" or "side". The project keeps its cell typing
elsewhere, in FlyTable (the lab's SeaTable database): the aedes_main table of the
aedes base. So connecto reads annotations from there rather than from CAVE:
aedes.connectivity.edges(root_ids) # from CAVE
aedes.ids("class:KC") # from FlyTable
FlyTable is lab-internal - it needs a SEATABLE_TOKEN on top of CAVE access, and there
is no public alternative - so the source is public=False. Because it is the only
source, annotations="auto" falls back to it (see DatasetSpec.annotation_source);
a caller without the token gets a clear missing-token error, not a silently empty
frame.
The neuPrint datasets: hemibrain, maleCNS, MANC, fish2.
No optic-lobe. It was a partial release - the optic lobes of the same specimen
that malecns now covers whole - so it was two names for one dataset, and the
narrower one could only ever give you fewer neurons and a different set of body
IDs for them. Use malecns and select the optic-lobe ROIs.
Datasets connecto has never heard of.
Adding a datastack must not require writing a class, or opening a PR:
ca3 = connecto.CAVE("zheng_ca3", fields={"type": ("cell_type",)})
wasp = connecto.NeuPrint("wasp3:v0.8", server="neuprint-pre.janelia.org")
The spec is probed from the server. A probed spec claims fewer capabilities and
has no fields, so ds.ids("DA1_lPN") raises a clear error rather than guessing
which column means "type" - curated specs for the datasets you care about, working
defaults for everything else.
probe_cave
¶
probe_cave(datastack: str, **overrides) -> DatasetSpec
Build a DatasetSpec by asking the CAVE server what it has.
Source code in connecto/datasets/generic.py
probe_neuprint
¶
probe_neuprint(dataset: str, server: str = 'neuprint.janelia.org', **overrides) -> DatasetSpec
Build a DatasetSpec by asking a neuPrint server what it has.
Source code in connecto/datasets/generic.py
CAVE
¶
Any CAVE datastack, without writing a class.
Spec fields (fields, side_map, capabilities, ...) can be passed as
keyword arguments to refine what was probed.
Source code in connecto/datasets/generic.py
NeuPrint
¶
NeuPrint(dataset: str, *, server: str = 'neuprint.janelia.org', version=None, annotations='auto', **overrides)
Any neuPrint dataset, without writing a class.
Source code in connecto/datasets/generic.py
The handle¶
Dataset
¶
Dataset(spec: DatasetSpec, *, backend: str | None = None, version=None, annotations: str | None = 'auto', fields: dict | None = None, edges=None)
Bases: ABC
A connectome you can query.
Datasets are immutable. There is no self.neurons, no edges_, no
use_types: a dataset is a handle, and the selection lives in the caller.
Re-pinning a version returns a new object (:meth:at) rather than mutating -
a mutable version setter plus a memoised annotation frame is exactly how you
end up joining annotations from one materialization to edges from another.
Source code in connecto/core/dataset.py
capabilities
property
¶
capabilities: frozenset[Cap]
What this dataset can do through the backend it is bound to.
Not spec.capabilities - that is what the data has, which is a different
and, for a live handle, useless claim. FlyWire has a chunkedgraph; a FlyWire
handle on the neuPrint backend cannot reach it, so it does not claim it.
version
property
¶
version: Version
The version this dataset is pinned to (resolved on first access).
cite
¶
Who to credit for this dataset.
connecto knows exactly which dataset produced the numbers in your figure, which puts it in an unusually good position to tell you whose work it was::
print(cn.Hemibrain().cite())
Source code in connecto/core/dataset.py
versions
¶
at
¶
at(version) -> Dataset
A new handle onto the same dataset, pinned to a different version.
Source code in connecto/core/dataset.py
find_version
¶
find_version(x, *, raise_missing: bool = True) -> Version
The newest version in which all the given IDs are valid.
On CAVE this scans materializations newest-first, because root IDs change
as neurons are edited and a set of IDs is only jointly valid in some of
them. On neuPrint body IDs are immutable, so this is an identity - which
is the point: version="auto" is correct code on both backends.
Source code in connecto/core/dataset.py
ids
¶
Resolve any neuron query to an array of int64 IDs.
ds.ids(720575940621039145) ds.ids("DA1_lPN") ds.ids("/AOTU00.*") ds.ids("cell_class:ALPN", side="left")
Source code in connecto/core/dataset.py
Backends¶
CAVEDataset
¶
CAVEDataset(spec: DatasetSpec, *, backend: str | None = None, version=None, annotations: str | None = 'auto', fields: dict | None = None, edges=None)
Bases: Dataset
A dataset served by a CAVE datastack.
Source code in connecto/core/dataset.py
NeuPrintDataset
¶
NeuPrintDataset(spec: DatasetSpec, *, backend: str | None = None, version=None, annotations: str | None = 'auto', fields: dict | None = None, edges=None)
Bases: Dataset
A dataset served by a neuPrint server.
Source code in connecto/core/dataset.py
Versions¶
Version
dataclass
¶
Version(value: int | str, backend: str, timestamp: datetime | None = None, expires: datetime | None = None)
A resolved dataset version.