navis.synblast¶
- navis.synblast(query, target, by_type=False, cn_types=None, scores='forward', normalized=True, smat='auto', n_cores=1, progress=True)[source]¶
Synapsed-based variant of NBLAST.
The gist is this: for each synapse in the query neuron, we find the closest synapse in the target neuron (can be restricted by synapse types). Those distances are then scored similar to nearest-neighbor pairs in NBLAST but without the vector component.
- Parameters:
query (Neuron/List) – Query neuron(s) to SynBLAST against the targets. Units should be in microns as NBLAST is optimized for that and have similar sampling resolutions. Neurons must have (non-empty) connector tables.
target (Neuron/List) – Query neuron(s) to SynBLAST against the targets. Units should be in microns as NBLAST is optimized for that and have similar sampling resolutions. Neurons must have (non-empty) connector tables.
by_type (bool) – If True, will use the “type” column in the connector tables to only compare e.g. pre- with pre- and post- with postsynapses.
cn_types (str | list, optional) – Use this to restrict synblast to specific types of connectors (e.g. “pre”synapses only).
scores ('forward' | 'mean' | 'min' | 'max') –
Determines the final scores:
’forward’ (default) returns query->target scores
’mean’ returns the mean of query->target and target->query scores
’min’ returns the minium between query->target and target->query scores
’max’ returns the maximum between query->target and target->query scores
n_cores (int, optional) – Max number of cores to use for nblasting. Default is
os.cpu_count() // 2
. This should ideally be an even number as that allows optimally splitting queries onto individual processes.normalized (bool, optional) – Whether to return normalized SynBLAST scores.
smat (str | pd.DataFrame, optional) – Score matrix. If ‘auto’ (default), will use scoring matrices from FCWB. Same behaviour as in R’s nat.nblast implementation. If
smat=None
the scores will be generated as the product of the distances and the dotproduct of the vectors of nearest-neighbor pairs.progress (bool) – Whether to show progress bars. This may cause some overhead, so switch off if you don’t really need it.
- Returns:
scores – Matrix with SynBLAST scores. Rows are query neurons, columns are targets.
- Return type:
pandas.DataFrame
Examples
>>> import navis >>> nl = navis.example_neurons(n=5) >>> nl.units <Quantity([8 8 8 8 8], 'nanometer')> >>> # Convert to microns >>> nl_um = nl * (8 / 1000) >>> # Run type-agnostic SyNBLAST >>> scores = navis.synblast(nl_um[:3], nl_um[3:], progress=False) >>> # Run type-sensitive (i.e. pre vs pre and post vs post) SyNBLAST >>> scores = navis.synblast(nl_um[:3], nl_um[3:], by_type=True, progress=False)
See also
navis.nblast()
The original morphology-based NBLAST.