genepy3d.io package#

Module contents#

Submodules#

genepy3d.io.base module#

Classes:

CatmaidApiTokenAuth(token)

Attaches HTTP X-Authorization Token headers to the given Request.

class genepy3d.io.base.CatmaidApiTokenAuth(token)[source]#

Bases: AuthBase

Attaches HTTP X-Authorization Token headers to the given Request.

This class is used for Catmaid server authentication.

token#

authentication string.

Type:

str

genepy3d.io.catmaid module#

Classes:

Catmaid(dfneu[, dfcon])

Support reading neuron data from Catmaid [1].

class genepy3d.io.catmaid.Catmaid(dfneu, dfcon=None)[source]#

Bases: object

Support reading neuron data from Catmaid [1].

dfneu#

neuron table.

Type:

pandas dataframe

dfcon#

connector table.

Type:

pandas dataframe

References

Methods:

from_csv(neuronfile[, confile])

Read neuron data from Catmaid csv files.

get_neuron_id_from_server(host, token, ...)

Return list of neuron IDs from given project ID.

from_server(host, token, project_id[, neuron_id])

Import neuron data from Catmaid server.

get_neuron_id([neuron_name])

Return neuron IDs from neuron names.

get_neuron_name([neuron_id])

Return neuron names from neuron IDs.

get_synaptic_relation([relation_id, ...])

Return neurons and corresponding treenodes filtered by their synaptic relations.

get_innervation_relation([nb_innervations])

Return neurons filtered by innervation relation.

get_neurons([neuron_id, scales])

Return neurons (Tree object) of a given list of neuron IDs.

to_csv([neuron_file, connector_file, neuron_id])

Export the neuron table and connector table into csv files.

classmethod from_csv(neuronfile, confile=None)[source]#

Read neuron data from Catmaid csv files.

Parameters:
  • neuronfile (str) – path to neuron csv file.

  • confile (str) – path to connector csv file.

Returns:

Catmaid object.

static get_neuron_id_from_server(host, token, project_id)[source]#

Return list of neuron IDs from given project ID.

Parameters:
  • host (str) – address of CATMAID server.

  • token (str) – authenticated string.

  • project_id (int) – project ID.

Returns:

array of int.

classmethod from_server(host, token, project_id, neuron_id=None)[source]#

Import neuron data from Catmaid server.

Parameters:
  • host (str) – Catmaid host address.

  • token (str) – authentication token.

  • project_id (int) – project ID.

  • neuron_id (int|list of int) – list of neuron IDs.

Returns:

Catmaid object.

get_neuron_id(neuron_name=None)[source]#

Return neuron IDs from neuron names.

Parameters:

neuron_name (str | array of str) – list of neuron names.

Returns:

pandas Series whose index is name and value is ID.

get_neuron_name(neuron_id=None)[source]#

Return neuron names from neuron IDs.

Parameters:

neuron_id (int | array of int) – list of neuron names.

Returns:

pandas Series whose index is ID and value is name.

get_synaptic_relation(relation_id='presynaptic_to', nb_connectors=1)[source]#

Return neurons and corresponding treenodes filtered by their synaptic relations.

A neuron can have multiple presynaptic gates (for receiving signals from others neurons), and only one postsynaptic gate (for sending signal).

Parameters:
  • relation_id (str) – presynaptic_to or postsynaptic_to.

  • nb_connectors (uint) – number of connectors. If None, then return all neurons regardess their number of connectors.

Returns:

Dictionary whose keys are neuron_id, values are treenode_ids.

get_innervation_relation(nb_innervations=1)[source]#

Return neurons filtered by innervation relation.

Innervation: a neuron receives signals from one (mono) or many (multi) other neurons via its presynaptic gates. We assume innervated neuron as postsynaptic neuron, the ones who make innervation are presynaptic neurons.

Parameters:

nb_innervations (int) – number innervated presynaptic neurons. If None, then return all neurons.

Returns:

