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:
datetimeobject
- 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
Noneif 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,somaoruncertain 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
Noneif 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_DATACore data table(s) used to calculate hash
EQ_ATTRIBUTESAttributes to be used when comparing two neurons.
SUMMARY_PROPSAttributes used for neuron summary
TEMP_ATTRTemporary attributes that need to be regenerated when data changes.
Neuron annotations.
bboxBounding box (includes connectors).
branch_pointsBranch node table.
Cable length.
Connector tags.
Connector table.
core_md5MD5 of core information for the neuron.
cyclesCycles in neuron (if any).
datatablesNames of all DataFrames attached to this neuron.
edge_coordsCoordinates of edges between nodes.
edgesEdges between nodes.
endsEnd node table (same as leafs).
extentsExtents of neuron in x/y/z direction (includes connectors).
Table with gap junctions.
geodesic_matrixMatrix with geodesic (along-the-arbor) distance between nodes.
Networkx Graph representation of this neuron.
idID of the neuron.
iGraph representation of this neuron.
is_isometricTest if neuron is isometric.
is_lockedTest if neuron is locked.
is_staleTest if temporary attributes might be outdated.
is_treeWhether neuron is a tree.
labelLabel (e.g. for legends).
leafsLeaf node table.
n_branchesNumber of branch points.
n_leafsNumber of leaf nodes.
n_skeletonsNumber of seperate skeletons in this neuron.
n_treesCount number of connected trees in this neuron.
nameNeuron name.
Neuron name (legacy - please use .name instead).
Node table.
open_endsNode 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_resolutionAverage cable length between child -> parent nodes.
Neuron broken down into linear segments (see also .small_segments).
simpleSimplified 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_labelLabel for soma detection.
soma_detection_radiusMinimum radius for soma detection.
soma_detection_tagsoma_posSearch for soma and return its position.
soma_radiusSoma radius (e.g. for plotting).
subtreesList of subtrees.
surface_areaRadius-based lateral surface area.
Node tags.
typeReturn type.
unitsUnits for coordinate space.
units_xyzUnits for coordinate space.
volumeRadius-based volume.