Skip to content

client.state

Client to interface with the JSON state service.

Methods:

Name Description
build_neuroglancer_url

Build a URL for a Neuroglancer deployment that will automatically retrieve specified state.

get_neuroglancer_info

Get the info field from a Neuroglancer deployment

get_property_json

Download a Neuroglancer JSON state

get_state_json

Download a Neuroglancer JSON state

save_state_json_local

Save a Neuroglancer JSON state to a JSON file locally.

upload_property_json

Upload a Neuroglancer JSON state

upload_state_json

Upload a Neuroglancer JSON state

Attributes:

Name Type Description
server_version Optional[Version]

The version of the service running on the remote server. Note that this

state_service_endpoint

Endpoint URL for posting JSON state

server_version: Optional[Version] property

The version of the service running on the remote server. Note that this refers to the software running on the server and has nothing to do with the version of the datastack itself.

state_service_endpoint property

Endpoint URL for posting JSON state

build_neuroglancer_url(state_id, ngl_url=None, target_site=None, static_url=False, format_properties=False)

Build a URL for a Neuroglancer deployment that will automatically retrieve specified state. If the datastack is specified, this is prepopulated from the info file field "viewer_site". If no ngl_url is specified in either the function or the client, a fallback neuroglancer deployment is used.

Parameters:

Name Type Description Default
state_id int

State id to retrieve

required
ngl_url str

Base url of a neuroglancer deployment. If None, defaults to the value for the datastack or the client. As a fallback, a default deployment is used.

None
target_site seunglab or cave - explorer or mainline or None

Set this to 'seunglab' for a seunglab deployment, or either 'cave-explorer'/'mainline' for a google main branch deployment. If None, checks the info field of the neuroglancer endpoint to determine which to use. Default is None.

None
static_url bool

If True, treats "state_id" as a static URL directly to the JSON and does not use the state service.

False
format_properties bool

If True, formats the url as a segment_properties info file

False

Returns:

Type Description
str

The full URL requested

get_neuroglancer_info(ngl_url=None)

Get the info field from a Neuroglancer deployment

Parameters:

Name Type Description Default
ngl_url str(optional)

URL to a Neuroglancer deployment. If None, defaults to the value for the datastack or the client.

None

Returns:

Type Description
dict

JSON-formatted info field from the Neuroglancer deployment

get_property_json(state_id)

Download a Neuroglancer JSON state

Parameters:

Name Type Description Default
state_id int

ID of a JSON state uploaded to the state service.

required

Returns:

Type Description
dict

JSON specifying a Neuroglancer state.

get_state_json(state_id)

Download a Neuroglancer JSON state

Parameters:

Name Type Description Default
state_id int

ID of a JSON state uploaded to the state service.

required

Returns:

Type Description
dict

JSON specifying a Neuroglancer state.

save_state_json_local(json_state, filename, overwrite=False)

Save a Neuroglancer JSON state to a JSON file locally.

Parameters:

Name Type Description Default
json_state dict

Dict representation of a neuroglancer state

required
filename str

Filename to save the state to

required
overwrite bool

Whether to overwrite the file if it exists. Default False.

False

Returns:

Type Description
None

upload_property_json(property_json, state_id=None, max_size=2500000)

Upload a Neuroglancer JSON state

Parameters:

Name Type Description Default
propery_json dict

Dict representation of a neuroglancer segment properties json

required
state_id int

ID of a JSON state uploaded to the state service. Using a state_id is an admin feature.

None
max_size Optional[int]

Maximum size in bytes for the data to upload. Default is 2.5MB. Set to None for no limit.

2500000

Returns:

Type Description
int

state_id of the uploaded JSON state

upload_state_json(json_state, state_id=None, timestamp=None)

Upload a Neuroglancer JSON state

Parameters:

Name Type Description Default
json_state dict

Dict representation of a neuroglancer state

required
state_id int

ID of a JSON state uploaded to the state service. Using a state_id is an admin feature.

None
timestamp

Timestamp for json state date. Requires state_id.

None

Returns:

Type Description
int

state_id of the uploaded JSON state