Expand description
Rust library for reading, writing, and manipulating SWC files for neuronal morphology.
Also includes a CLI for basic validation, sorting, and reindexing (with optional feature cli
).
The format was originally proposed in Cannon, et al. 1998, with an implementation in dohalloran/SWC_BATCH_CHECK.
While commonly used, many variants exist; this implementation tries to cover the “standardised” version described here, with some ambiguities resolved by the SWCplus specification.
The header is a series of #
-prefixed lines starting at the beginning of the file.
Blank lines (i.e. without a #
or any other non-whitespace content) do not interrupt the header,
but are also not included in the parsed header.
All other #
-prefixed and all whitespace-only lines in the file after the first sample are ignored.
Samples define a sample ID, a structure represented by that sample, its location, radius,
and the sample ID of the sample’s parent in the neuron’s tree structure (the root’s parent is -1
).
The SwcNeuron is generic over implementors of StructureIdentifier and Header, and can be parsed from [Read]ers and dumped to Writers. StructureIdentifier is implemented for some known sub-specifications. Header is implemented for String (i.e. a free-text header field). AnySwc is a SwcNeuron with any structure integer and string header.
Re-exports§
pub use crate::structures::AnyStructure;
pub use crate::structures::StructureIdentifier;
pub use crate::header::Header;
Modules§
- header
- Module for metadata contained in the header of the SWC file.
- structures
- Module for types represented by the structure ID field of a SWC sample.
Macros§
- neuromorpho_
ext - Thin wrapper around the
structure_mapping
macro for producing enums which extend the Neuromorpho SWC standard (i.e. have additional structure types in theCustom
block, 5+). - structure_
mapping - Macro for creating a public enum implementing StructureIdentifier.
Structs§
- Missing
Sample Error - Error where a sample refers to an unknown parent sample.
- SwcLines
- Iterator which eagerly reads the header on construction and then lazily reads the remaining lines.
- SwcNeuron
- Struct representing a neuron skeleton as a tree of SwcSamples.
- SwcSample
- Struct representing a row of a SWC file (a single sample from the neuron), which gives information about a single node in the tree.
Enums§
- Inconsistent
Neuron Error - Error where a neuron represented by a SWC file is inconsistent.
- Sample
Parse Error - Error in parsing a SWC sample (row).
- SwcLine
- Line in a SWC file, which might be a comment or sample.
- SwcParse
Error - Error for a SWC file which cannot be parsed
Functions§
- parse_
swc_ lines - Parse lines from a SWC file.