Skip to main content

ConnectomeManager

Struct ConnectomeManager 

Source
pub struct ConnectomeManager { /* private fields */ }
Expand description

Central manager for the FEAGI connectome

§Responsibilities

  1. Cortical Area Management: Add, remove, query cortical areas
  2. Brain Region Management: Hierarchical organization
  3. Neuron/Synapse Queries: High-level API (delegates to NPU)
  4. Genome I/O: Load/save brain structure

§Data Storage

  • Cortical areas: Stored in HashMap for O(1) lookup
  • Brain regions: Stored in BrainRegionHierarchy
  • Neuron data: Lives in NPU (not stored here)
  • Synapse data: Lives in NPU (not stored here)

§Thread Safety

Uses RwLock for concurrent reads with exclusive writes. Multiple threads can read simultaneously, but writes block.

Implementations§

Source§

impl ConnectomeManager

Source

pub fn instance() -> Arc<RwLock<ConnectomeManager>>

Get the global singleton instance

§Returns

Arc to the ConnectomeManager wrapped in RwLock

§Example
use feagi_brain_development::ConnectomeManager;

let manager = ConnectomeManager::instance();
let read_lock = manager.read();
let area_count = read_lock.get_cortical_area_count();
Source

pub fn new_for_testing() -> Self

Calculate optimal visualization voxel granularity for a cortical area

This function determines the granularity for aggregated rendering based on:

  • Total voxel count (larger areas get larger chunks)
  • Aspect ratio (handles thin dimensions like 1024×900×3)
  • Target chunk count (~2k-10k chunks for manageable message size)
§Arguments
  • dimensions - The cortical area dimensions (width, height, depth)
§Returns

Tuple of (chunk_x, chunk_y, chunk_z) that divides evenly into dimensions

Create a new isolated instance for testing

This bypasses the singleton pattern and creates a fresh instance. Use this in tests to avoid conflicts between parallel test runs.

§Example
let manager = ConnectomeManager::new_for_testing();
// Use manager in isolated test
Source

pub fn new_for_testing_with_npu(npu: Arc<TracingMutex<DynamicNPU>>) -> Self

Create a new isolated instance for testing with NPU

This bypasses the singleton pattern and creates a fresh instance with NPU connected. Use this in tests to avoid conflicts between parallel test runs.

§Arguments
  • npu - Arc<TracingMutex> to connect to this manager
§Example
let npu = Arc::new(TracingMutex::new(RustNPU::new(1_000_000, 10_000_000, 10), "NPU"));
let manager = ConnectomeManager::new_for_testing_with_npu(npu);
Source

pub fn setup_core_morphologies_for_testing(&mut self)

Set up core morphologies in the registry (for testing only)

This is a test helper to set up core morphologies (projector, block_to_block, etc.) in the morphology registry so that synaptogenesis tests can run.

§Note

This should only be called in tests. Morphologies are typically loaded from genome files. This method is public to allow integration tests to access it.

Source

pub fn refresh_cortical_area_hashes( &self, properties_changed: bool, geometry_changed: bool, )

Refresh cortical area-related hashes based on the affected data.

Source

pub fn add_cortical_area(&mut self, area: CorticalArea) -> BduResult<u32>

Add a new cortical area

§Arguments
  • area - The cortical area to add
§Returns

The assigned cortical index

§Errors

Returns error if:

  • An area with the same cortical_id already exists
  • The area’s cortical_idx conflicts with an existing area
Source

pub fn remove_cortical_area( &mut self, cortical_id: &CorticalID, ) -> BduResult<()>

Remove a cortical area by ID

§Arguments
  • cortical_id - ID of the cortical area to remove
§Returns

Ok(()) if removed, error if area doesn’t exist

§Note

This does NOT remove neurons from the NPU - that must be done separately.

Source

pub fn rename_cortical_area_id( &mut self, old_id: &CorticalID, new_id: CorticalID, new_cortical_type: CorticalAreaType, ) -> BduResult<()>

Update a cortical area ID without changing its cortical_idx.

This remaps internal lookup tables, brain-region membership, and mapping keys.

Source

pub fn rename_cortical_area_id_with_options( &mut self, old_id: &CorticalID, new_id: CorticalID, new_cortical_type: CorticalAreaType, update_npu_registry: bool, ) -> BduResult<()>

Update a cortical area ID without changing its cortical_idx, with optional NPU registry update.

Source

pub fn get_cortical_area( &self, cortical_id: &CorticalID, ) -> Option<&CorticalArea>

Get a cortical area by ID

Source