dictionary whose key is postsynaptic neuron, value is innervating presynaptic neurons.

get_neurons(neuron_id=None, scales=(1.0, 1.0, 1.0))[source]#

Return neurons (Tree object) of a given list of neuron IDs.

Parameters:
  • neuron_id (int | array of int) – list of neuron IDs.

  • scales (tuple (float)) – define x, y, z scales

Returns:

list of neurons (tree.Tree)

to_csv(neuron_file='dfneu.csv', connector_file='dfcon.csv', neuron_id=None)[source]#

Export the neuron table and connector table into csv files.

We can extract for a subset of neuron given by neuron_id.

Parameters:
  • neuron_file (str) – file path to save the neuron table.

  • connector_file (str) – file path to save the connector table.

  • neuron_id (list of int) – list of neuron IDs to be exported. If None, then all neurons were exported.

genepy3d.io.swc module#

Classes:

SWC(filepath[, recursive])

Support reading neuron data from swc files [1].

class genepy3d.io.swc.SWC(filepath, recursive=False)[source]#

Bases: object

Support reading neuron data from swc files [1].

References

Methods:

get_neuron_id()

Return neuron IDs.

get_neurons([neuron_id])

Return list of neurons (Tree object) identified by IDs.

get_neuron_id()[source]#

Return neuron IDs.

Returns:

A pandas serie of (name,id).

get_neurons(neuron_id=None)[source]#

Return list of neurons (Tree object) identified by IDs.

Returns:

A dictionary where key is the neuron ID and value is the Tree object.

genepy3d.io.trackmate module#

This module supports reading tracked file from TrackMate.

Functions:

read_spots(filepath)

Read tracked spots table exported from TrackMate.

Classes:

Spots(spotsdf)

Handle tracked spots table.

genepy3d.io.trackmate.read_spots(filepath)[source]#

Read tracked spots table exported from TrackMate.

Parameters:

filepath (str) – path to the csv file.

Returns:

Spots object.

class genepy3d.io.trackmate.Spots(spotsdf)[source]#

Bases: object

Handle tracked spots table.

spots#

Spots table.

Type:

dataframe

trackid_lst#

list of trackid from the Spots table.

Type:

numpy array

nb_tracks#

number of tracks.

Type:

int

Notes

The spots table must be imported from trackmate.read_spots().

Examples

import numpy as np
from genepy3d.io import trackmate

# Csv file of spots table from Trackmate
spots = trackmate.read_spots("path/to/spots/csv/file")

Methods:

tracks_nb_spots([ascending])

Return number of spots per track.

get_tracks(trackid_lst[, return_type, ...])

Return tracks data given by trackid_lst.

remove_tracks(trackid_lst_excluded)

Remove tracks from the table.

tracks_nb_spots(ascending=False)[source]#

Return number of spots per track.

Parameters:

ascending (bool) – if True, sort by ascending order.

Returns:

A Pandas series index by trackid.

get_tracks(trackid_lst, return_type='simpletrack', x_col='position_x', y_col='position_y', z_col='position_z', t_col='frame')[source]#

Return tracks data given by trackid_lst.

Support two returns: “dataframe” as a Pandas dataframe and “simpletrack” as SimpleTrack objects.

Parameters:
  • trackid_lst (numpy array or int) – a single trackid or list of trackid.

  • return_type (str) – if “dataframe” then return a Pandas dataframe, if “simpletrack” then return SimpleTrack objects.

  • x_col (str) – x column name.

  • y_col (str) – y column name.

  • z_col (str) – z column name.

  • t_col (str) – time column name.

Returns:

A Pandas dataframe or SimpleTrack objects depend on condition.

Notes

The parameters x_col, y_col, z_col and t_col are only needed if return_type = “simpletrack”.

remove_tracks(trackid_lst_excluded)[source]#

Remove tracks from the table.

Parameters:

trackid_lst_excluded (numpy array) – list of trackids to be removed.

Returns:

Itself. Tracks with given trackids will be removed from the spots table.