Problem
For FBbt:00003748 (medulla) with JRC2018U open, VFB_00102107 has an index on the open template, so it should be shown first in Available Images. It is currently shown last of eight. The other seven are hemisphere- or source-specific images with no index (ME_R/ME_L, and two sets of ME(R)/ME(L)).
This applies to any neuropil class that now has more than one image on a template: the image indexed to the open template is the one that belongs to it and should lead.
Why it ends up last
- vfb_json
term_info has the information. anatomy_channel_image[].channel_image.image.index is [3] for VFB_00102107 and [] for the other seven JRC2018U images. The same holds on other templates (VFB_00101385 on hemibrain: [3]; VFB_00030624 on JFRC2: [25]).
- VFBquery
get_term_info drops it. The Examples records (vfb_queries.py L940–972) carry id, label, thumbnails and file URLs only, then sort each template's list by id descending. VFB_00102107 sorts below the newer VFB_00107*–VFB_00109* images.
- uk.ac.vfb.geppetto passes the order through.
VFBProcessTermInfoVFBqueryJson builds the Available Images carousel in the order received (L867–887). ImageRec already has an index field, but Examples records never populate it, so the index is not available at this step today.
- geppetto-vfb re-sorts client-side.
orderCarouselElements() in VFBTermInfo.js (L52–67) ranks by template (loaded template, then JRC2018U, JRC2018VNCU, L1EM, L3CNS, then the rest), then by image id descending within a template. This would undo a correct backend order, and the carousel element only carries name, thumbnail URL and reference, not the index.
Options
A. Prioritise by dataset. Rank images from the template's own painted-domain dataset first. This works, but needs a template-to-dataset mapping set up and maintained for every template, including each new one.
B. Prioritise by index (chosen). An image with an index on a template is, by construction, a domain of that template's label volume. The rule is universal, needs no per-template set-up, and the data is already in term_info.
Solution
Within each template, order images with an index first, by index ascending (more than one indexed image per template should be rare), then the remaining images by id descending as now.
- VFBquery: add
index (int(image.index[0]) when non-empty) to each Examples record and replace the plain id sort with the ordering above. ImageSchema already allows index. get_term_info is cached, so roll it out with a version (major.minor) bump or force_refresh on affected terms, not a cache bucket rename.
- geppetto-vfb: keep the template ranking in
orderCarouselElements() but drop the within-template id tiebreak, so the backend order survives (Array.prototype.sort is stable). Template ordering stays client-side, which still protects against a stale cache pinning the wrong template first.
- uk.ac.vfb.geppetto: no change needed, since it preserves order. Optionally also sort
Examples by ImageRec.index, so the rule holds independently of VFBquery.
Acceptance: with JRC2018U loaded, FBbt:00003748 shows VFB_00102107 as the first Available Image. Classes with no indexed image keep their current order.
Related: #469 (thumbnails for every aligned template); #473 (a single source per anatomical individual, which would also cut the duplicate ME(R)/ME(L) images here).
Problem
For FBbt:00003748 (medulla) with JRC2018U open,
VFB_00102107has an index on the open template, so it should be shown first in Available Images. It is currently shown last of eight. The other seven are hemisphere- or source-specific images with no index (ME_R/ME_L, and two sets ofME(R)/ME(L)).This applies to any neuropil class that now has more than one image on a template: the image indexed to the open template is the one that belongs to it and should lead.
Why it ends up last
term_infohas the information.anatomy_channel_image[].channel_image.image.indexis[3]forVFB_00102107and[]for the other seven JRC2018U images. The same holds on other templates (VFB_00101385on hemibrain:[3];VFB_00030624on JFRC2:[25]).get_term_infodrops it. TheExamplesrecords (vfb_queries.py L940–972) carry id, label, thumbnails and file URLs only, then sort each template's list by id descending.VFB_00102107sorts below the newerVFB_00107*–VFB_00109*images.VFBProcessTermInfoVFBqueryJsonbuilds the Available Images carousel in the order received (L867–887).ImageRecalready has anindexfield, butExamplesrecords never populate it, so the index is not available at this step today.orderCarouselElements()inVFBTermInfo.js(L52–67) ranks by template (loaded template, then JRC2018U, JRC2018VNCU, L1EM, L3CNS, then the rest), then by image id descending within a template. This would undo a correct backend order, and the carousel element only carries name, thumbnail URL and reference, not the index.Options
A. Prioritise by dataset. Rank images from the template's own painted-domain dataset first. This works, but needs a template-to-dataset mapping set up and maintained for every template, including each new one.
B. Prioritise by index (chosen). An image with an index on a template is, by construction, a domain of that template's label volume. The rule is universal, needs no per-template set-up, and the data is already in
term_info.Solution
Within each template, order images with an index first, by index ascending (more than one indexed image per template should be rare), then the remaining images by id descending as now.
index(int(image.index[0])when non-empty) to eachExamplesrecord and replace the plain id sort with the ordering above.ImageSchemaalready allowsindex.get_term_infois cached, so roll it out with a version (major.minor) bump orforce_refreshon affected terms, not a cache bucket rename.orderCarouselElements()but drop the within-template id tiebreak, so the backend order survives (Array.prototype.sortis stable). Template ordering stays client-side, which still protects against a stale cache pinning the wrong template first.ExamplesbyImageRec.index, so the rule holds independently of VFBquery.Acceptance: with JRC2018U loaded, FBbt:00003748 shows
VFB_00102107as the first Available Image. Classes with no indexed image keep their current order.Related: #469 (thumbnails for every aligned template); #473 (a single source per anatomical individual, which would also cut the duplicate
ME(R)/ME(L)images here).