pub fn get_cortical_area_mut( &mut self, cortical_id: &CorticalID, ) -> Option<&mut CorticalArea>

Get a mutable reference to a cortical area

Source

pub fn get_cortical_idx(&self, cortical_id: &CorticalID) -> Option<u32>

Get cortical index by ID

Source

pub fn get_parent_region_id_for_area( &self, cortical_id: &CorticalID, ) -> Option<String>

Find which brain region contains a cortical area

This is used to populate parent_region_id in API responses for Brain Visualizer. Delegates to BrainRegionHierarchy for the actual search.

§Arguments
  • cortical_id - Cortical area to search for
§Returns
  • Option<String> - Parent region ID (UUID string) if found
Source

pub fn recompute_brain_region_io_registry( &mut self, ) -> BduResult<HashMap<String, (Vec<String>, Vec<String>)>>

Recompute brain-region inputs/outputs registries from current cortical mappings.

This drives /v1/region/regions_members (via BrainRegion.properties["inputs"/"outputs"]).

Semantics (matches Python _auto_assign_region_io() and BV expectations):

  • outputs: Any cortical area in the region that connects to an area outside the region
  • inputs: Any cortical area in the region that receives a connection from outside the region

This function updates the hierarchy in-place and returns the computed base64 ID lists for downstream persistence into RuntimeGenome.

Source

pub fn get_root_region_id(&self) -> Option<String>

Get the root brain region ID (region with no parent)

§Returns
  • Option<String> - Root region ID (UUID string) if found
Source

pub fn get_cortical_id(&self, cortical_idx: u32) -> Option<&CorticalID>

Get cortical ID by index

Source

pub fn get_all_cortical_idx_to_id_mappings(&self) -> AHashMap<u32, String>

Get all cortical_idx -> cortical_id mappings (for burst loop caching) Returns a HashMap of cortical_idx -> cortical_id (base64 string)

Source

pub fn get_all_visualization_granularities( &self, ) -> AHashMap<u32, (u32, u32, u32)>

Get all cortical_idx -> visualization_voxel_granularity mappings

Returns a map of cortical_idx to (granularity_x, granularity_y, granularity_z) for areas that have visualization voxel granularity configured.

Source

pub fn get_cortical_area_ids(&self) -> Vec<&CorticalID>

Get all cortical area IDs

Source

pub fn get_cortical_area_count(&self) -> usize

Get the number of cortical areas

Source

pub fn get_upstream_cortical_areas( &self, target_cortical_id: &CorticalID, ) -> Vec<u32>

Get all cortical areas that have synapses targeting the specified area (upstream/afferent areas)

Reads from the upstream_cortical_areas property stored on the cortical area. This property is maintained by add_upstream_area() and remove_upstream_area().

§Arguments
  • target_cortical_id - The cortical area ID to find upstream connections for
§Returns

Vec of cortical_idx values for all upstream areas

Source

pub fn filter_non_memory_upstream_areas(&self, upstream: &[u32]) -> Vec<u32>

Filter upstream cortical indices to exclude memory areas.

Source

pub fn refresh_upstream_cortical_areas_from_mappings( &mut self, target_cortical_id: &CorticalID, ) -> Vec<u32>

Recompute and persist upstream_cortical_areas for a target area from mapping properties.

This is a recovery path for stale upstream tracking (e.g., bidirectional mappings that were mirrored into properties but not fully regenerated).

Source

pub fn add_upstream_area( &mut self, target_cortical_id: &CorticalID, src_cortical_idx: u32, )

Add an upstream cortical area to a target area’s upstream list

This should be called when synapses are created from src_cortical_idx to target_cortical_id.

§Arguments
  • target_cortical_id - The cortical area receiving connections
  • src_cortical_idx - The cortical index of the source area
Source

pub fn get_memory_twin_for_upstream_idx( &self, memory_area_idx: u32, upstream_idx: u32, ) -> Option<CorticalID>

Get the memory twin cortical ID for a given memory area and upstream area.

Source

pub fn ensure_memory_twin_area( &mut self, memory_area_id: &CorticalID, upstream_area_id: &CorticalID, ) -> BduResult<CorticalID>

Ensure a memory twin area exists for the given upstream and memory areas.

Source

pub fn remove_upstream_area( &mut self, target_cortical_id: &CorticalID, src_cortical_idx: u32, )

Remove an upstream cortical area from a target area’s upstream list

This should be called when all synapses from src_cortical_idx to target_cortical_id are deleted.

§Arguments
  • target_cortical_id - The cortical area that had connections
  • src_cortical_idx - The cortical index of the source area to remove
