refactoredCPPNeuronMesher
|
Class for representing and processing neuron morphology graphs. More...
#include <neurongraph.h>
Public Member Functions | |
NeuronGraph () | |
Default constructor. More... | |
NeuronGraph (std::string filename) | |
Constructor that loads a neuron from file. More... | |
NeuronGraph (const std::map< int, SWCNode > &nodeSet) | |
Constructs a NeuronGraph from an existing set of nodes. More... | |
void | addNode (const SWCNode &node) |
Adds a single node to the graph. More... | |
void | setNodes (const std::map< int, SWCNode > &nodeSet) |
Replaces the current set of nodes in the graph. More... | |
bool | isTopologicallySorted (const std::map< int, SWCNode > &nodeSet) const |
Checks if a set of nodes is topologically sorted. More... | |
bool | isTopologicallySorted () const |
std::map< int, SWCNode > | topologicalSort (const std::map< int, SWCNode > &nodeSet) const |
Sorts nodes topologically using Kahn's algorithm. More... | |
std::map< int, SWCNode > | topologicalSort () const |
bool | hasSomaSegment (const std::map< int, SWCNode > &nodeSet) const |
Checks if the node set contains a soma segment. More... | |
bool | hasSomaSegment () const |
bool | isSomaMissing (const std::map< int, SWCNode > &nodeSet) const |
Checks if the node set is missing a soma. More... | |
bool | isSomaMissing () const |
std::map< int, SWCNode > | removeSomaSegment (const std::map< int, SWCNode > &inputNodes) const |
Removes the soma segment from a set of nodes. More... | |
std::map< int, SWCNode > | removeSomaSegment () const |
std::map< int, SWCNode > | setSoma (const std::map< int, SWCNode > &nodeSet) const |
Adds a soma node if none exists. More... | |
std::map< int, SWCNode > | setSoma () const |
std::map< int, SWCNode > | preprocess (const std::map< int, SWCNode > &nodeSet) const |
Applies standard preprocessing steps to a set of nodes. More... | |
void | readFromFile (const std::string &filename) |
Reads neuron data from an SWC file. More... | |
void | writeToFile (const std::map< int, SWCNode > &nodeSet, const std::string &filename) |
Writes a set of nodes to an SWC file. More... | |
void | writeToFile (const std::string &filename) |
void | readFromFileUGX (const std::string &filename) |
Reads neuron data from a UGX file. More... | |
void | readFromFileUGXorSWC (const std::string &filename) |
Reads a neuron file, automatically detecting the format. More... | |
void | writeToFileUGX (const std::map< int, SWCNode > &nodeSet, const std::string &filename) |
Writes a set of nodes to a UGX file. More... | |
void | writeToFileUGX (const std::string &filename) |
void | swc2ugx (const std::string &inputfile, const std::string &outputfile) |
Converts an SWC file to UGX format. More... | |
void | ugx2swc (const std::string &inputfile, const std::string &outputfile) |
Converts a UGX file to SWC format. More... | |
int | numberOfNodes () |
Returns the number of nodes in the graph. More... | |
int | numberOfEdges () |
Returns the number of edges in the graph. More... | |
auto | getNodes () |
Returns a copy of all nodes in the graph. More... | |
std::map< int, SWCNode > | splitEdges (const std::map< int, SWCNode > &nodeSet) const |
Splits all edges in the graph by inserting midpoint nodes. More... | |
std::map< int, SWCNode > | splitEdges () const |
std::vector< std::map< int, SWCNode > > | splitEdgesN (const std::map< int, SWCNode > &nodeSet, int N) const |
Applies edge splitting N times recursively. More... | |
std::vector< std::map< int, SWCNode > > | splitEdgesN (int N) const |
std::map< int, std::map< int, SWCNode > > | getTrunks (const std::map< int, SWCNode > &nodeSet, bool resetIndex=false) const |
Extracts trunk segments from a neuron morphology. More... | |
std::map< int, std::map< int, SWCNode > > | getTrunks (bool resetIndex=false) const |
std::map< int, int > | getTrunkParentMap (const std::map< int, SWCNode > &nodeSet, const std::map< int, std::map< int, SWCNode >> &trunkNodeSets) const |
Creates a mapping from trunk IDs to their parent trunk IDs. More... | |
std::map< int, SWCNode > | assembleTrunks (const std::map< int, std::map< int, SWCNode >> &trunkNodeSets) const |
Combines multiple trunks into a single node set. More... | |
std::map< int, SWCNode > | assembleTrunks (const std::map< int, std::map< int, SWCNode >> &resampledTrunks, const std::map< int, int > &trunkParentMap) |
Combines resampled trunks using a parent-child relationship map. More... | |
std::map< int, SWCNode > | linearSplineResampleTrunk (const std::map< int, SWCNode > &trunk, double &delta) const |
Resamples a single trunk using linear interpolation. More... | |
std::map< int, std::map< int, SWCNode > > | allLinearSplineResampledTrunks (std::map< int, std::map< int, SWCNode >> &trunks, double &delta) const |
Resamples all trunks using linear interpolation. More... | |
std::map< int, SWCNode > | cubicSplineResampleTrunk (const std::map< int, SWCNode > &trunk, double &delta) const |
Resamples a single trunk using cubic spline interpolation. More... | |
std::map< int, std::map< int, SWCNode > > | allCubicSplineResampledTrunks (std::map< int, std::map< int, SWCNode >> &trunks, double &delta) const |
Resamples all trunks using cubic spline interpolation. More... | |
std::map< int, std::map< int, SWCNode > > | generateRefinements (const std::map< int, SWCNode > &nodeSet, double &delta, int &N, std::string &method) |
Generates multiple levels of refined neuron morphologies. More... | |
std::map< int, std::map< int, SWCNode > > | generateRefinements (double &delta, int &N, std::string &method) |
Private Member Functions | |
std::map< int, std::vector< int > > | getNeighborMap (const std::map< int, SWCNode > &nodeSet) const |
Builds a neighbor map from a set of nodes. More... | |
Private Attributes | |
std::map< int, SWCNode > | nodes |
Map of node IDs to SWCNode objects. More... | |
std::map< int, std::vector< int > > | edges |
Adjacency list representation of the neuron graph. More... | |
Class for representing and processing neuron morphology graphs.
The NeuronGraph class provides comprehensive functionality for working with neuron morphology data, including file I/O, topological analysis, and geometric processing. It supports both SWC and UGX file formats and includes methods for manipulating and analyzing neuron structures.
Key features:
|
inline |
Default constructor.
Creates an empty NeuronGraph with no nodes or edges.
|
inline |
Constructor that loads a neuron from file.
[in] | filename | Path to the SWC or UGX file to load |
NeuronGraph::NeuronGraph | ( | const std::map< int, SWCNode > & | nodeSet | ) |
Constructs a NeuronGraph from an existing set of nodes.
Constructor that initializes a NeuronGraph from a set of SWC nodes.
[in] | nodeSet | Map of node IDs to SWCNode objects |
nodeSet | A map containing SWC nodes indexed by their IDs |
This constructor creates a new NeuronGraph instance by clearing any existing data and populating the graph with the provided nodes. It automatically builds the parent-child relationships between nodes.
void NeuronGraph::addNode | ( | const SWCNode & | node | ) |
Adds a single node to the graph.
Adds a single node to the graph and updates edge relationships.
[in] | node | The SWCNode to add |
node | The SWCNode to be added to the graph |
This method adds a node to the internal nodes map and automatically creates the parent-child edge relationship if the node has a valid parent (pid != -1). Root nodes (pid == -1) are added without creating edges.
std::map< int, std::map< int, SWCNode > > NeuronGraph::allCubicSplineResampledTrunks | ( | std::map< int, std::map< int, SWCNode >> & | trunks, |
double & | delta | ||
) | const |
Resamples all trunks using cubic spline interpolation.
Applies cubic spline resampling to all trunk segments in a neuron morphology.
[in,out] | trunks | Map of trunk IDs to their nodes |
[in,out] | delta | Target spacing between resampled points (may be adjusted) |
trunks | Map of trunk segments where each key is a trunk ID and value is a map of node IDs to SWCNodes |
delta | Target distance between consecutive nodes in the resampled trunks (in microns) |
This method processes each trunk segment in the input map and applies cubic spline resampling to achieve a smooth and uniform node distribution. The resampling is performed independently on each trunk.
Key features:
The resampling process involves:
std::map< int, std::map< int, SWCNode > > NeuronGraph::allLinearSplineResampledTrunks | ( | std::map< int, std::map< int, SWCNode >> & | trunks, |
double & | delta | ||
) | const |
Resamples all trunks using linear interpolation.
Applies linear spline resampling to all trunk segments in a neuron morphology.
[in,out] | trunks | Map of trunk IDs to their nodes |
[in,out] | delta | Target spacing between resampled points (may be adjusted) |
trunks | Map of trunk segments where each key is a trunk ID and value is a map of node IDs to SWCNodes |
delta | Target distance between consecutive nodes in the resampled trunks (in microns) |
This method processes each trunk segment in the input map and applies linear spline resampling to achieve a more uniform node distribution. The resampling is performed independently on each trunk.
Key features:
The resampling process involves:
std::map< int, SWCNode > NeuronGraph::assembleTrunks | ( | const std::map< int, std::map< int, SWCNode >> & | resampledTrunks, |
const std::map< int, int > & | trunkParentMap | ||
) |
Combines resampled trunks using a parent-child relationship map.
[in] | resampledTrunks | Map of trunk IDs to their resampled nodes |
[in] | trunkParentMap | Map of trunk IDs to their parent trunk IDs |
This version is used when trunk nodes have been resampled and need to be reconnected based on the original topology.
std::map< int, SWCNode > NeuronGraph::assembleTrunks | ( | const std::map< int, std::map< int, SWCNode >> & | trunkNodeSets | ) | const |
Combines multiple trunks into a single node set.
Combines multiple trunk segments into a single neuron representation with sequential node IDs.
[in] | trunkNodeSets | Map of trunk IDs to their nodes |
trunkNodeSets | Map of trunk segments where each key is a trunk ID and value is a map of node IDs to SWCNodes |
This method takes multiple trunk segments and combines them into a single neuron representation while ensuring all node IDs are unique and sequential. It handles the remapping of parent-child relationships to maintain the neuron's topological structure.
Key features:
The method performs two main passes:
std::map< int, SWCNode > NeuronGraph::cubicSplineResampleTrunk | ( | const std::map< int, SWCNode > & | trunk, |
double & | delta | ||
) | const |
Resamples a single trunk using cubic spline interpolation.
Resamples a single trunk segment using cubic spline interpolation.
[in] | trunk | The trunk to resample (map of node IDs to SWCNodes) |
[in,out] | delta | Target spacing between resampled points (may be adjusted) |
Cubic spline interpolation generally produces smoother curves than linear interpolation, especially for coarsely sampled data.
trunk | Map of node IDs to SWCNode objects representing the trunk to be resampled |
delta | Target distance between consecutive nodes in the resampled trunk (in microns) |
This method performs cubic spline resampling of a neuron trunk to achieve a smooth and uniform distribution of nodes along its length. It creates a smooth curve that passes through all original nodes and samples new points along this curve.
Key features:
The algorithm works as follows:
std::map< int, std::map< int, SWCNode > > NeuronGraph::generateRefinements | ( | const std::map< int, SWCNode > & | nodeSet, |
double & | delta, | ||
int & | N, | ||
std::string & | method | ||
) |
Generates multiple levels of refined neuron morphologies.
Generates multiple levels of mesh refinements for a neuron morphology.
[in] | nodeSet | The set of nodes to refine |
[in,out] | delta | Initial spacing parameter for refinement |
[in,out] | N | Number of refinement levels to generate |
[in,out] | method | Refinement method ("linear" or "cubic") |
This method generates a series of increasingly refined versions of the input neuron morphology by repeatedly applying the specified interpolation method.
nodeSet | Map of SWC nodes representing the input neuron morphology |
delta | Initial target spacing between nodes (in microns). This value is halved in each refinement level. |
N | Number of refinement levels to generate |
method | Interpolation method to use ("linear" or "cubic") |
This method creates a series of increasingly refined versions of the input neuron morphology. Each refinement level approximately halves the spacing between nodes, providing a multi-resolution representation of the neuron that can be used for progressive rendering or adaptive meshing.
Key features:
The refinement process works as follows:
|
inline |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. Generates refinements for the current graph's nodes
|
private |
Builds a neighbor map from a set of nodes.
Builds an adjacency list representing the connectivity between nodes in a neuron morphology.
[in] | nodeSet | Set of nodes to process |
This helper function constructs an adjacency list representation of the graph from a set of nodes by establishing parent-child relationships.
nodeSet | Map of SWC nodes where key is node ID and value is the SWCNode object |
This method constructs an undirected graph representation of the neuron morphology by creating neighbor relationships between connected nodes. For each node in the input set, it establishes bidirectional connections between the node and its parent (if the parent exists in the nodeSet).
The resulting neighbor map allows efficient traversal of the neuron's topology in any direction, which is essential for various analysis and processing tasks such as trunk extraction and topological sorting.
|
inline |
Returns a copy of all nodes in the graph.
std::map< int, int > NeuronGraph::getTrunkParentMap | ( | const std::map< int, SWCNode > & | nodeSet, |
const std::map< int, std::map< int, SWCNode >> & | trunkNodeSets | ||
) | const |
Creates a mapping from trunk IDs to their parent trunk IDs.
Determines the parent-child relationships between trunk segments in a neuron morphology.
[in] | nodeSet | The original set of nodes |
[in] | trunkNodeSets | Map of trunk IDs to their nodes |
nodeSet | Original map of all SWC nodes in the neuron |
trunkNodeSets | Map of trunk segments where each key is a trunk ID and value is a map of node IDs to SWCNodes |
This method analyzes the connectivity between trunk segments to establish a hierarchical parent-child relationship between them. It determines which trunk connects to which by examining the parent-child relationships of the nodes at the connection points between trunks.
The algorithm works in two main phases:
Key assumptions:
|
inline |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. Extracts trunk segments from the current graph
std::map< int, std::map< int, SWCNode > > NeuronGraph::getTrunks | ( | const std::map< int, SWCNode > & | nodeSet, |
bool | resetIndex = false |
||
) | const |
Extracts trunk segments from a neuron morphology.
[in] | nodeSet | The set of nodes to process |
[in] | resetIndex | If true, renumbers node IDs sequentially |
A trunk is defined as a linear segment between branch points or between a branch point and a leaf node.
nodeSet | Map of SWC nodes where key is node ID and value is the SWCNode object |
resetIndex | If true, renumbers node IDs sequentially within each trunk (default: false) |
This method identifies and extracts linear segments (trunks) from a neuron morphology. A trunk is defined as a path between:
The algorithm works as follows:
The method handles both directed and undirected traversal of the neuron morphology.
|
inline |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. Checks if the current graph contains a soma segment
bool NeuronGraph::hasSomaSegment | ( | const std::map< int, SWCNode > & | nodeSet | ) | const |
Checks if the node set contains a soma segment.
Checks if the neuron has multiple soma nodes (soma segment)
[in] | nodeSet | The set of nodes to check |
A soma segment is defined as multiple connected nodes of type 1 (soma).
nodeSet | Map of SWC nodes to check |
This method detects the presence of soma segments, which occur when multiple nodes have type 1 (soma). In proper neuron morphology, there should be exactly one soma node. Multiple soma nodes can cause issues in analysis and mesh generation.
The method uses early exit optimization - it returns true as soon as a second soma node is found, avoiding unnecessary iterations.
|
inline |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. Checks if the current graph is missing a soma
bool NeuronGraph::isSomaMissing | ( | const std::map< int, SWCNode > & | nodeSet | ) | const |
Checks if the node set is missing a soma.
Checks if the neuron is missing a soma node.
[in] | nodeSet | The set of nodes to check |
This is the inverse of hasSomaSegment() and is provided for readability.
nodeSet | Map of SWC nodes to check |
This method determines whether the neuron morphology lacks a soma (cell body). Every valid neuron should have exactly one soma node of type 1. Missing somas can occur in incomplete reconstructions or when dealing with neuron fragments.
The method uses early exit - it returns false as soon as any soma node is found, making it efficient for large neuron datasets.
|
inline |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. Checks if the current graph's nodes are topologically sorted
bool NeuronGraph::isTopologicallySorted | ( | const std::map< int, SWCNode > & | nodeSet | ) | const |
Checks if a set of nodes is topologically sorted.
Checks if the neuron nodes are topologically sorted.
[in] | nodeSet | The set of nodes to check |
A set of nodes is considered topologically sorted if for every node, its parent ID is less than its own ID (i.e., parent nodes come before their children in the sequence).
nodeSet | Map of SWC nodes to check |
This method verifies that all parent nodes have IDs smaller than their children nodes (parent_id < child_id). This property is important for many neuron analysis algorithms and ensures proper tree traversal.
A topologically sorted neuron means that when nodes are processed in ID order, all parent nodes are encountered before their children.
std::map< int, SWCNode > NeuronGraph::linearSplineResampleTrunk | ( | const std::map< int, SWCNode > & | trunk, |
double & | delta | ||
) | const |
Resamples a single trunk using linear interpolation.
Resamples a single trunk segment using linear interpolation.
[in] | trunk | The trunk to resample (map of node IDs to SWCNodes) |
[in,out] | delta | Target spacing between resampled points (may be adjusted) |
trunk | Map of node IDs to SWCNode objects representing the trunk to be resampled |
delta | Target distance between consecutive nodes in the resampled trunk (in microns) |
This method performs linear resampling of a neuron trunk to achieve a more uniform distribution of nodes along its length. It creates a piecewise linear approximation of the original trunk with nodes spaced approximately 'delta' units apart.
Key features:
The algorithm works as follows:
|
inline |
Returns the number of edges in the graph.
|
inline |
Returns the number of nodes in the graph.
Applies standard preprocessing steps to a set of nodes.
Preprocesses a node set to ensure proper soma properties.
[in] | nodeSet | The set of nodes to preprocess |
Preprocessing includes:
nodeSet | The input map of SWC nodes to preprocess |
This method performs essential preprocessing steps on neuron data:
The preprocessing ensures that the neuron has exactly one soma node, which is critical for proper neuron analysis and mesh generation.
void NeuronGraph::readFromFile | ( | const std::string & | filename | ) |
Reads neuron data from an SWC file.
Reads neuron morphology data from an SWC format file.
[in] | filename | Path to the SWC file to read |
std::runtime_error | If the file cannot be opened or parsed |
filename | Path to the SWC file to read |
This method parses an SWC (Standardized Morphology Format) file and populates the graph with neuron nodes. The SWC format contains one node per line with the following columns: ID, type, x, y, z, radius, parent_ID.
The parser handles:
void NeuronGraph::readFromFileUGX | ( | const std::string & | filename | ) |
Reads neuron data from a UGX file.
Reads neuron morphology data from a UGX file.
[in] | filename | Path to the UGX file to read |
std::runtime_error | If the file cannot be opened or parsed |
filename | Path to the input UGX file to read |
This method imports neuron morphology data from a UGX file and populates the internal data structures of the NeuronGraph class. It handles the conversion from the UGX format to the internal SWC-based representation.
The method processes the following UGX elements:
The import process includes:
void NeuronGraph::readFromFileUGXorSWC | ( | const std::string & | filename | ) |
Reads a neuron file, automatically detecting the format.
Automatically detects file format and reads neuron data.
[in] | filename | Path to the neuron file (SWC or UGX) |
This method examines the file extension to determine whether to use readFromFile() or readFromFileUGX().
std::runtime_error | If the file format is not supported |
filename | Path to the input file (SWC or UGX format) |
This method automatically determines the file format based on the file extension and calls the appropriate reader method:
This provides a convenient unified interface for loading neuron data regardless of the input format.
|
inline |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. Removes the soma segment from the current graph
std::map< int, SWCNode > NeuronGraph::removeSomaSegment | ( | const std::map< int, SWCNode > & | inputNodes | ) | const |
Removes the soma segment from a set of nodes.
Removes multiple soma nodes and replaces them with a single averaged soma.
[in] | inputNodes | The set of nodes to process |
This method identifies and removes the soma segment (multiple connected type 1 nodes) and replaces it with a single representative soma node at the average position.
inputNodes | The input map of SWC nodes containing multiple soma nodes |
This method processes neuron morphologies that have multiple soma nodes (soma segments) and consolidates them into a single soma node. The process involves:
void NeuronGraph::setNodes | ( | const std::map< int, SWCNode > & | nodeSet | ) |
Replaces the current set of nodes in the graph.
Sets the nodes of the graph, replacing any existing nodes.
[in] | nodeSet | New set of nodes to use |
This method clears the current graph and rebuilds it using the provided nodes. It automatically updates the internal adjacency list.
nodeSet | A map containing SWC nodes indexed by their IDs |
This method clears the current graph data and repopulates it with the provided node set. It rebuilds all parent-child relationships from scratch.
|
inline |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. Adds a soma node to the current graph if none exists
Adds a soma node if none exists.
Assigns a soma node to a neuron morphology that lacks one.
[in] | nodeSet | The set of nodes to process |
If no soma (type 1) node is present, this method adds one at the root position of the neuron tree.
nodeSet | The input map of SWC nodes missing a soma |
This method addresses neuron morphologies that are missing a soma (cell body) by converting the first root node found (pid == -1) into a soma node (type = 1).
The method follows this logic:
This operation is essential for:
|
inline |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. Splits all edges in the current graph
Splits all edges in the graph by inserting midpoint nodes.
Splits all edges in the neuron by inserting midpoint nodes.
[in] | nodeSet | The set of nodes to process |
This method inserts a new node at the midpoint of each edge, effectively doubling the number of edges while preserving the overall shape of the neuron.
nodeSet | The input map of SWC nodes to process |
This method performs edge subdivision by inserting a new node at the midpoint of every parent-child edge in the neuron morphology. The process involves:
This operation effectively doubles the resolution of the neuron morphology, which is useful for:
std::vector< std::map< int, SWCNode > > NeuronGraph::splitEdgesN | ( | const std::map< int, SWCNode > & | nodeSet, |
int | N | ||
) | const |
Applies edge splitting N times recursively.
Performs N iterations of edge splitting on the neuron morphology.
[in] | nodeSet | The set of nodes to process |
[in] | N | Number of times to split the edges |
nodeSet | The input map of SWC nodes to process |
N | The number of edge splitting iterations to perform |
This method applies the splitEdges() operation N times in sequence, where each iteration uses the result of the previous iteration as input. This creates progressively finer subdivisions of the neuron morphology.
The returned vector contains N maps, where:
After N iterations, the number of nodes grows exponentially, with each iteration approximately doubling the number of edges (and thus nodes).
Use cases:
|
inline |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. Applies edge splitting N times to the current graph
void NeuronGraph::swc2ugx | ( | const std::string & | inputfile, |
const std::string & | outputfile | ||
) |
Converts an SWC file to UGX format.
[in] | inputfile | Path to the input SWC file |
[in] | outputfile | Path for the output UGX file |
This is a convenience method that combines readFromFile() and writeToFileUGX().
inputfile | Path to the input SWC file |
outputfile | Path to the output UGX file |
This static utility method provides convenient SWC to UGX format conversion. It creates a temporary NeuronGraph instance, loads the SWC data, and exports it in UGX format suitable for mesh generation and finite element analysis.
|
inline |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. Sorts the current graph's nodes topologically
std::map< int, SWCNode > NeuronGraph::topologicalSort | ( | const std::map< int, SWCNode > & | nodeSet | ) | const |
Sorts nodes topologically using Kahn's algorithm.
Performs topological sorting of neuron nodes to ensure proper parent-child ordering.
[in] | nodeSet | The set of nodes to sort |
This method ensures that parent nodes always appear before their children in the resulting sequence, which is important for many processing steps.
nodeSet | The input map of SWC nodes to sort |
This method implements Kahn's algorithm for topological sorting to ensure that all parent nodes have smaller IDs than their children. The algorithm:
Topological sorting is essential for:
The resulting neuron will have:
void NeuronGraph::ugx2swc | ( | const std::string & | inputfile, |
const std::string & | outputfile | ||
) |
Converts a UGX file to SWC format.
[in] | inputfile | Path to the input UGX file |
[in] | outputfile | Path for the output SWC file |
This is a convenience method that combines readFromFileUGX() and writeToFile().
inputfile | Path to the input UGX file |
outputfile | Path to the output SWC file |
This static utility method provides convenient UGX to SWC format conversion. It creates a temporary NeuronGraph instance, loads the UGX data, and exports it in standard SWC format for compatibility with neuron analysis tools.
void NeuronGraph::writeToFile | ( | const std::map< int, SWCNode > & | nodeSet, |
const std::string & | filename | ||
) |
Writes a set of nodes to an SWC file.
Writes neuron morphology data to an SWC format file.
[in] | nodeSet | The nodes to write |
[in] | filename | Path to the output file |
nodeSet | Map of SWC nodes to write to file |
filename | Output file path for the SWC data |
This method exports neuron morphology data in the standard SWC format. Nodes are written in sorted order by ID to ensure consistent output. Each line contains: ID, type, x, y, z, radius, parent_ID.
The output format is compatible with standard neuron analysis tools and can be read back using readFromFile().
|
inline |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. Writes the current graph's nodes to an SWC file
void NeuronGraph::writeToFileUGX | ( | const std::map< int, SWCNode > & | nodeSet, |
const std::string & | filename | ||
) |
Writes a set of nodes to a UGX file.
Writes neuron morphology data to a UGX file format.
[in] | nodeSet | The nodes to write |
[in] | filename | Path to the output file |
nodeSet | Map of SWC nodes to be written, where key is node ID and value is SWCNode object |
filename | Path to the output UGX file |
This method converts the internal neuron representation into the UGX file format, which is compatible with the UG4 simulation framework. The UGX format is an XML-based format that can represent complex graph structures with additional attributes.
The output UGX file includes:
The method performs the following steps:
|
inline |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. Writes the current graph's nodes to a UGX file
|
private |
Adjacency list representation of the neuron graph.