Repository navigation
Add skeleton and mesh downloads to the neuroglancer view - #178
Merged
Merged
Conversation
Closes #175. The "Neuron Visualization" header gets a download icon that opens a modal dialog. The dialog fetches one file per displayed neuron in the chosen format and saves them as a single zip archive, built in the browser with fflate. Neurons without a file are listed in missing_body_ids.txt inside the zip, and selections above 50 neurons ask for confirmation first. Formats come from a new `neuroglancer.download_formats` list in the dataset config (key, label, url_template with a `{body_id}` placeholder, kind). `kind: swc` stores the response verbatim; `kind: ngmesh` addresses the Neuroglancer legacy mesh manifest, fetches its fragments and converts them to Wavefront OBJ (vertices in nanometers) client-side. Entries are validated at load time (placeholder present, known kind, unique keys). The icon, dialog and scripts are only rendered when the list is non-empty, so datasets without configured formats are unchanged. The male CNS config offers coarse SWC, high-resolution SWC and OBJ mesh from the public flyem-male-cns bucket. The embedded viewer is a cross-origin iframe, so the page cannot read its current URL. Body IDs therefore default to the page's own neuroglancer state (type neurons plus ticked partners), which `initializeNeuroglancerLinks()` now exposes on `window`. As a fallback for selections changed inside the viewer, the dialog accepts a pasted Neuroglancer URL and takes the segments of the neuron layer, using the same layer lookup as the URL generator (`findMainSegmentationLayer`). Files are fetched through the GCS JSON API endpoint, since the plain storage.googleapis.com URLs send no CORS headers.
The download feature was a single bullet under "Viewing the 3D Model". It now has a "Downloading Neurons" subsection below "External neuPrint Link" that explains the dialog, the three formats offered for the male CNS (coarse SWC, high-resolution SWC, OBJ mesh) with their size and use cases, and the difference between leaving the Neuroglancer URL field empty (neurons the page sent to the viewer) and pasting a Neuroglancer URL (exactly the neurons visible in that view, including changes made inside Neuroglancer). Adds a screenshot of the dialog and reuses the "copy URL" screenshot. The section is still rendered only when the dataset configures download formats.
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.
What this adds
A download icon next to the "open in new window" icon above the Neuroglancer view. It opens a modal dialog where the user picks a format and gets one zip file with one file per displayed neuron. For the male CNS the formats are coarse SWC skeleton, high-resolution SWC skeleton, and OBJ mesh (converted in the browser from the Neuroglancer legacy mesh, vertices in nanometers). Neurons without a file end up in
missing_body_ids.txtinside the zip, and selections above 50 neurons ask for confirmation first.How it works
neuroglancer.download_formatslist (seeconfig/README.md). Each entry has akey,label,url_templatewith a{body_id}placeholder, and akind(swcorngmesh). Entries are validated when the config loads.neuroglancer-url-generator.js;static/js/swc-download.jsdoes the fetching, the OBJ conversion, and the zipping with the vendoredfflatelibrary, so everything still works in a local file system (vs web server).Limitation worth knowing
The viewer is a cross-origin iframe, so the page cannot read its current URL. By default the download covers what the page sent to the viewer: the type's neurons plus the partners and ROIs ticked in the tables. Selections changed inside Neuroglancer are not visible to the page. For that case the dialog has a URL field: open the viewer in a new window, copy the URL, paste it, and the page parses the neuron layer's segments from it.
Files are fetched through the GCS JSON API (
https://www.googleapis.com/storage/v1/b/<bucket>/o/<object>?alt=media) because the plainstorage.googleapis.comURLs send no CORS headers.Testing
missing_body_ids.txt.Also in this PR
Documentation in the user guide, developer guide,
config/README.md, the generated-site README, the help page, and the top-level README.Closes #175.