Source

pub fn has_cortical_area(&self, cortical_id: &CorticalID) -> bool

Check if a cortical area exists

Source

pub fn is_initialized(&self) -> bool

Check if the connectome is initialized (has areas)

Source

pub fn add_brain_region( &mut self, region: BrainRegion, parent_id: Option<String>, ) -> BduResult<()>

Add a brain region

Source

pub fn remove_brain_region(&mut self, region_id: &str) -> BduResult<()>

Remove a brain region

Source

pub fn change_brain_region_parent( &mut self, region_id: &str, new_parent_id: &str, ) -> BduResult<()>

Change the parent of an existing brain region.

Source

pub fn get_brain_region(&self, region_id: &str) -> Option<&BrainRegion>

Get a brain region by ID

Source

pub fn get_brain_region_mut( &mut self, region_id: &str, ) -> Option<&mut BrainRegion>

Get a mutable reference to a brain region

Source

pub fn get_brain_region_ids(&self) -> Vec<&String>

Get all brain region IDs

Source

pub fn get_brain_region_hierarchy(&self) -> &BrainRegionHierarchy

Get the brain region hierarchy

Source

pub fn get_morphologies(&self) -> &MorphologyRegistry

Get all morphologies from the loaded genome

Source

pub fn get_morphology_count(&self) -> usize

Get morphology count

Source

pub fn upsert_morphology( &mut self, morphology_id: String, morphology: Morphology, )

Insert or overwrite a morphology definition in the in-memory registry.

NOTE: This updates the runtime registry used by mapping/synapse generation. Callers that also maintain a RuntimeGenome (source of truth) MUST update it too.

Source

pub fn remove_morphology(&mut self, morphology_id: &str) -> bool

Remove a morphology definition from the in-memory registry.

Returns true if the morphology existed and was removed.

NOTE: Callers that also maintain a RuntimeGenome (source of truth) MUST update it too.

Source

pub fn update_cortical_mapping( &mut self, src_area_id: &CorticalID, dst_area_id: &CorticalID, mapping_data: Vec<Value>, ) -> BduResult<()>

Update cortical mapping properties between two cortical areas

Following Python’s update_cortical_mapping_properties() logic:

  1. Updates the source area’s cortical_mapping_dst property
  2. Triggers synapse regeneration for the affected connection
§Arguments
  • src_area_id - Source cortical area ID
  • dst_area_id - Destination cortical area ID
  • mapping_data - List of connection specifications
§Returns
  • BduResult<()> - Ok if successful, Err otherwise
Source

pub fn regenerate_synapses_for_mapping( &mut self, src_area_id: &CorticalID, dst_area_id: &CorticalID, ) -> BduResult<usize>

Regenerate synapses for a specific cortical mapping

Creates new synapses based on mapping rules. Only removes existing synapses if a mapping already existed (update case), not for new mappings (allows multiple synapses between the same neurons).

§Arguments
  • src_area_id - Source cortical area ID
  • dst_area_id - Destination cortical area ID
§Returns
  • BduResult<usize> - Number of synapses created
Source

pub fn set_npu(&mut self, npu: Arc<TracingMutex<DynamicNPU>>)

Set the NPU reference for neuron/synapse queries

This should be called once during FEAGI initialization after the NPU is created.

§Arguments
  • npu - Arc to the Rust NPU (wrapped in TracingMutex for automatic lock tracing)
Source

pub fn has_npu(&self) -> bool

Check if NPU is connected

Source

pub fn get_npu(&self) -> Option<&Arc<TracingMutex<DynamicNPU>>>

Get NPU reference (read-only access for queries)

§Returns
  • Option<&Arc<Mutex<RustNPU>>> - Reference to NPU if connected
Source

pub fn set_plasticity_executor( &mut self, executor: Arc<Mutex<AsyncPlasticityExecutor>>, )

Set the PlasticityExecutor reference (optional, only if plasticity feature enabled) The executor is passed as Arc<Mutex> for feature-gating compatibility

Source

pub fn get_plasticity_executor( &self, ) -> Option<&Arc<Mutex<AsyncPlasticityExecutor>>>

Get the PlasticityExecutor reference (if plasticity feature enabled)

Source

pub fn get_neuron_capacity(&self) -> usize

Get neuron capacity from config (lock-free, never acquires NPU lock)

§Returns
  • usize - Maximum neuron capacity from config (single source of truth)
§Performance

This is a lock-free read from config that never blocks, even during burst processing. Capacity values are set at NPU initialization and never change.

