Allow viewer data to be updated in real-time - #142
Closed
r-b-g-b wants to merge 1 commit into
Closed
Conversation
…x.webshow(data) returns client, a JSMixer object with a method addData, client.addData(data1=volume) will add that data to the viewer
Contributor
|
Superseded by #675 |
mvdoc
added a commit
that referenced
this pull request
Aug 21, 2026
Rebases and completes GH-142: `JSMixer.addData` lets you push new data into an already running `cortex.webshow` viewer, without restarting the server: client = cortex.webshow(volume) client.addData(second=other_volume) The method was dead code -- it referenced `_convert_dataset` and `Dataset`, neither of which exists in `cortex.webgl.view`, so any call raised `NameError`, and it proxied to `window.viewers`, which the mixer page never defines. Changes: - `show()` keeps the packaged metadata as a dict instead of a JSON string, and serializes it when the mixer page is generated. That lets `addData` merge new dataviews into it, so a page reload shows everything that has been added so far. - `addData` builds a `Package` for the new dataviews, reorders vertex data against the ctm files the viewer was started with, registers the new images with the data handler, merges the metadata, and sends only the new dataviews to the browser. Adding a name that is already displayed replaces it, and the images of the replaced dataview are dropped so that repeatedly refreshing data does not pile up unused buffers in the server. Data for a subject the viewer was not started with is rejected with a clear `ValueError`, since surfaces cannot be added to a running viewer. - `mriview.Viewer.addData` (and `mriview.MultiView.addData`) now accept the raw metadata package in addition to `dataset.DataView` objects. Tests: the `xfail`-ed `test_addData_no_crash` is replaced by a `TestAddData` group covering dataview registration and switching, the metadata served on reload, the rendered image actually changing, name replacement and the pruning that goes with it, and the unknown-subject error, plus a separate test for vertex data (which exercises the reorder path). Co-authored-by: Claude <noreply@anthropic.com>
alexhuth
pushed a commit
that referenced
this pull request
Aug 21, 2026
Rebases and completes GH-142: `JSMixer.addData` lets you push new data into an already running `cortex.webshow` viewer, without restarting the server: client = cortex.webshow(volume) client.addData(second=other_volume) The method was dead code -- it referenced `_convert_dataset` and `Dataset`, neither of which exists in `cortex.webgl.view`, so any call raised `NameError`, and it proxied to `window.viewers`, which the mixer page never defines. Changes: - `show()` keeps the packaged metadata as a dict instead of a JSON string, and serializes it when the mixer page is generated. That lets `addData` merge new dataviews into it, so a page reload shows everything that has been added so far. - `addData` builds a `Package` for the new dataviews, reorders vertex data against the ctm files the viewer was started with, registers the new images with the data handler, merges the metadata, and sends only the new dataviews to the browser. Adding a name that is already displayed replaces it, and the images of the replaced dataview are dropped so that repeatedly refreshing data does not pile up unused buffers in the server. Data for a subject the viewer was not started with is rejected with a clear `ValueError`, since surfaces cannot be added to a running viewer. - `mriview.Viewer.addData` (and `mriview.MultiView.addData`) now accept the raw metadata package in addition to `dataset.DataView` objects. Tests: the `xfail`-ed `test_addData_no_crash` is replaced by a `TestAddData` group covering dataview registration and switching, the metadata served on reload, the rendered image actually changing, name replacement and the pruning that goes with it, and the unknown-subject error, plus a separate test for vertex data (which exercises the reorder path). Co-authored-by: Claude <noreply@anthropic.com>
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.
This commit makes a few changes that allow you to refresh the brain data using something like the following code...
client = cortex.webshow(data) # data is a cortex.Volume, client is a JSMixer object# make a new volume, data1client.addData(data1=data1) # data1 is the key, data is some new cortex.Volume