google / google/neuroglancer

How do I programmatically change the currently selected annotation?

Open
#407 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
1.5k
Forks
389
Avg merge
3d 21h
Merged PRs (30d)
3

Description

The JSON state for my `Viewer` contains this:

```json
"selection": {
"layers": {
"my-line-annotations": {
"annotationId": "123456789",
"annotationSource": 0,
"annotationSubsource": "default"
}
}
}
```

But I can't figure out how to change it via the Python API. For example, I tried this:

```python
with viewer.txn() as s:
s.selection = {
"layers": {
"my-line-annotations": {
"annotationId": "123456789",
"annotationSource": 0,
"annotationSubsource": "default"
}
}
}
```

But that yields:

```
AttributeError: 'ViewerState' object has no attribute 'selection'
```

Also, is it possible to get a callback when the user changes the currently selected annotation?

---

I tried to figure it out by looking into the TypeScript code (not my forte). I see that the [relevant variable][1] is of [type `TrackableDataSelectionState`][2], but I don't know how to proceed from there.

[1]: https://github.com/google/neuroglancer/blob/master/src/neuroglancer/viewer.ts#L210
[2]: https://github.com/google/neuroglancer/blob/master/src/neuroglancer/viewer_state.ts#L33

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.