Source

pub fn get_synapse_capacity(&self) -> usize

Get synapse capacity from config (lock-free, never acquires NPU lock)

§Returns
  • usize - Maximum synapse capacity from config (single source of truth)
§Performance

This is a lock-free read from config that never blocks, even during burst processing. Capacity values are set at NPU initialization and never change.

Source

pub fn update_fatigue_index(&self) -> Option<u8>

Update fatigue index based on utilization of neuron and synapse arrays

Calculates fatigue index as max(regular_neuron_util%, memory_neuron_util%, synapse_util%) Applies hysteresis: triggers at 85%, clears at 80% Rate limited to max once per 2 seconds to protect against rapid changes

§Safety

This method is completely non-blocking and safe to call during genome loading. If StateManager is unavailable or locked, it will skip the calculation gracefully.

§Returns
  • Option<u8> - New fatigue index (0-100) if calculation was performed, None if rate limited or StateManager unavailable
Source

pub fn create_neurons_for_area( &mut self, cortical_id: &CorticalID, ) -> BduResult<u32>

Create neurons for a cortical area

This delegates to the NPU’s optimized batch creation function.

§Arguments
  • cortical_id - Cortical area ID (6-character string)
§Returns

Number of neurons created

Source

pub fn add_neuron( &mut self, cortical_id: &CorticalID, x: u32, y: u32, z: u32, firing_threshold: f32, firing_threshold_limit: f32, leak_coefficient: f32, resting_potential: f32, neuron_type: u8, refractory_period: u16, excitability: f32, consecutive_fire_limit: u16, snooze_length: u16, mp_charge_accumulation: bool, ) -> BduResult<u64>

Add a single neuron to a cortical area

§Arguments
  • cortical_id - Cortical area ID
  • x - X coordinate
  • y - Y coordinate
  • z - Z coordinate
  • firing_threshold - Firing threshold (minimum MP to fire)
  • firing_threshold_limit - Firing threshold limit (maximum MP to fire, 0 = no limit)
  • leak_coefficient - Leak coefficient
  • resting_potential - Resting membrane potential
  • neuron_type - Neuron type (0=excitatory, 1=inhibitory)
  • refractory_period - Refractory period
  • excitability - Excitability multiplier
  • consecutive_fire_limit - Maximum consecutive fires
  • snooze_length - Snooze duration after consecutive fire limit
  • mp_charge_accumulation - Whether membrane potential accumulates
§Returns

The newly created neuron ID

Source

pub fn delete_neuron(&mut self, neuron_id: u64) -> BduResult<bool>

Delete a neuron by ID

§Arguments
  • neuron_id - Global neuron ID
§Returns

true if the neuron was deleted, false if it didn’t exist

Source

pub fn apply_cortical_mapping( &mut self, src_cortical_id: &CorticalID, ) -> BduResult<u32>

Apply cortical mapping rules (dstmap) to create synapses

This parses the destination mapping rules from a source area and creates synapses using the NPU’s synaptogenesis functions.

§Arguments
  • src_cortical_id - Source cortical area ID
§Returns

Number of synapses created

Source

pub fn has_neuron(&self, neuron_id: u64) -> bool

Check if a neuron exists

§Arguments
  • neuron_id - The neuron ID to check
§Returns

true if the neuron exists in the NPU, false otherwise

§Note

Returns false if NPU is not connected

Source

pub fn get_neuron_count(&self) -> usize

Get total number of active neurons (lock-free cached read with opportunistic update)

§Returns

The total number of neurons (from cache)

§Performance

This is a lock-free atomic read that never blocks, even during burst processing. Opportunistically updates cache if NPU is available (non-blocking try_lock).

Source

pub fn update_cached_neuron_count(&self)

Update the cached neuron count (explicit update)

Use this if you want to force a cache update. Most callers should just use get_neuron_count() which updates opportunistically.

Source

pub fn refresh_neuron_count_for_area( &self, cortical_id: &CorticalID, ) -> Option<usize>

Refresh cached neuron count for a single cortical area from the NPU.

Returns the refreshed count if successful.

Source

pub fn get_synapse_count(&self) -> usize

Get total number of synapses (lock-free cached read with opportunistic update)

§Returns

The total number of synapses (from cache)

§Performance

This is a lock-free atomic read that never blocks, even during burst processing. Opportunistically updates cache if NPU is available (non-blocking try_lock).

Source

pub fn update_cached_synapse_count(&self)

Update the cached synapse count (explicit update)

Use this if you want to force a cache update. Most callers should just use get_synapse_count() which updates opportunistically.

