Struct SwcNeuron

Source
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>

Source

pub fn len(&self) -> usize

Number of samples in the neuron.

Source

pub fn is_empty(&self) -> bool

Whether there are any samples in the neuron.

Source

pub fn sort_index(self) -> Self

Sort the neuron’s samples by their index.

Source

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

Source

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.

Source

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.

Source

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.

Source

pub fn to_writer<W: Write>(&self, writer: &mut W) -> Result<(), Error>

Dump this SwcNeuron to a Writer.

These writes are quite small: consider wrapping it in a [BufWriter].

Source

pub fn replace_header(&mut self, header: Option<H>) -> Option<H>

Replace the existing header with a new one, returning the existing.

Source

pub fn map_header<H2: Header, F: Fn(&Self) -> Option<H2>>( self, f: F, ) -> SwcNeuron<S, H2>

Create a new header by applying a function to this SwcNeuron, then create a new neuron with that header.

Trait Implementations§

Source§

impl<S: Clone + StructureIdentifier, H: Clone + Header> Clone for SwcNeuron<S, H>

Source§

fn clone(&self) -> SwcNeuron<S, H>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<S: Debug + StructureIdentifier, H: Debug + Header> Debug for SwcNeuron<S, H>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<S: StructureIdentifier, H: Header> FromIterator<SwcSample<S>> for SwcNeuron<S, H>

Source§

fn from_iter<I: IntoIterator<Item = SwcSample<S>>>(iter: I) -> Self

Creates a value from an iterator. Read more
Source§

impl<S: StructureIdentifier, H: Header, R: BufRead> TryFrom<SwcLines<S, R>> for SwcNeuron<S, H>

Source§

type Error = SwcParseError

The type returned in the event of a conversion error.
Source§

fn try_from(lines: SwcLines<S, R>) -> Result<Self, Self::Error>

Performs the conversion.

Auto Trait Implementations§

§

impl<S, H> Freeze for SwcNeuron<S, H>
where H: Freeze,

§

impl<S, H> RefUnwindSafe for SwcNeuron<S, H>

§

impl<S, H> Send for SwcNeuron<S, H>
where H: Send, S: Send,

§

impl<S, H> Sync for SwcNeuron<S, H>
where H: Sync, S: Sync,

§

impl<S, H> Unpin for SwcNeuron<S, H>
where H: Unpin, S: Unpin,

§

impl<S, H> UnwindSafe for SwcNeuron<S, H>
where H: UnwindSafe, S: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.