pub struct SpikeTrain {
pub neuron_id: usize,
pub spike_times: Vec<SimTime>,
pub max_window: f64,
}Expand description
A collection of spikes over time for one neuron
Fields§
§neuron_id: usizeNeuron ID
spike_times: Vec<SimTime>Spike times (sorted)
max_window: f64Maximum time window to keep
Implementations§
Source§impl SpikeTrain
impl SpikeTrain
Sourcepub fn with_window(neuron_id: usize, max_window: f64) -> Self
pub fn with_window(neuron_id: usize, max_window: f64) -> Self
Create with custom window size
Sourcepub fn record_spike(&mut self, time: SimTime)
pub fn record_spike(&mut self, time: SimTime)
Record a spike at given time
Sourcepub fn spike_rate(&self, window: f64) -> f64
pub fn spike_rate(&self, window: f64) -> f64
Compute instantaneous spike rate (spikes/ms)
Sourcepub fn to_pattern(
&self,
start: SimTime,
bin_size: f64,
num_bins: usize,
) -> Vec<bool>
pub fn to_pattern( &self, start: SimTime, bin_size: f64, num_bins: usize, ) -> Vec<bool>
Convert spike train to binary pattern (temporal encoding)
Safely handles potential overflow in bin calculation.
Sourcepub fn cross_correlation(
&self,
other: &SpikeTrain,
max_lag: f64,
bin_size: f64,
) -> Vec<f64>
pub fn cross_correlation( &self, other: &SpikeTrain, max_lag: f64, bin_size: f64, ) -> Vec<f64>
Compute cross-correlation with another spike train
Uses O(n log n) sliding window algorithm instead of O(n²) pairwise comparison. Optimized to skip sorting when spike trains are already sorted (typical case). Uses binary search for initial window position.
Trait Implementations§
Source§impl Clone for SpikeTrain
impl Clone for SpikeTrain
Source§fn clone(&self) -> SpikeTrain
fn clone(&self) -> SpikeTrain
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for SpikeTrain
impl RefUnwindSafe for SpikeTrain
impl Send for SpikeTrain
impl Sync for SpikeTrain
impl Unpin for SpikeTrain
impl UnwindSafe for SpikeTrain
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more