Source

pub fn update_all_cached_stats(&self)

Update all cached stats (neuron and synapse counts)

This is called automatically when NPU is connected and can be called explicitly if you want to force a cache refresh.

Source

pub fn get_neuron_coordinates(&self, neuron_id: u64) -> (u32, u32, u32)

Get neuron coordinates (x, y, z)

§Arguments
  • neuron_id - The neuron ID to query
§Returns

Coordinates as (x, y, z), or (0, 0, 0) if neuron doesn’t exist or NPU not connected

Source

pub fn get_neuron_cortical_idx(&self, neuron_id: u64) -> u32

Get the cortical area index for a neuron

§Arguments
  • neuron_id - The neuron ID to query
§Returns

Cortical area index, or 0 if neuron doesn’t exist or NPU not connected

Source

pub fn get_neurons_in_area(&self, cortical_id: &CorticalID) -> Vec<u64>

Get all neuron IDs in a specific cortical area

§Arguments
  • cortical_id - The cortical area ID (string)
§Returns

Vec of neuron IDs in the area, or empty vec if area doesn’t exist or NPU not connected

Source

pub fn get_outgoing_synapses( &self, source_neuron_id: u64, ) -> Vec<(u32, u8, u8, u8)>

Get all outgoing synapses from a source neuron

§Arguments
  • source_neuron_id - The source neuron ID
§Returns

Vec of (target_neuron_id, weight, psp, synapse_type), or empty if NPU not connected

Source

pub fn get_incoming_synapses( &self, target_neuron_id: u64, ) -> Vec<(u32, u8, u8, u8)>

Get all incoming synapses to a target neuron

§Arguments
  • target_neuron_id - The target neuron ID
§Returns

Vec of (source_neuron_id, weight, psp, synapse_type), or empty if NPU not connected

Source

pub fn get_neuron_count_in_area(&self, cortical_id: &CorticalID) -> usize

Get neuron count for a specific cortical area

§Arguments
  • cortical_id - The cortical area ID (string)
§Returns

Number of neurons in the area, or 0 if area doesn’t exist or NPU not connected

Get neuron count for a specific cortical area (lock-free cached read)

§Arguments
  • cortical_id - The cortical area ID
§Returns

The number of neurons in the area (from cache, never blocks on NPU lock)

§Performance

This is a lock-free atomic read that never blocks, even during burst processing. Count is maintained in ConnectomeManager and updated when neurons are created/deleted.

Source

pub fn get_populated_areas(&self) -> Vec<(String, usize)>

Get all cortical areas that have neurons

§Returns

Vec of (cortical_id, neuron_count) for areas with at least one neuron

Source

pub fn is_area_populated(&self, cortical_id: &CorticalID) -> bool

Check if a cortical area has any neurons

§Arguments
  • cortical_id - The cortical area ID
§Returns

true if the area has at least one neuron, false otherwise

Source

pub fn get_synapse_count_in_area(&self, cortical_id: &CorticalID) -> usize

Get total synapse count for a specific cortical area (outgoing only) - lock-free cached read

§Arguments
  • cortical_id - The cortical area ID
§Returns

Total number of outgoing synapses from neurons in this area (from cache, never blocks on NPU lock)

§Performance

This is a lock-free atomic read that never blocks, even during burst processing. Count is maintained in ConnectomeManager and updated when synapses are created/deleted.

Source

pub fn get_incoming_synapse_count_in_area( &self, cortical_id: &CorticalID, ) -> usize

Get total incoming synapse count for a specific cortical area.

§Arguments
  • cortical_id - The cortical area ID
§Returns

Total number of incoming synapses targeting neurons in this area.

Source

pub fn get_outgoing_synapse_count_in_area( &self, cortical_id: &CorticalID, ) -> usize

Get total outgoing synapse count for a specific cortical area.

§Arguments
  • cortical_id - The cortical area ID
§Returns

Total number of outgoing synapses originating from neurons in this area.

Source

pub fn are_neurons_connected( &self, source_neuron_id: u64, target_neuron_id: u64, ) -> bool

Check if two neurons are connected (source → target)

§Arguments
  • source_neuron_id - The source neuron ID
  • target_neuron_id - The target neuron ID
§Returns

true if there is a synapse from source to target, false otherwise

Source

pub fn get_connection_weight( &self, source_neuron_id: u64, target_neuron_id: u64, ) -> Option<u8>

Get connection strength (weight) between two neurons

§Arguments
  • source_neuron_id - The source neuron ID
  • target_neuron_id - The target neuron ID
