Skip to content

Integrating custom NBLAST scoring matrices #182

@schlegelp

Description

@schlegelp

We have recently generated some custom NBLAST scoring matrices which turned out to be very useful and I'm thinking about how to best package them up for easy use by others. I wouldn't want to put them into navis directly but e.g. flybrains might be a good place to put them.

This would already work:

import flybrains
scores = navis.nblast_allbyall(neurons, smat=flybrains.my_matrix) 

To make things easier we could additionally allow a syntax like this:

scores = navis.nblast_allbyall(neurons, smat="flybrains:my_matrix")

where a string with a colon is interpreted as "get this object from this module" and users don't even have to import flybrains themselves.

Another option would be to implement a plugin system similar to what we're doing for transforms:

# flybrains/scoring.py
mat = pd.read_csv('../data/scoring_function.csv')

navis.nbl.register_scoring_matrix(mat, name="flybrains_custom_matrix", description="...")
import flybrains
scores = navis.nblast_allbyall(neurons, smat="flybrains_custom_matrix")

We could even use Python's entry_points to avoid having to explicitly import flybrains (see octarine3d's plugin system). The advantage of the latter would be discoverability: we could have a function to list all available scoring functions.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions