State Utilities#

Basic convenience functions for downloading and parsing neuroglancer states.

Given a neuroglancer link, return the corresponding JSON state.

Arg:
link: str

A neuroglancer link such as: https://neuroglancer-demo.appspot.com/#!gs://flyem-male-cns/v0.9/male-cns-v0.9.json

Also works with fully expanded neuroglancer links.

Returns:

dict

ngsidekick.state_utils.download_ngstate(link)[source]#

Given a neuroglancer link which references a JSON state file, download the file and return the enclosed JSON data.

Arg:
link: str

A neuroglancer link such as: https://neuroglancer-demo.appspot.com/#!gs://flyem-male-cns/v0.9/male-cns-v0.9.json

Returns:

dict

ngsidekick.state_utils.encode_ngstate(ng_server, link_json_settings)[source]#

Produce a fully expanded URL from a neuroglancer server and a JSON state.

ngsidekick.state_utils.layer_dict(state)[source]#

Given a neuroglancer JSON state, return a dictionary of the layer states, keyed by layer name.

ngsidekick.state_utils.layer_state(state, name_pattern)[source]#

Given a neuroglancer JSON state and a regex pattern, return the layer state whose name matches the pattern. If more than one layer matches the pattern, raise an error.