§Returns

Synapse weight (0-255), or None if no connection exists

Source

pub fn get_area_connectivity_stats( &self, cortical_id: &CorticalID, ) -> (usize, usize, f32)

Get connectivity statistics for a cortical area

§Arguments
  • cortical_id - The cortical area ID
§Returns

(neuron_count, total_synapses, avg_synapses_per_neuron)

Source

pub fn get_neuron_cortical_id(&self, neuron_id: u64) -> Option<CorticalID>

Get the cortical area ID (string) for a neuron

§Arguments
  • neuron_id - The neuron ID
§Returns

The cortical area ID, or None if neuron doesn’t exist

Source

pub fn get_neuron_density(&self, cortical_id: &CorticalID) -> f32

Get neuron density (neurons per voxel) for a cortical area

§Arguments
  • cortical_id - The cortical area ID
§Returns

Neuron density (neurons per voxel), or 0.0 if area doesn’t exist

Source

pub fn get_all_area_stats(&self) -> Vec<(String, usize, usize, f32)>

Get all cortical areas with connectivity statistics

§Returns

Vec of (cortical_id, neuron_count, synapse_count, density)

Source

pub fn get_config(&self) -> &ConnectomeConfig

Get the configuration

Source

pub fn set_config(&mut self, config: ConnectomeConfig)

Update configuration

Source

pub fn load_genome_from_json(&mut self, json_str: &str) -> BduResult<()>

Load a genome from JSON string

This method:

  1. Parses the genome JSON
  2. Creates cortical areas from the blueprint
  3. Reconstructs the brain region hierarchy
  4. Stores neuron morphologies for later processing
§Arguments
  • json_str - JSON string of the genome
§Returns

Ok(()) if genome loaded successfully

§Errors

Returns error if:

  • JSON is malformed
  • Required fields are missing
  • Cortical areas have invalid data
  • Brain region hierarchy is invalid
§Example
use feagi_brain_development::ConnectomeManager;

let manager = ConnectomeManager::instance();
let mut mgr = manager.write();

let genome_json = r#"{ "version": "2.1", "blueprint": {...} }"#;
mgr.load_genome_from_json(genome_json)?;
Source

pub fn ensure_core_cortical_areas(&mut self) -> BduResult<()>

Ensure core cortical areas (_death, _power, _fatigue) exist

Core areas are required for brain operation:

  • _death (cortical_idx=0): Manages neuron death and cleanup
  • _power (cortical_idx=1): Provides power injection for burst engine
  • _fatigue (cortical_idx=2): Monitors brain fatigue and triggers sleep mode

If any core area is missing from the genome, it will be automatically created with default properties (1x1x1 dimensions, minimal configuration).

§Returns
  • Ok(()) if all core areas exist or were successfully created
  • Err(BduError) if creation fails
Source

pub fn save_genome_to_json( &self, genome_id: Option<String>, genome_title: Option<String>, ) -> BduResult<String>

👎Deprecated: Use GenomeService::save_genome() instead. This produces incomplete v2.1 format without morphologies/physiology.

Save the connectome as a genome JSON

DEPRECATED: This method produces incomplete hierarchical format v2.1 without morphologies/physiology. Use GenomeService::save_genome() instead, which produces complete flat format v3.0.

This method is kept only for legacy tests. Production code MUST use GenomeService.

§Arguments
  • genome_id - Optional custom genome ID (generates timestamp-based ID if None)
  • genome_title - Optional custom genome title
§Returns

JSON string representation of the genome (hierarchical v2.1, incomplete)

Source

pub fn prepare_for_new_genome(&mut self) -> BduResult<()>

Prepare for loading a new genome

Clears all existing cortical areas, brain regions, and resets state. This is typically called before loading a new genome.

Source

pub fn resize_for_genome(&mut self, genome: &RuntimeGenome) -> BduResult<()>

Calculate and resize memory for a genome

Analyzes the genome to determine memory requirements and prepares the NPU for the expected neuron/synapse counts.

§Arguments
  • genome - Genome to analyze for memory requirements
Source

pub fn create_synapse( &mut self, source_neuron_id: u64, target_neuron_id: u64, weight: u8, psp: u8, synapse_type: u8, ) -> BduResult<()>

Create a synapse between two neurons

§Arguments
  • source_neuron_id - Source neuron ID
  • target_neuron_id - Target neuron ID
  • weight - Synapse weight (0-255)
  • psp - Synapse PSP (0-255)
  • synapse_type - Synapse type (0=excitatory, 1=inhibitory)
