use scirs2_core::ndarray::{Array1, Array2, Array3, Array4};
use std::collections::{HashMap, VecDeque};
#[derive(Debug, Clone)]
pub struct BiologicalVisionConfig {
pub cortical_layers: usize,
pub receptive_field_sizes: Vec<usize>,
pub lateral_inhibition_strength: f64,
pub temporal_window: usize,
pub attention_radius: usize,
pub saccade_horizon: usize,
pub color_adaptation_rate: f64,
pub motion_prediction_window: usize,
pub ommatidial_count: usize,
pub prediction_error_threshold: f64,
}
impl Default for BiologicalVisionConfig {
fn default() -> Self {
Self {
cortical_layers: 6,
receptive_field_sizes: vec![3, 5, 7, 11, 15, 21],
lateral_inhibition_strength: 0.5,
temporal_window: 10,
attention_radius: 50,
saccade_horizon: 5,
color_adaptation_rate: 0.1,
motion_prediction_window: 8,
ommatidial_count: 1000,
prediction_error_threshold: 0.3,
}
}
}
#[derive(Debug, Clone)]
pub struct CorticalLayer {
pub level: usize,
pub feature_maps: Array3<f64>,
pub receptive_field_size: usize,
pub lateral_connections: Array2<f64>,
pub top_down_predictions: Array3<f64>,
pub bottom_upfeatures: Array3<f64>,
pub prediction_errors: Array3<f64>,
}
#[derive(Debug, Clone)]
pub struct RetinaModel {
pub photoreceptors: Array2<f64>,
pub bipolar_cells: Array2<f64>,
pub horizontal_cells: Array2<f64>,
pub ganglion_cells: Array2<f64>,
pub center_surround_filters: Vec<Array2<f64>>,
}
#[derive(Debug, Clone)]
pub struct CompoundEyeModel {
pub ommatidia: Vec<Ommatidium>,
pub motion_detectors: Array2<f64>,
pub wide_field_neurons: Array1<f64>,
pub looming_detectors: Array1<f64>,
}
#[derive(Debug, Clone)]
pub struct Ommatidium {
pub position: (f64, f64),
pub optical_axis: (f64, f64, f64),
pub response: f64,
pub responsehistory: VecDeque<f64>,
}
#[derive(Debug, Clone)]
pub struct AttentionSystem {
pub attention_center: (usize, usize),
pub attention_map: Array2<f64>,
pub saccade_targets: Vec<(usize, usize)>,
pub inhibition_of_return: Array2<f64>,
pub feature_attention_weights: HashMap<String, f64>,
}
#[derive(Debug, Clone)]
pub struct PredictiveCodingSystem {
pub prediction_models: Vec<Array3<f64>>,
pub prediction_errors: Vec<Array3<f64>>,
pub temporal_predictions: Vec<Array4<f64>>,
pub confidence_estimates: Vec<Array3<f64>>,
}
#[derive(Debug, Clone)]
pub struct ColorConstancySystem {
pub illumination_estimates: Array2<(f64, f64, f64)>,
pub surface_reflectance: Array2<(f64, f64, f64)>,
pub adaptationstate: (f64, f64, f64),
pub color_memory: Vec<(f64, f64, f64)>,
}
#[derive(Debug, Clone)]
pub struct MotionTrack {
pub object_id: usize,
pub position: (f64, f64),
pub velocity: (f64, f64),
pub positionhistory: VecDeque<(f64, f64)>,
pub predicted_positions: Vec<(f64, f64)>,
pub confidence: f64,
pub age: usize,
}
impl CorticalLayer {
pub fn new(level: usize, height: usize, width: usize, receptive_field_size: usize) -> Self {
Self {
level,
feature_maps: Array3::zeros((8, height, width)), receptive_field_size,
lateral_connections: Array2::zeros((height, width)),
top_down_predictions: Array3::zeros((8, height, width)),
bottom_upfeatures: Array3::zeros((8, height, width)),
prediction_errors: Array3::zeros((8, height, width)),
}
}
}
impl RetinaModel {
pub fn new(height: usize, width: usize) -> Self {
Self {
photoreceptors: Array2::zeros((height, width)),
bipolar_cells: Array2::zeros((height, width)),
horizontal_cells: Array2::zeros((height, width)),
ganglion_cells: Array2::zeros((height, width)),
center_surround_filters: Vec::new(),
}
}
}
impl Ommatidium {
pub fn new(position: (f64, f64), optical_axis: (f64, f64, f64)) -> Self {
Self {
position,
optical_axis,
response: 0.0,
responsehistory: VecDeque::new(),
}
}
}