pyroglancer package

Subpackages

Submodules

pyroglancer.createconfig module

Module for creating yaml based configuration files for adding layers in the neuroglancer.

pyroglancer.createconfig.createconfig(configdata, configfileloc=None, overwrite=False)[source]

Create config file in case it is not found.

Parameters
  • configdata (dict) – different layers to be added in the neuroglancer instance

  • configfileloc (str) – location of the configuration file

  • overwrite (bool) – if set to True, then overwrites the existing configuration file

pyroglancer.createconfig.getdefaultconfigdata()[source]

Get neuroglancer layer data from default configuration in case configuration fileit is not found.

pyroglancer.flywire module

pyroglancer.layers module

pyroglancer.loadconfig module

Module contains functions to handle configuratio data fron YAML files.

pyroglancer.loadconfig.getconfigdata(configfileloc=None)[source]

Get the YAML config data from the default location.

Parameters

configfileloc (str) – override the default location if configfileloc is present

Returns

configdata – different layers to be added in the neuroglancer instance

Return type

dict

pyroglancer.localserver module

This code is used to serve local data via http port, so it can be read by neuroglancer.

class pyroglancer.localserver.RequestHandler(*args, directory=None, **kwargs)[source]

Bases: http.server.SimpleHTTPRequestHandler

This class provides support for generic cors access, HTTP ‘Range’ requests In case of the range implementation, the approach is to: - Override send_head to look for ‘Range’ and respond appropriately. - Override copyfile to only transmit a range when requested.

copyfile(source, outputfile)[source]

Copy all data between two file objects.

The SOURCE argument is a file object open for reading (or anything with a read() method) and the DESTINATION argument is a file object open for writing (or anything with a write() method).

The only reason for overriding this would be to change the block size or perhaps to replace newlines by CRLF – note however that this the default server uses this to copy binary data as well.

do_OPTIONS()[source]
end_headers()[source]

Allow responses to be shared with any requester without any credentials.

send_head()[source]

Common code for GET and HEAD commands.

This sends the response code and MIME headers.

Return value is either a file object (which has to be copied to the outputfile by the caller unless the command was HEAD, and must be closed by the caller under all circumstances), or None, in which case the caller has nothing further to do.

class pyroglancer.localserver.Server(server_address)[source]

Bases: http.server.HTTPServer

Class for basic HTTP server.

protocol_version = 'HTTP/1.1'
pyroglancer.localserver.closedataserver(removefiles=True)[source]

Close a already started dataserver.

Parameters

removefiles (flag to remove the created contents in the hosted server) –

Return type

None

pyroglancer.localserver.copy_byte_range(infile, outfile, start=None, stop=None, bufsize=16384)[source]

Like shutil.copyfileobj, but only copy a range of the streams. Both start and stop are inclusive.

pyroglancer.localserver.parse_byte_range(byte_range)[source]

Returns the two numbers in ‘bytes=123-456’ or throws ValueError. The last number or both numbers may be None.

pyroglancer.localserver.startdataserver(address='127.0.0.1', port=8000, directory=None, restart=True)[source]

Start a dataserver thread(return control back) that can host local folder via http.

Parameters
  • address (str) – ip address to use for the local host server

  • port (int) – port number to use for the local host server

  • directory (str) – local directory to be used for hosting

  • restart (bool) – restart/clean up already running data server

pyroglancer.meshgenerator module

Module contains functions to generate multi-resolution meshes.

class pyroglancer.meshgenerator.Quantize(fragment_origin, fragment_shape, input_origin, quantization_bits)[source]

Bases: object

pyroglancer.meshgenerator.cmp_zorder(lhs, rhs)[source]
Return type

bool

pyroglancer.meshgenerator.decompose_meshes(verts, faces, nodes_per_dim, bits)[source]

pyroglancer.ngspaces module

pyroglancer.ngviewer module

Module contains code to open a neuroglancer viewer.

pyroglancer.ngviewer.closeviewer()[source]

Close a already started ngviewer.

pyroglancer.ngviewer.get_ngscreenshot(ngviewer, viewer_size=[1000, 1000])[source]

Get screenshot of neuroglancer viewing engine. :param ngviewer: object of Neuroglancer viewer class. :type ngviewer: ng.viewer.Viewer :param viewer_size: :type viewer_size: screenshot size

Returns

screenshot

Return type

screenshot image.

pyroglancer.ngviewer.openviewer(ngviewer=None, headless=False)[source]

Open a neuroglancer viewing engine.

Parameters
  • ngviewer (ng.viewer.Viewer) – object of Neuroglancer viewer class.

  • headless (bool) – if True, then operating in servers or testcase mode.

Returns

ngviewer – object of Neuroglancer viewer class.

Return type

ng.viewer.Viewer

pyroglancer.ngviewer.setviewerstate(ngviewer=None, axis_lines=True, bounding_box=True, layout=None, zoom_factor=None)[source]

Set state of neuroglancer viewing engine.

Parameters
  • ngviewer (ng.viewer.Viewer) – object of Neuroglancer viewer class.

  • axis_lines (bool) – if False, then disable the axis lines.

  • bounding_box (bool) – if False, then disable the default annotations like bounding box.

  • layout (string | dict) – possible layout options.

  • zoom_factor (float) – zoom factor of image.

Returns

ngviewer – object of Neuroglancer viewer class.

Return type

ng.viewer.Viewer

pyroglancer.points module

Module contains functions to handle point data.

pyroglancer.points.annotate_points(ngviewer, dimensions, pointscolor, points_df, layer_name, layer_scale)[source]

Annotate points from a dataframe (defunct do not use..).