§Returns

Ok(()) if synapse created successfully

Source

pub fn get_synapse( &self, source_neuron_id: u64, target_neuron_id: u64, ) -> Option<(u8, u8, u8)>

Get synapse information between two neurons

§Arguments
  • source_neuron_id - Source neuron ID
  • target_neuron_id - Target neuron ID
§Returns

Some((weight, psp, type)) if synapse exists, None otherwise

Source

pub fn update_synapse_weight( &mut self, source_neuron_id: u64, target_neuron_id: u64, new_weight: u8, ) -> BduResult<()>

Update the weight of an existing synapse

§Arguments
  • source_neuron_id - Source neuron ID
  • target_neuron_id - Target neuron ID
  • new_weight - New synapse weight (0-255)
§Returns

Ok(()) if synapse updated, Err if synapse not found

Source

pub fn remove_synapse( &mut self, source_neuron_id: u64, target_neuron_id: u64, ) -> BduResult<bool>

Remove a synapse between two neurons

§Arguments
  • source_neuron_id - Source neuron ID
  • target_neuron_id - Target neuron ID
§Returns

Ok(true) if synapse removed, Ok(false) if synapse didn’t exist

Source

pub fn batch_create_neurons( &mut self, cortical_id: &CorticalID, neurons: Vec<(u32, u32, u32, f32, f32, f32, f32, i32, u16, f32, u16, u16, bool)>, ) -> BduResult<Vec<u64>>

Batch create multiple neurons at once (SIMD-optimized)

This is significantly faster than calling add_neuron() in a loop

§Arguments
  • cortical_id - Target cortical area
  • neurons - Vector of neuron parameters (x, y, z, firing_threshold, leak, resting_potential, etc.)
§Returns

Vector of created neuron IDs

Source

pub fn delete_neurons_batch(&mut self, neuron_ids: Vec<u64>) -> BduResult<usize>

Delete multiple neurons at once (batch operation)

§Arguments
  • neuron_ids - Vector of neuron IDs to delete
§Returns

Number of neurons actually deleted

Source

pub fn update_neuron_properties( &mut self, neuron_id: u64, firing_threshold: Option<f32>, leak_coefficient: Option<f32>, resting_potential: Option<f32>, excitability: Option<f32>, ) -> BduResult<()>

Update properties of an existing neuron

§Arguments
  • neuron_id - Target neuron ID
  • firing_threshold - Optional new firing threshold
  • leak_coefficient - Optional new leak coefficient
  • resting_potential - Optional new resting potential
  • excitability - Optional new excitability
§Returns

Ok(()) if neuron updated successfully

Source

pub fn set_neuron_firing_threshold( &mut self, neuron_id: u64, new_threshold: f32, ) -> BduResult<()>

Update the firing threshold of a specific neuron

§Arguments
  • neuron_id - Target neuron ID
  • new_threshold - New firing threshold value
§Returns

Ok(()) if threshold updated successfully

Source

pub fn get_cortical_area_by_name(&self, name: &str) -> Option<CorticalArea>

Get cortical area by name (alternative to ID lookup)

§Arguments
  • name - Human-readable area name
§Returns

Some(CorticalArea) if found, None otherwise

Source

pub fn resize_cortical_area( &mut self, cortical_id: &CorticalID, new_dimensions: CorticalAreaDimensions, ) -> BduResult<()>

Resize a cortical area (changes dimensions, may require neuron reallocation)

§Arguments
  • cortical_id - Target cortical area ID
  • new_dimensions - New dimensions (width, height, depth)
§Returns

Ok(()) if resized successfully

§Note

This does NOT automatically create/delete neurons. It only updates metadata. Caller must handle neuron population separately.

Source

pub fn get_areas_in_region(&self, region_id: &str) -> BduResult<Vec<String>>

Get all cortical areas in a brain region

§Arguments
  • region_id - Brain region ID
§Returns

Vector of cortical area IDs in the region

Source

pub fn update_brain_region( &mut self, region_id: &str, new_name: Option<String>, new_description: Option<String>, ) -> BduResult<()>

Update brain region properties

§Arguments
  • region_id - Target region ID
  • new_name - Optional new name
  • new_description - Optional new description
§Returns

Ok(()) if updated successfully

Source

pub fn update_brain_region_properties( &mut self, region_id: &str, properties: HashMap<String, Value>, ) -> BduResult<()>

Update brain region properties with generic property map

Supports updating any brain region property including coordinates, title, description, etc.

§Arguments
  • region_id - Target region ID
  • properties - Map of property names to new values
