feat: Add example Python linear registration script and control over non-display dimension based annotation clipping#883
Open
seankmartin wants to merge 66 commits intogoogle:masterfrom
Conversation
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.
Summary
ViewerStateto expose thedisplayDimensionsof the Neuroglancer viewer state.Setup
From the repository main directory:
Linear registration workflow
The workflow is described in more detail in the docstring in the example file. But in short the most likely use path is as follows:
python -i example_linear_registration.py --url https://neuroglancer.demo.appspot.com/...In images that might look like this. This image is after placing the fixed and reference layers in the right layer groups:

And then after placing a number of points:

Here is a video of using the tool on the default included demo data, the points placed here could be a bit better, this is moreso to give an idea of the different steps of estimation and actions on pressing the custom functions bound to keys for the workflow:
https://github.com/user-attachments/assets/41f27c77-94d9-452d-9317-8fda9c2c3827
New annotation layer state -
clipDimensionsWeightOne problem arose during this script setup. As part of the script we created a second coordinate space. The annotations representing the registration points would contain information for both coordinate spaces. This allowed to conveniently know which points were linked, allow moving to the same spot in the fixed image and moving image quickly, allowing adjusting the points easily etc. There was one issue with this though, which is that the non-display dimension clipping meant that moving in the left panel caused the annotations in the right panel to disappear, and vice versa. Here shows the issue, and the state change proposed to allow changing the default weight on dimensions that are non-display dimensions. Setting that weight to zero means that no clipping happens on the specified dimension when it is a non display dimension.
2026-02-05.12-39-31.mp4
There are a few points to note about this though:
#uicontroldirective, but unsure if we want to introduce that kind of pattern. Either way, it could be something like#clipdimweight[0]=0.0 #clipdimweight[2]=0.5.clipDimensionsWeight. This is definitely a bit undesirable, but considering that I would imagine this state feature is likely only used by advanced users that might be ok. Alternatively an array could be used for the weights instead of an object. Regardless, thought it would be good to agree on the state representation / overall strategy here before worrying too much about those details.