label id for label name

9 просмотров
Перейти к первому непрочитанному сообщению

Gregory Jefferis

не прочитано,
29 июл. 2018 г., 05:28:2529.07.2018
– <catmaid@googlegroups.com>
Hi Tom et al,

I would like to use the skeletons/node-labels API endpoint. It returns skeleton ids for neurons containing nodes with a given label (tag). As input it expects label ids. I do not see immediately how to find the label ids.

With many thanks,

Greg.

--
Gregory Jefferis, PhD
Division of Neurobiology
MRC Laboratory of Molecular Biology
Francis Crick Avenue
Cambridge Biomedical Campus
Cambridge, CB2 OQH, UK




Chris Barnes

не прочитано,
29 июл. 2018 г., 06:59:2229.07.2018
– cat...@googlegroups.com
Hi Greg,

You can get all of the labels/tags used by a project with the {project_id}/labels/stats endpoint (which calls the django/applications/catmaid/control/label.py: get_label_stats function). You can use this client-side to get a mapping from names to IDs - that's what the tag table widget does. The initial query can take a couple of seconds but the result can be cached if performance is an issue.

Hope that helps!
Chris

--
You received this message because you are subscribed to the Google Groups "CATMAID" group.
To unsubscribe from this group and stop receiving emails from it, send an email to catmaid+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Gregory Jefferis

не прочитано,
29 июл. 2018 г., 07:29:0629.07.2018
– cat...@googlegroups.com
Thanks, Chris. I hadn't realised that is the approach taken by the front end. 

The get_label_stats call takes about 20s for me (probably only a 1/3 of that is on the server) and retrieves a 1M row table, so it's somewhat wasteful when you just want to know the integer id of one tag, but yes it can be cached – I just don't at the moment because I haven't formulated a good cache invalidation strategy for scripted access. But I guess I could cache the inferred label id to label name mapping since I assume that rarely changes.

Best,

Greg.

Chris Barnes

не прочитано,
29 июл. 2018 г., 07:58:2329.07.2018
– cat...@googlegroups.com
You're right, that does sound pretty unreasonable. The table is so large because the widget needs a row per label-node relationship. A new endpoint for getting label IDs would not be complicated (or allowing node-labels or label_stats to search by name), although as you say a label's mapping to an ID should not change unless something significant happens to the database. I don't think we enforce label name uniqueness on the database side so it's possible to put it in a state where one string can have multiple IDs, though.

Tom Kazimiers

не прочитано,
29 июл. 2018 г., 19:20:5129.07.2018
– cat...@googlegroups.com
Hi Greg,

Chris is right, there was so far no convenient way to get this
information. Therefore I added a new API to get more detailed
information on labels:

GET /{project_id}/labels/detail

It will return a list of objects, one for each available label in the
current project. Each object currently has the fields 'id' and 'name'.
From this you can easily build a mapping in either direction. Like Chris
already said, we currently don't enforce name uniqueness in the
databases for labels, but we still assume it and our API endpoints
shouldn't create any name duplicates.

I also updated the `/{project_id}/skeletons/node-labels` endpoint to
also accept a `label_names` parameter to avoid the label ID lookup
altogether.

Cheers,
Tom
Ответить всем
Отправить сообщение автору
Переслать
0 новых сообщений