§Returns

Ok(()) if updated successfully

Source

pub fn get_neuron_by_coordinates( &self, cortical_id: &CorticalID, x: u32, y: u32, z: u32, ) -> Option<u64>

Get neuron by 3D coordinates within a cortical area

§Arguments
  • cortical_id - Cortical area ID
  • x - X coordinate
  • y - Y coordinate
  • z - Z coordinate
§Returns

Some(neuron_id) if found, None otherwise

Source

pub fn get_neuron_position(&self, neuron_id: u64) -> Option<(u32, u32, u32)>

Get the position (coordinates) of a neuron

§Arguments
  • neuron_id - Neuron ID
§Returns

Some((x, y, z)) if found, None otherwise

Source

pub fn get_cortical_area_for_neuron(&self, neuron_id: u64) -> Option<CorticalID>

Get which cortical area contains a specific neuron

§Arguments
  • neuron_id - Neuron ID
§Returns

Some(cortical_id) if found, None otherwise

Source

pub fn get_neuron_properties( &self, neuron_id: u64, ) -> Option<HashMap<String, Value>>

Get all properties of a neuron

§Arguments
  • neuron_id - Neuron ID
§Returns

Some(properties) if found, None otherwise

Source

pub fn get_neuron_property( &self, neuron_id: u64, property_name: &str, ) -> Option<Value>

Get a specific property of a neuron

§Arguments
  • neuron_id - Neuron ID
  • property_name - Name of the property to retrieve
§Returns

Some(value) if found, None otherwise

Source

pub fn get_all_cortical_ids(&self) -> Vec<CorticalID>

Get all cortical area IDs

§Returns

Vector of all cortical area IDs

Source

pub fn get_all_cortical_indices(&self) -> Vec<u32>

Get all cortical area indices

§Returns

Vector of all cortical area indices

Source

pub fn get_cortical_area_names(&self) -> Vec<String>

Get all cortical area names

§Returns

Vector of all cortical area names

Source

pub fn list_ipu_areas(&self) -> Vec<CorticalID>

List all input (IPU/sensory) cortical areas

§Returns

Vector of IPU/sensory area IDs

Source

pub fn list_opu_areas(&self) -> Vec<CorticalID>

List all output (OPU/motor) cortical areas

§Returns

Vector of OPU/motor area IDs

Source

pub fn get_max_cortical_area_dimensions(&self) -> (usize, usize, usize)

Get maximum dimensions across all cortical areas

§Returns

(max_width, max_height, max_depth)

Source

pub fn get_cortical_area_properties( &self, cortical_id: &CorticalID, ) -> Option<HashMap<String, Value>>

Get all properties of a cortical area as a JSON-serializable map

§Arguments
  • cortical_id - Cortical area ID
§Returns

Some(properties) if found, None otherwise

Source

pub fn get_all_cortical_area_properties(&self) -> Vec<HashMap<String, Value>>

Get properties of all cortical areas

§Returns

Vector of property maps for all areas

Source

pub fn get_all_brain_region_ids(&self) -> Vec<String>

Get all brain region IDs

§Returns

Vector of all brain region IDs

Source

pub fn get_brain_region_names(&self) -> Vec<String>

Get all brain region names

§Returns

Vector of all brain region names

Source

pub fn get_brain_region_properties( &self, region_id: &str, ) -> Option<HashMap<String, Value>>

Get properties of a brain region

§Arguments
  • region_id - Brain region ID
§Returns

Some(properties) if found, None otherwise

Source

pub fn cortical_area_exists(&self, cortical_id: &CorticalID) -> bool

Check if a cortical area exists

§Arguments
  • cortical_id - Cortical area ID to check
§Returns

true if area exists, false otherwise

Source

pub fn brain_region_exists(&self, region_id: &str) -> bool

Check if a brain region exists

§Arguments
  • region_id - Brain region ID to check
§Returns

true if region exists, false otherwise

Source

pub fn get_brain_region_count(&self) -> usize

Get the total number of brain regions

§Returns

Number of brain regions

Source

pub fn get_neurons_by_cortical_area(&self, cortical_id: &CorticalID) -> Vec<u64>

Get neurons by cortical area (alias for get_neurons_in_area for API compatibility)

§Arguments
  • cortical_id - Cortical area ID
§Returns

Vector of neuron IDs in the area

Trait Implementations§

Source§

impl Debug for ConnectomeManager

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

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

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

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

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

Source§

impl<T> WithSubscriber for T

Source§

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

fn with_current_subscriber(self) -> WithDispatch<Self>

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