Carousel multi-template query images + collapse multi-dataset rows#61
Merged
Conversation
…arousel The registration MATCH returns one row per (instance, template), so a multi-template instance appeared as several rows each with a single thumbnail. Group by instance and join every alignment's thumbnail into the '; '-joined multi-image carousel the V2 Images column renders, so the frontend can bring the loaded template's thumbnail to the front. Mirrors the existing groupby collapse in TransgeneExpressionHere and the multi-thumbnail carousel the shared _owlery_query_to_results helper already emits.
- get_instances: collapse the per-(template, dataset) rows the registration + has_source MATCH multiplies into one row per instance: thumbnails join into a DISTINCT '; ' carousel (a template's thumbnail repeats across datasets), and datasets join into a distinct ', ' list (fixes the duplicate/triple rows for images sourced from several datasets, e.g. larval mushroom body output neuron). - get_neuron_neuron_connectivity, get_similar_neurons: replace the single- alignment LIMIT 1 subquery with collect + apoc.text.join so multi-template neurons return all alignments' thumbnails as a carousel (representative template/ technique kept for those columns). Validated against pdb.virtualflybrain.org. Frontend (geppetto-vfb slideshowImageComponent) brings the loaded template's thumbnail to the front of the carousel.
The Images/Template_Space collects had no DISTINCT, so the cross-product with INSTANCEOF types / imaging techniques repeated each alignment's thumbnail (e.g. 2 templates -> 6 thumbnails, 1 -> 3). Use collect(DISTINCT ...) so it is one thumbnail per template, and align the thumbnail markdown with the other query functions (template,imageId ref + 'aligned to' alt + '; ' separator) so the frontend reorders by the loaded template. Validated against pdb (nThumbs == nTemplates per neuron).
Contributor
Author
|
Now also included (was previously deferred): the connectivity/similarity functions — get_neuron_neuron_connectivity, get_similar_neurons, get_individual_neuron_inputs — previously used LIMIT 1 to a single alignment. They now use collect + apoc.text.join (with collect(DISTINCT …) where a cross-product would otherwise duplicate) so multi-template neurons return all alignments' thumbnails as a carousel, with a representative template/technique kept for the non-image columns. All validated against pdb.virtualflybrain.org (nThumbs == nTemplates). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Query-result rows previously returned a single image thumbnail per row, and for image terms aligned to more than one template (e.g. DNc02 VFB_jrmc37oj — brain JRC2018U + VNC JRCVNC2018U) that single thumbnail was an arbitrary alignment that didn't follow the loaded template. Separately, get_instances (ListAllAvailableImages) multiplied rows for images sourced from several datasets, producing duplicate/triple rows for the same image.
This PR makes every affected query function emit all alignments' thumbnails as a ; -joined carousel (each item tagged template,imageId), and collapses the multi-dataset rows into one row per image. The frontend (geppetto-vfb slideshowImageComponent) then brings the loaded template's thumbnail to the front of the carousel.
Changes
get_instances / ListAllAvailableImages
The registration + has_source MATCH yields one row per (instance, template, dataset). Collapse to one row per instance via groupby('id'):
thumbnails join into a DISTINCT '; ' carousel (a template's thumbnail repeats across datasets, so dedupe);
datasets join into a distinct ', ' list (fixes the duplicate/triple rows for images sourced from several datasets, e.g. larval mushroom body output neuron).
get_neuron_neuron_connectivity, get_similar_neurons, get_individual_neuron_inputs
Previously used LIMIT 1 to a single alignment. Now use collect + apoc.text.join (with collect(DISTINCT …) where the INSTANCEOF type/technique cross-product would otherwise duplicate entries) so multi-template neurons return all alignments' thumbnails as a carousel. A representative template/technique is kept for the non-image columns.
Validation
All Cypher changes validated against pdb.virtualflybrain.org (read-only):
multi-template neurons return nThumbs == nTemplates (no duplicates, none dropped);
multi-dataset instances collapse to one row with every dataset listed (confirmed against a known 4-dataset instance).
Downstream / no Java change needed
The multi-valued dataset cell (ds1, ds2, …) passes straight through VFBqueryJsonProcessor.formatGenericCell and renders via MarkdownLinkComponent, whose label regex is global — so every dataset renders as its own clickable chip regardless of separator. The thumbnail carousel cell is handled by the existing separator-agnostic imageMarkdownToVariableJson path.
Scope
Backend (VFBquery) only. The frontend carousel-reorder-by-loaded-template lives in geppetto-client (slideshowImageComponent) / geppetto-vfb and is tracked separately. The larger per-template geometry and downloads work (lazy ImportType per template + frontend select/promote) is also separate and not in this PR.