Parameters
  • ngviewer (ng.viewer.Viewer) – object of Neuroglancer viewer class.

  • dimensions (neuroglancer.CoordinateSpace) – object of neuroglancer coordinate space class.

  • points_df (dataframe) – should contain ‘x’, ‘y’, ‘z’ columns

  • layer_scale (int | float) – scaling from voxel to native space in ‘x’, ‘y’, ‘z’

pyroglancer.points.commit_info(pointinfo, path, pointlayername)[source]

Commit the info file created for the points based precomputed format.

Parameters
  • pointinfo (dict) – info in json format for the points

  • path (str) – local path of the precomputed hosted layer.

  • pointlayername (str) – name for the points layer

pyroglancer.points.create_pointinfo(dimensions, path, layer_name)[source]

Create info file for the points based precomputed format.

Parameters
  • path (str) – local path of the precomputed hosted layer.

  • layer_name (str) – name for the points layer

  • dimensions (neuroglancer.CoordinateSpace) – object of neuroglancer coordinate space class.

Returns

path – local path of the precomputed hosted layer.

Return type

str

pyroglancer.points.put_pointfile(path, layer_name, points, pointsscale, pointname)[source]

Put pointfile in the local dataserver.

Parameters
  • path (str) – local path of the precomputed hosted layer.

  • layer_name (str) – name for the points layer

  • points (dataframe) – should contain ‘x’, ‘y’, ‘z’ columns

  • pointsscale (int | float) – scaling from voxel to native space in ‘x’, ‘y’, ‘z’

  • pointsname (str) – name for the points (not yet implemented)

pyroglancer.points.upload_points(points_df, path, layer_name, layer_scale)[source]

Upload points from a dataframe.

Parameters
  • points_df (dataframe) – should contain ‘x’, ‘y’, ‘z’ columns

  • path (str) – local path of the precomputed hosted layer.

  • layer_name (str) – name for the points layer

  • layer_scale (int | float) – scaling from voxel to native space in ‘x’, ‘y’, ‘z’

pyroglancer.skeletons module

pyroglancer.synapses module

Module contains functions to handle synapse data.

pyroglancer.synapses.annotate_synapses(ngviewer, dimensions, x)[source]

Annotate postsynapses of a neuron/neuronlist. (defunct do not use..).

This function annotates synapses of a neuron/neuronlist

Parameters
  • ngviewer (ng.viewer.Viewer) – object of Neuroglancer viewer class.

  • dimensions (neuroglancer.CoordinateSpace) – object of neuroglancer coordinate space class.

  • x (CatmaidNeuron | CatmaidNeuronList or TreeNeuron | NeuronList) – neuron or neuronlist of different formats

Returns

status – annotation status

Return type

bool

pyroglancer.synapses.commit_info(synapseinfo, path, synapsetype)[source]

Commit the info file created for the synapses based on precomputed format.

Parameters
  • synapseinfo (dict) – info in json format for the synapses

  • path (str) – local path of the precomputed hosted layer.

  • synapsetype (str) – pre or postsynapses

pyroglancer.synapses.create_synapseinfo(dimensions, path)[source]

Create info file for the synapse based precomputed format.

Parameters
  • path (str) – local path of the precomputed hosted layer.

  • dimensions (neuroglancer.CoordinateSpace) – object of neuroglancer coordinate space class.

pyroglancer.synapses.put_synapsefile(path, synapsetype, synapses, skeletonid)[source]

Put synapse in the local dataserver.

Parameters
  • path (str) – local path of the precomputed hosted layer.

  • synapsetype (str) – pre or postsynapses

  • synapses (dataframe) – contains ‘x’, ‘y’, ‘z’ columns

  • skeletonid (int) – skeleton id to be associated with the corresponding synapse

  • pointsname (str) – name for the points (not yet implemented)

pyroglancer.synapses.synapses2nodepoints(x, layer_scale)[source]

Generate nodepoints (point A, point B) from synapses for given neuron(s).

Parameters
  • x (CatmaidNeuron | CatmaidNeuronList or TreeNeuron | NeuronList) – neuron or neuronlist of different formats

  • layer_scale (int | float) – scaling from voxel to native space in ‘x’, ‘y’, ‘z’

Returns

synapsepointscollec_df – contains synapse points in point A - point B format used in flywire annotations.

Return type

dataframe

pyroglancer.synapses.upload_synapses(x, path)[source]

Upload synpases from a neuron or neuronlist.

Parameters
  • x (CatmaidNeuron | CatmaidNeuronList or TreeNeuron | NeuronList) – neuron or neuronlist of different formats

  • path (str) – local path of the precomputed hosted layer.

pyroglancer.utils module

Module contains utility functions.

pyroglancer.utils.get_alphavalue(layer_kws)[source]

Get alpha values from the interface APIs.

pyroglancer.utils.get_annotationstatetype(layer_kws)[source]

Get alpha values from the interface APIs.

pyroglancer.utils.get_hexcolor(layer_kws)[source]

Convert text based color to hex value.

pyroglancer.utils.get_scalevalue(layer_kws)[source]

Get scale values from the interface APIs.

pyroglancer.utils.obj2pointcloud(objurl=None)[source]

Convert object url to point cloud data in open3d format.

Parameters

objurl (str) – url containing the obj file.

Returns

pcd – point cloud object of open3d PointCloud class.

Return type

o3d.geometry.PointCloud

pyroglancer.utils.pointcloud2meshes(pcd_data, algorithm='rollingball', **kwargs)[source]

Convert point cloud files to volumetric meshes.

Parameters
  • pcd_data (o3d.geometry.PointCloud or str) – pointcloud object or file location in polygon file format.

  • algorithm (str) – algorithm of either ‘rollingball’ or ‘marchingcubes’ to convert points to meshes.

Returns

ret_mesh – mesh object of navis volume class.

Return type

navis.Volume

pyroglancer.volumes module

Module contents

Module contains functions to handle init etc.