pymaid.CatmaidNeuron¶
- class pymaid.CatmaidNeuron(x, remote_instance=None, units='nm', **metadata)[source]¶
Catmaid neuron object holding neuron data (nodes, connectors, name, etc) and providing quick access to various PyMaid functions.
CatmaidNeuron can be minimally constructed from just a skeleton ID and a CatmaidInstance. Other parameters (nodes, connectors, neuron name, annotations, etc.) will then be retrieved from the server ‘on-demand’.
The easiest way to construct a CatmaidNeuron is by using
get_neuron()
.Manually, a complete CatmaidNeuron can be constructed from a pandas DataFrame (df) containing: df.nodes, df.connectors, df.skeleton_id, df.neuron_name, df.tags
Using a CatmaidNeuron to initialise a CatmaidNeuron will automatically make a copy.
- skeleton_id¶
This neuron’s skeleton ID.
- Type:
str
- neuron_name¶
This neuron’s name.
- Type:
str
- nodes¶
Contains complete node table.
- Type:
pandas.DataFrame
- connectors¶
Contains complete connector table.
- Type:
pandas.DataFrame
- presynapses¶
All presynaptic connectors.
- Type:
pandas.DataFrame
- postsynapses¶
All postsynaptic connectors.
- Type:
pandas.DataFrame
- gap_junctions¶
All gap junction connectors.
- Type:
pandas.DataFrame
- date_retrieved¶
Timestamp of data retrieval.
- Type:
datetime
object
- tags¶
Node tags.
- Type:
dict
- connector_tags¶
Connector tags.
- Type:
dict
- annotations¶
This neuron’s annotations.
- Type:
list
- graph¶
Graph representation of this neuron.
- Type:
network.DiGraph
- igraph¶
iGraph representation of this neuron. Returns
None
if igraph library not installed.- Type:
igraph.Graph
- review_status¶
This neuron’s review status.
- Type:
int
- n_connectors¶
Total number of synapses.
- Type:
int
- n_presynapses¶
Total number of presynaptic sites.
- Type:
int
- n_postsynapses¶
Total number of presynaptic sites.
- Type:
int
- n_branch_nodes¶
Number of branch nodes.
- Type:
int
- n_end_nodes¶
Number of end nodes.
- Type:
int
- n_open_ends¶
Number of open end nodes = leaf nodes that are not tagged with either:
ends
,not a branch
,uncertain end
,soma
oruncertain continuation
.- Type:
int
- cable_length¶
Cable length in micrometers [um].
- Type:
float
- segments¶
Node IDs making up linear segments. Maximizes segment lengths (similar to CATMAID’s review widget).
- Type:
list of lists
- small_segments¶
Node IDs making up linear segments between end/branch points.
- Type:
list of lists
- soma¶
Returns
None
if no soma or ‘NA’ if data not available.- Type:
node ID of soma
- root¶
Node ID(s) of root.
- Type:
numpy.array
- color¶
Color of neuron. Used for e.g. export to json.
- Type:
tuple
- partners¶
Connectivity table of this neuron.
- Type:
pd.DataFrame
Examples
>>> # Initialize a new neuron >>> n = pymaid.CatmaidNeuron(123456) >>> # Retrieve node data from server on-demand >>> n.nodes CatmaidNeuron - INFO - Retrieving skeleton data... node_id parent_id creator_id x y z radius confidence 0 ... >>> # Initialize with skeleton data >>> n = pymaid.get_neuron(123456) >>> # Get annotations from server >>> n.annotations ['annotation1', 'annotation2'] >>> # Force update of annotations >>> n.get_annotations()
Initialize CatmaidNeuron.
- Parameters:
x –
- Data to construct neuron from:
pandas.DataFrame is expected to be SWC table
pandas.Series is expected to have a DataFrame as .nodes - additional properties will be attached as meta data
str is treated as SWC file name
BufferedIOBase e.g. from open(filename)
networkx.DiGraph parsed by navis.nx2neuron
remote_instance (CatmaidInstance, optional) – Storing this makes it more convenient to retrieve e.g. neuron annotations, review status, etc. If not provided, will try using global CatmaidInstance.
units (str | pint.Units | pint.Quantity) – Units for coordinates. Defaults to
None
(dimensionless). Strings must be parsable by pint: e.g. “nm”, “um”, “micrometer” or “8 nanometers”.metadata – Any additional data to attach to neuron.
- __init__(x, remote_instance=None, units='nm', **metadata)[source]¶
Initialize CatmaidNeuron.
- Parameters:
x –
- Data to construct neuron from:
pandas.DataFrame is expected to be SWC table
pandas.Series is expected to have a DataFrame as .nodes - additional properties will be attached as meta data
str is treated as SWC file name
BufferedIOBase e.g. from open(filename)
networkx.DiGraph parsed by navis.nx2neuron
remote_instance (CatmaidInstance, optional) – Storing this makes it more convenient to retrieve e.g. neuron annotations, review status, etc. If not provided, will try using global CatmaidInstance.
units (str | pint.Units | pint.Quantity) – Units for coordinates. Defaults to
None
(dimensionless). Strings must be parsable by pint: e.g. “nm”, “um”, “micrometer” or “8 nanometers”.metadata – Any additional data to attach to neuron.
Methods
__init__
(x[, remote_instance, units])Initialize CatmaidNeuron.
cell_body_fiber
([reroot_soma, inplace])Prune neuron to its cell body fiber.
convert_units
(to[, inplace])Convert coordinates to different unit.
copy
([deepcopy])Return a copy of this neuron.
downsample
([factor, inplace])Downsample the neuron by given factor.
get_annotations
([remote_instance])Retrieve annotations for neuron.
get_connector_tags
([remote_instance])Fetch tags on connectors of a neuron.
get_graph_nx
()Calculate and return networkX representation of neuron.
get_igraph
()Calculate and return iGraph representation of neuron.
get_name
([remote_instance])Retrieve/update name of neuron.
get_partners
([remote_instance])Get connectivity table for this neuron.
get_review
([remote_instance])Get/Update review status for neuron.
get_skeleton
([remote_instance])Get/update skeleton data for neuron.
map_units
(units[, on_error])Convert units to match neuron space.
memory_usage
([deep, estimate])Return estimated memory usage of this neuron.
plot2d
(**kwargs)Plot neuron using
navis.plot2d()
.plot3d
(**kwargs)Plot neuron using
navis.plot3d()
.prune_at_depth
(depth[, source, inplace])Prune all neurites past a given distance from a source.
prune_by_longest_neurite
([n, reroot_soma, ...])Prune neuron down to the longest neurite.
prune_by_strahler
(to_prune[, inplace])Prune neuron based on Strahler order.
prune_by_volume
(v[, mode, ...])Prune neuron by intersection with given volume(s).
prune_distal_to
(node[, inplace])Cut off nodes distal to given nodes.
prune_proximal_to
(node[, inplace])Remove nodes proximal to given node.
prune_twigs
(size[, inplace, recursive])Prune terminal twigs under a given size.
reload
([remote_instance])Reload neuron from server.
reroot
(new_root[, inplace])Reroot neuron to given node ID or node tag.
resample
(resample_to[, inplace])Resample neuron to given resolution.
set_remote_instance
([remote_instance, ...])Assign remote_instance to neuron.
snap
(locs[, to])Snap xyz location(s) to closest node or synapse.
summary
([add_props])Get a summary of this neuron.
to_dataframe
()Turn this CatmaidNeuron into a pandas DataFrame with original CATMAID data.
to_swc
([filename])Generate SWC file from this neuron.
Attributes
CORE_DATA
Core data table(s) used to calculate hash
EQ_ATTRIBUTES
Attributes to be used when comparing two neurons.
SUMMARY_PROPS
Attributes used for neuron summary
TEMP_ATTR
Temporary attributes that need to be regenerated when data changes.
Neuron annotations.
bbox
Bounding box (includes connectors).
branch_points
Branch node table.
Cable length.
Connector tags.
Connector table.
core_md5
MD5 of core information for the neuron.
cycles
Cycles in neuron (if any).
datatables
Names of all DataFrames attached to this neuron.
edge_coords
Coordinates of edges between nodes.
edges
Edges between nodes.
ends
End node table (same as leafs).
extents
Extents of neuron in x/y/z direction (includes connectors).
Table with gap junctions.
geodesic_matrix
Matrix with geodesic (along-the-arbor) distance between nodes.
Networkx Graph representation of this neuron.
id
ID of the neuron.
iGraph representation of this neuron.
is_isometric
Test if neuron is isometric.
is_locked
Test if neuron is locked.
is_stale
Test if temporary attributes might be outdated.
is_tree
Whether neuron is a tree.
label
Label (e.g. for legends).
leafs
Leaf node table.
n_branches
Number of branch points.
n_leafs
Number of leaf nodes.
n_skeletons
Number of seperate skeletons in this neuron.
n_trees
Count number of connected trees in this neuron.
name
Neuron name.
Neuron name (legacy - please use .name instead).
Node table.
open_ends
Node IDs of open ends.
Get connected partners.
Table with postsynapses (filtered from connectors table).
Table with presynapses (filtered from connectors table).
Review status in percent.
Root node(s).
sampling_resolution
Average cable length between child -> parent nodes.
Neuron broken down into linear segments (see also .small_segments).
simple
Simplified representation consisting only of root, branch points and leafs.
Skeleton ID.
Neuron broken down into small linear segments (see also .segments).
Search for soma and return node ID(s).
soma_detection_label
Label for soma detection.
soma_detection_radius
Minimum radius for soma detection.
soma_detection_tag
soma_pos
Search for soma and return its position.
soma_radius
Soma radius (e.g. for plotting).
subtrees
List of subtrees.
surface_area
Radius-based lateral surface area.
Node tags.
type
Return type.
units
Units for coordinate space.
units_xyz
Units for coordinate space.
volume
Radius-based volume.