Skip to content

Allow viewer data to be updated in real-time - #142

Closed
r-b-g-b wants to merge 1 commit into
gallantlab:mainfrom
r-b-g-b:add_data_realtime
Closed

Allow viewer data to be updated in real-time#142
r-b-g-b wants to merge 1 commit into
gallantlab:mainfrom
r-b-g-b:add_data_realtime

Conversation

@r-b-g-b

@r-b-g-b r-b-g-b commented Jan 14, 2016

Copy link
Copy Markdown
Contributor

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, data1
client.addData(data1=data1) # data1 is the key, data is some new cortex.Volume

…x.webshow(data) returns client, a JSMixer object with a method addData, client.addData(data1=volume) will add that data to the viewer
Base automatically changed from master to main January 19, 2021 20:02
@mvdoc

mvdoc commented Aug 20, 2026

Copy link
Copy Markdown
Contributor

Superseded by #675

@mvdoc mvdoc closed this Aug 20, 2026
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants