BlueBrain / snap

The Blue Brain Pythonic Simulation and Network Analysis Productivity layer
https://bluebrainsnap.readthedocs.io/
GNU Lesser General Public License v3.0
19 stars 10 forks source link

Filter by node or edge population `type` #228

Closed mgeplf closed 7 months ago

mgeplf commented 1 year ago

When getting node and edge populations, it should be able possible to filter by type (as defined in the config file); ie: get all virtual edge populations, or only in non-virtual node populations. The idea would be that this could happen across the API.

mgeplf commented 1 year ago

Suggested by @MWolfR; please add more if you wish.

joni-herttuainen commented 1 year ago

It just about dawned on me that this is already (kind of) possible with nodes:

in h5 we have the mandatory model_type field which should conform to whatever you'd put in the Circuit Config.

Using this, we can retrieve all the certain types:

circuit.nodes.get({"model_type": "virtual"})

or the inverse of that with a "very clear" and "self-explanatory" negative lookahead regex:

circuit.nodes.get({"model_type": {"$regex": "^(?!virtual).*$"}})

this only applies to nodes, though, as edges don't have model_type.