pub struct ScoreMatrixBuilder<T: TargetNeuron> { /* private fields */ }
Expand description

Calculate a score matrix (lookup table for converting point matches into NBLAST scores) from real data using some sets of matching and non-matching neurons.

At a minimum, one matching set must be added (.add_matching_set), and the dist and dot bins must either be set automatically or calculated (.set_(n_)?(dist|dot)_bins).

Implementations§

source§

impl<T: TargetNeuron + Sync> ScoreMatrixBuilder<T>

source

pub fn new(neurons: Vec<T>, seed: u64) -> Self

seed is used when randomly selecting non-matching neurons to use as controls.

source

pub fn add_matching_set(&mut self, matching: &[usize]) -> &mut Self

Add a set of neurons which are considered to be mutually matching, as indices into the ScoreMatrixBuilder.neurons. This can be done several times with different sets. Matching sets should be small subsets of the total neuron count.

Indices outside of the neuron vec will be silently filtered out. Filtered sets with length <2 will also be silently ignored.

source

pub fn add_nonmatching_set(&mut self, nonmatching: &[usize]) -> &mut Self

Optionally list neuron sets which are mutually non-matching, as indices into ScoreMatrixBuilder.neurons, from which non-matching pairs will be randomly drawn. By default, all neurons are included, as matching sets are expected to be only a small portion of the total neurons.

Candidate non-matching pairs are made sure not to be in the matching pairs, so this can safely be ignored.

source

pub fn set_use_alpha(&mut self, use_alpha: bool) -> &mut Self

Alpha values are a measure of how colinear a neuron’s local neighborhood is. Score matrices calculated using alpha can only be used for queries using alpha, and vice versa.

False by default.

source

pub fn set_dist_lookup(&mut self, lookup: BinLookup<Precision>) -> &mut Self

Manually set the lookup bins for distances.

Consider BinLookup::new_exp here.

source

pub fn set_n_dist_bins(&mut self, n_bins: usize) -> &mut Self

Automatically generate distance bins by by using distances from matching sets.

source

pub fn set_dot_lookup(&mut self, lookup: BinLookup<Precision>) -> &mut Self

Manually set the lookup bins for dot products.

Consider BinLookup::new_linear(0.0, 1.0, n_bins, (true, true)) here.

source

pub fn set_n_dot_bins(&mut self, n_bins: usize) -> &mut Self

Automatically generate abs dot product bins by using dot products from matching sets.

source

pub fn set_max_matching_pairs(&mut self, n_pairs: usize) -> &mut Self

Draw at most this many matching pairs from the given matching sets. May be fewer if there aren’t that many combinations. By default, uses all possible pairs.

source

pub fn set_max_nonmatching_pairs(&mut self, n_pairs: usize) -> &mut Self

Draw at most this many nonmatching pairs from the given nonmatching sets. May be fewer if there aren’t that many combinations. By default, uses as many pairs as for matching.

source

pub fn build( &self ) -> Result<RangeTable<Precision, Precision>, ScoreMatBuildErr>

Return a tuple of (dist_bins, dot_bins, cells) in the forms accepted by table_to_fn.

Auto Trait Implementations§

§

impl<T> RefUnwindSafe for ScoreMatrixBuilder<T>
where T: RefUnwindSafe,

§

impl<T> Send for ScoreMatrixBuilder<T>
where T: Send,

§

impl<T> Sync for ScoreMatrixBuilder<T>
where T: Sync,

§

impl<T> Unpin for ScoreMatrixBuilder<T>
where T: Unpin,

§

impl<T> UnwindSafe for ScoreMatrixBuilder<T>
where T: 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> Az for T

source§

fn az<Dst>(self) -> Dst
where T: Cast<Dst>,

Casts the value.
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<Src, Dst> CastFrom<Src> for Dst
where Src: Cast<Dst>,

source§

fn cast_from(src: Src) -> Dst

Casts the value.
source§

impl<T> CheckedAs for T

source§

fn checked_as<Dst>(self) -> Option<Dst>
where T: CheckedCast<Dst>,

Casts the value.
source§

impl<Src, Dst> CheckedCastFrom<Src> for Dst
where Src: CheckedCast<Dst>,

source§

fn checked_cast_from(src: Src) -> Option<Dst>

Casts the value.
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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<Src, Dst> LosslessTryInto<Dst> for Src
where Dst: LosslessTryFrom<Src>,

source§

fn lossless_try_into(self) -> Option<Dst>

Performs the conversion.
source§

impl<Src, Dst> LossyInto<Dst> for Src
where Dst: LossyFrom<Src>,

source§

fn lossy_into(self) -> Dst

Performs the conversion.
source§

impl<T> OverflowingAs for T

source§

fn overflowing_as<Dst>(self) -> (Dst, bool)
where T: OverflowingCast<Dst>,

Casts the value.
source§

impl<Src, Dst> OverflowingCastFrom<Src> for Dst
where Src: OverflowingCast<Dst>,

source§

fn overflowing_cast_from(src: Src) -> (Dst, bool)

Casts the value.
§

impl<T> Pointable for T

§

const ALIGN: usize = _

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

impl<T> Same for T

§

type Output = T

Should always be Self
source§

impl<T> SaturatingAs for T

source§

fn saturating_as<Dst>(self) -> Dst
where T: SaturatingCast<Dst>,

Casts the value.
source§

impl<Src, Dst> SaturatingCastFrom<Src> for Dst
where Src: SaturatingCast<Dst>,

source§

fn saturating_cast_from(src: Src) -> Dst

Casts the value.
§

impl<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
§

fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).
§

fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
source§

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

§

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

§

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

impl<T> UnwrappedAs for T

source§

fn unwrapped_as<Dst>(self) -> Dst
where T: UnwrappedCast<Dst>,

Casts the value.
source§

impl<Src, Dst> UnwrappedCastFrom<Src> for Dst
where Src: UnwrappedCast<Dst>,

source§

fn unwrapped_cast_from(src: Src) -> Dst

Casts the value.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more
source§

impl<T> WrappingAs for T

source§

fn wrapping_as<Dst>(self) -> Dst
where T: WrappingCast<Dst>,

Casts the value.
source§

impl<Src, Dst> WrappingCastFrom<Src> for Dst
where Src: WrappingCast<Dst>,

source§

fn wrapping_cast_from(src: Src) -> Dst

Casts the value.