SpikingNeuron

Struct SpikingNeuron 

Source
pub struct SpikingNeuron {
    pub membrane_potential: f64,
    pub threshold: f64,
    pub refractory_period: f64,
    pub time_since_spike: f64,
    pub leak_constant: f64,
    pub input_current: f64,
    pub position: Vec<f64>,
    pub learning_rate: f64,
}
Expand description

Spiking neuron model using leaky integrate-and-fire dynamics

This neuron model integrates input currents over time and generates spikes when the membrane potential exceeds a threshold. After spiking, the neuron enters a refractory period during which it cannot spike again.

§Model Dynamics

The membrane potential follows the equation: dV/dt = -leak_constant * V + I(t)

Where V is membrane potential and I(t) is input current.

§Example

use scirs2_spatial::neuromorphic::core::SpikingNeuron;

let mut neuron = SpikingNeuron::new(vec![0.0, 0.0]);

// Simulate neuron for several time steps
let dt = 0.1;
let input_current = 1.5;

for _ in 0..20 {
    let spiked = neuron.update(dt, input_current);
    if spiked {
        println!("Neuron spiked!");
    }
}

Fields§

§membrane_potential: f64

Membrane potential

§threshold: f64

Spike threshold

§refractory_period: f64

Refractory period

§time_since_spike: f64

Time since last spike

§leak_constant: f64

Leak constant

§input_current: f64

Input current

§position: Vec<f64>

Neuron position in space

§learning_rate: f64

Learning rate

Implementations§

Source§

impl SpikingNeuron

Source

pub fn new(position: Vec<f64>) -> Self

Create new spiking neuron

§Arguments
  • position - Spatial position of the neuron in N-dimensional space
§Returns

A new SpikingNeuron with default parameters

Source

pub fn with_params( position: Vec<f64>, threshold: f64, refractory_period: f64, leak_constant: f64, learning_rate: f64, ) -> Self

Create a new spiking neuron with custom parameters

§Arguments
  • position - Spatial position of the neuron
  • threshold - Spike threshold
  • refractory_period - Duration of refractory period
  • leak_constant - Membrane leak constant
  • learning_rate - Learning rate for adaptation
Source

pub fn update(&mut self, dt: f64, input_current: f64) -> bool

Update neuron state and check for spike

Integrates the neuron dynamics for one time step and determines if a spike should be generated.

§Arguments
  • dt - Time step size
  • input_current - Input current for this time step
§Returns

True if the neuron spiked, false otherwise

Source

pub fn calculate_influence(&self, other_position: &[f64]) -> f64

Calculate distance-based influence on another neuron

Computes the spatial influence this neuron has on another neuron based on their relative positions using a Gaussian function.

§Arguments
  • other_position - Position of the other neuron
§Returns

Influence strength (0 to 1)

Source

pub fn position(&self) -> &[f64]

Get neuron position

Source

pub fn set_position(&mut self, position: Vec<f64>)

Set neuron position

Source

pub fn membrane_potential(&self) -> f64

Get membrane potential

Source

pub fn set_membrane_potential(&mut self, potential: f64)

Set membrane potential

Source

pub fn threshold(&self) -> f64

Get spike threshold

Source

pub fn set_threshold(&mut self, threshold: f64)

Set spike threshold

Source

pub fn refractory_period(&self) -> f64

Get refractory period

Source

pub fn set_refractory_period(&mut self, period: f64)

Set refractory period

Source

pub fn leak_constant(&self) -> f64

Get leak constant

Source

pub fn set_leak_constant(&mut self, leak: f64)

Set leak constant

Source

pub fn learning_rate(&self) -> f64

Get learning rate

Source

pub fn set_learning_rate(&mut self, rate: f64)

Set learning rate

Source

pub fn is_refractory(&self) -> bool

Check if neuron is in refractory period

Source

pub fn time_since_spike(&self) -> f64

Get time since last spike

Source

pub fn reset(&mut self)

Reset neuron to initial state

Source

pub fn inject_current(&mut self, current: f64)

Inject current into the neuron

Source

pub fn distance_to(&self, other: &SpikingNeuron) -> Option<f64>

Calculate distance to another neuron

§Arguments
  • other - Reference to another neuron
§Returns

Euclidean distance between neurons, or None if dimensions don’t match

Source

pub fn adapt_threshold( &mut self, target_rate: f64, actual_rate: f64, adaptation_rate: f64, )

Adapt threshold based on recent activity (homeostatic plasticity)

§Arguments
  • target_rate - Target firing rate
  • actual_rate - Actual firing rate
  • adaptation_rate - Rate of threshold adaptation
Source

pub fn adapt_learning_rate( &mut self, performance_factor: f64, adaptation_rate: f64, )

Update learning rate based on recent performance

§Arguments
  • performance_factor - Factor indicating learning performance (0-1)
  • adaptation_rate - Rate of learning rate adaptation

Trait Implementations§

Source§

impl Clone for SpikingNeuron

Source§

fn clone(&self) -> SpikingNeuron

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 Debug for SpikingNeuron

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

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> IntoEither for T

Source§

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

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

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

Initializes a with the given initializer. Read more
Source§

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

Dereferences the given pointer. Read more
Source§

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

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

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

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

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

Source§

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

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

fn is_in_subset(&self) -> bool

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

fn to_subset_unchecked(&self) -> SS

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

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
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.
Source§

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

Source§

fn vzip(self) -> V