pub struct SwcNeuron<S: StructureIdentifier, H: Header> {
pub samples: Vec<SwcSample<S>>,
pub header: Option<H>,
}
Expand description
Struct representing a neuron skeleton as a tree of SwcSamples.
Fields§
§samples: Vec<SwcSample<S>>
Samples present in the SWC file.
header: Option<H>
Header of the SWC file
Implementations§
Source§impl<S: StructureIdentifier, H: Header> SwcNeuron<S, H>
impl<S: StructureIdentifier, H: Header> SwcNeuron<S, H>
Sourcepub fn sort_index(self) -> Self
pub fn sort_index(self) -> Self
Sort the neuron’s samples by their index.
Sourcepub fn reindex(self) -> Result<Self, MissingSampleError>
pub fn reindex(self) -> Result<Self, MissingSampleError>
Re-index the neuron’s samples in order of occurrence, starting at 1. Returns error if the SWC is missing a parent sample
Sourcepub fn sort_topo(self, reindex: bool) -> Result<Self, InconsistentNeuronError>
pub fn sort_topo(self, reindex: bool) -> Result<Self, InconsistentNeuronError>
Re-order its samples in pre-order depth first search. Children are visited in the order of their original sample number.
Returns an error if the neuron is not a self-consistent tree.
Sourcepub fn validate(
&self,
validate_order: bool,
) -> Result<(), InconsistentNeuronError>
pub fn validate( &self, validate_order: bool, ) -> Result<(), InconsistentNeuronError>
Ensure that SwcNeuron is a self-consistent tree.
If validate_order
is false
, samples may be defined earlier in the file than their parents.
Sourcepub fn from_reader<R: BufRead>(reader: R) -> Result<Self, SwcParseError>
pub fn from_reader<R: BufRead>(reader: R) -> Result<Self, SwcParseError>
Parse a SwcNeuron from a [Read]er.
Does not check the neuron for consistency, but does check for valid structures.
Sourcepub fn replace_header(&mut self, header: Option<H>) -> Option<H>
pub fn replace_header(&mut self, header: Option<H>) -> Option<H>
Replace the existing header with a new one, returning the existing.