refactoredCPPNeuronMesher
bindings.cpp File Reference

Python bindings for the CPPNeuronMesher library using pybind11. More...

#include <pybind11/pybind11.h>
#include <pybind11/stl.h>
#include "neurongraph.h"
Include dependency graph for bindings.cpp:

Functions

 PYBIND11_MODULE (neurongraph, m)
 Python module definition for neurongraph. More...
 

Detailed Description

Python bindings for the CPPNeuronMesher library using pybind11.

Author
CPPNeuronMesher Project
Date
2024

This file provides Python bindings for the NeuronGraph class and SWCNode structure, enabling Python users to access the full functionality of the CPPNeuronMesher library. The bindings expose all major operations including file I/O, morphology analysis, preprocessing, mesh operations, and trunk analysis.

The Python module can be imported as:

import neurongraph
graph = neurongraph.NeuronGraph()
See also
NeuronGraph for the main class documentation
SWCNode for the node structure documentation

Function Documentation

◆ PYBIND11_MODULE()

PYBIND11_MODULE ( neurongraph  ,
 
)

Python module definition for neurongraph.

Parameters
mThe pybind11 module object

This function defines the Python module 'neurongraph' and exposes all C++ classes and methods to Python. The module provides two main classes:

  • SWCNode: Represents individual neuron nodes with spatial and topological data
  • NeuronGraph: Main class for neuron morphology analysis and processing

All method signatures are preserved from C++ to Python, with automatic type conversion handled by pybind11 for standard types (int, double, string, maps, vectors).

Python binding for SWCNode structure

Exposes the SWCNode C++ structure to Python, providing direct access to all neuron node properties. SWCNode represents a single point in a neuron morphology with spatial coordinates, topological relationships, and morphological type.

Python usage:

node = neurongraph.SWCNode()
node.id = 1
node.pid = -1 # Root node
node.type = 1 # Soma
node.x, node.y, node.z = 0.0, 0.0, 0.0
node.radius = 5.0
Note
All attributes are read-write from Python
See also
SWCNode C++ structure for detailed field descriptions

Python binding for NeuronGraph class

Exposes the complete NeuronGraph C++ class to Python, providing access to all neuron morphology analysis, processing, and I/O operations. This is the main class for working with neuron data in Python.

Python usage examples:

# Create empty graph
graph = neurongraph.NeuronGraph()
# Load from file
graph = neurongraph.NeuronGraph("neuron.swc")
# Create from node dictionary
nodes = {1: node1, 2: node2, ...}
graph = neurongraph.NeuronGraph(nodes)
Here is the call graph for this function: