Skip to content

Available Images: show the template's own indexed (painted-domain) image first #500

Description

@Robbie1977

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

  1. 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]).
  2. 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.
  3. 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.
  4. 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).

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions