catpy package¶
Submodules¶
catpy.client module¶
-
class
catpy.client.
CatmaidClient
(base_url, token=None, auth_name=None, auth_pass=None, project_id=None)[source]¶ Bases:
object
Python object handling authentication, request pooling etc. for requests made to a CATMAID server.
Methods
fetch
(relative_url[, method, data, raw])Interact with the CATMAID server in a manner very similar to the javascript CATMAID.fetch API. from_json
(path[, with_project_id])Return a CatmaidClient instance with credentials matching those in a JSON file. get
(relative_url[, params, raw])Get data from a running instance of CATMAID. post
(relative_url[, data, raw])Post data to a running instance of CATMAID. set_api_token
(token)Set CatmaidClient to use the given API token in place. set_http_auth
(username, password)Set HTTP authorization for CatmaidClient in place. -
fetch
(relative_url, method='GET', data=None, raw=False)[source]¶ Interact with the CATMAID server in a manner very similar to the javascript CATMAID.fetch API.
Parameters: relative_url : str or tuple of str
URL to send the request to, relative to the base_url. If a tuple is passed, its elements will be joined with ‘/’.
method: {‘GET’, ‘POST’}, optional
HTTP method to use (the default is ‘GET’)
data: dict or str, optional
JSON-like key/value data to be included in the request as a payload (defaults to empty)
raw: bool, optional
Whether to return the response as a string (defaults to returning a dict)
Returns: dict or str
Data returned from CATMAID: type depends on the ‘raw’ parameter.
-
classmethod
from_json
(path, with_project_id=True)[source]¶ Return a CatmaidClient instance with credentials matching those in a JSON file. Should have the property base_url as a minimum.
If HTTP authentication is required, should have the properties auth_name and auth_pass.
If you intend to use an authorized CATMAID account (required for some endpoints), should have the property token.
Can optionally include the property project_id.
Parameters: path : str
Path to the JSON credentials file
with_project_id : bool
Whether to look for the project_id field (it can be set later on the returned CatmaidClient instance)
Returns: CatmaidClient
Instance of the API, authenticated with
-
get
(relative_url, params=None, raw=False)[source]¶ Get data from a running instance of CATMAID.
Parameters: relative_url : str or tuple of str
URL to send the request to, relative to the base_url. If a tuple is passed, its elements will be joined with ‘/’.
params: dict or str, optional
JSON-like key/value data to be included in the get URL (defaults to empty)
raw: bool, optional
Whether to return the response as a string (defaults to returning a dict)
Returns: dict or str
Data returned from CATMAID: type depends on the ‘raw’ parameter.
-
post
(relative_url, data=None, raw=False)[source]¶ Post data to a running instance of CATMAID.
Parameters: relative_url : str or tuple of str
URL to send the request to, relative to the base_url. If a tuple is passed, its elements will be joined with ‘/’.
data: dict or str, optional
JSON-like key/value data to be included in the request as a payload (defaults to empty)
raw: bool, optional
Whether to return the response as a string (defaults to returning a dict)
Returns: dict or str
Data returned from CATMAID: type depends on the ‘raw’ parameter.
-
-
class
catpy.client.
CoordinateTransformer
(resolution=None, translation=None)[source]¶ Bases:
object
Methods
from_catmaid
(catmaid_client, stack_id)Return a CoordinateTransformer for a particular CATMAID stack. project_to_stack
(project_coords)Take a point in project space and transform it into stack space. project_to_stack_array
(arr[, dims])Take an array of points in project space and transform them into stack space. project_to_stack_coord
(dim, project_coord)stack_to_project
(stack_coords)Take a point in stack space and transform it into project space. stack_to_project_array
(arr[, dims])Take an array of points in stack space and transform them into project space. stack_to_project_coord
(dim, stack_coord)-
classmethod
from_catmaid
(catmaid_client, stack_id)[source]¶ Return a CoordinateTransformer for a particular CATMAID stack.
Parameters: catmaid_client : CatmaidClient
Authenticated instance of CatmaidClient
stack_id : int
Returns: CoordinateTransformer
-
project_to_stack
(project_coords)[source]¶ Take a point in project space and transform it into stack space.
Parameters: project_coords : dict
x, y, and/or z coordinates in project / real space
Returns: dict
coordinates transformed into stack / voxel space
-
project_to_stack_array
(arr, dims='xyz')[source]¶ Take an array of points in project space and transform them into stack space.
Parameters: arr : array-like
M by N array containing M coordinates in project / real space in N dimensions
dims : str
Order of dimensions in columns, default ‘xyz’
Returns: np.ndarray
M by N array containing M coordinates in stack / voxel space in N dimensions
-
stack_to_project
(stack_coords)[source]¶ Take a point in stack space and transform it into project space.
Parameters: stack_coords : dict
x, y, and/or z coordinates in stack / voxel space
Returns: dict
coordinates transformed into project / real space
-
stack_to_project_array
(arr, dims='xyz')[source]¶ Take an array of points in stack space and transform them into project space.
Parameters: arr : array-like
M by N array containing M coordinates in stack / voxel space in N dimensions
dims : array-like or str
Order of dimensions in columns, default (x, y, z)
Returns: np.ndarray
M by N array containing M coordinates in project / real space in N dimensions
-
classmethod