Crate swc_neuron

source ·
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§

Modules§

  • Module for metadata contained in the header of the SWC file.
  • Module for types represented by the structure ID field of a SWC sample.

Macros§

  • Thin wrapper around the structure_mapping macro for producing enums which extend the Neuromorpho SWC standard (i.e. have additional structure types in the Custom block, 5+).
  • Macro for creating a public enum implementing StructureIdentifier.

Structs§

  • Error where a sample refers to an unknown parent sample.
  • Iterator which eagerly reads the header on construction and then lazily reads the remaining lines.
  • Struct representing a neuron skeleton as a tree of SwcSamples.
  • 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§

Functions§

Type Aliases§

  • Maximally flexible SwcNeuron with any structure specification and a free-text header.
  • Float type used for locations and radii.
  • Type used for sample IDs.