Files
ruvnet--RuView/v2/crates/ruv-neural/ruv-neural-core/src/brain.rs
T
rUv f49c722764 chore(repo): rename rust-port/wifi-densepose-rs → v2/ (flatten to one level) (#427)
The Rust port lived two directories deep (rust-port/wifi-densepose-rs/)
without any sibling under rust-port/ that warranted the extra level.
Move the whole workspace up to v2/ to match v1/ (Python) at the same
depth and shorten every cd / build command across the repo.

git mv preserves history for all tracked files. 60 files updated for
path references (CI workflows, ADRs, docs, scripts, READMEs, internal
.claude-flow state). Two manual fixes for relative-cd paths in
CLAUDE.md and ADR-043 that became wrong after the depth change
(cd ../.. → cd ..).

Validated:
- cargo check --workspace --no-default-features → clean (after target/
  nuke; the gitignored target/ was carried by the OS rename and had
  hard-coded old paths in build scripts)
- cargo test --workspace --no-default-features → 1,539 passed, 0 failed,
  8 ignored (same totals as pre-rename)
- ESP32-S3 on COM7 → still streaming live CSI (cb #40300, RSSI -64 dBm)

After-merge follow-up: contributors should `rm -rf v2/target` once and
let cargo regenerate from the new path.
2026-04-25 21:28:13 -04:00

104 lines
2.7 KiB
Rust

//! Brain region and atlas types for parcellation.
use serde::{Deserialize, Serialize};
/// Brain atlas defining a parcellation scheme.
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum Atlas {
/// Desikan-Killiany atlas (68 cortical regions).
DesikanKilliany68,
/// Destrieux atlas (148 cortical regions).
Destrieux148,
/// Schaefer 100-parcel atlas.
Schaefer100,
/// Schaefer 200-parcel atlas.
Schaefer200,
/// Schaefer 400-parcel atlas.
Schaefer400,
/// Custom atlas with a specified number of regions.
Custom(usize),
}
impl Atlas {
/// Number of regions in this atlas.
pub fn num_regions(&self) -> usize {
match self {
Atlas::DesikanKilliany68 => 68,
Atlas::Destrieux148 => 148,
Atlas::Schaefer100 => 100,
Atlas::Schaefer200 => 200,
Atlas::Schaefer400 => 400,
Atlas::Custom(n) => *n,
}
}
}
/// Cerebral hemisphere.
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum Hemisphere {
Left,
Right,
Midline,
}
/// Brain lobe classification.
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum Lobe {
Frontal,
Parietal,
Temporal,
Occipital,
Limbic,
Subcortical,
Cerebellar,
}
/// A single brain region (parcel) within an atlas.
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct BrainRegion {
/// Region index within the atlas.
pub id: usize,
/// Human-readable name (e.g., "superiorfrontal").
pub name: String,
/// Hemisphere.
pub hemisphere: Hemisphere,
/// Lobe classification.
pub lobe: Lobe,
/// Centroid in MNI coordinates (x, y, z in mm).
pub centroid: [f64; 3],
}
/// A full brain parcellation (atlas + all regions).
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Parcellation {
/// Atlas used.
pub atlas: Atlas,
/// All regions in the parcellation.
pub regions: Vec<BrainRegion>,
}
impl Parcellation {
/// Number of regions.
pub fn num_regions(&self) -> usize {
self.regions.len()
}
/// Get a region by its id.
pub fn get_region(&self, id: usize) -> Option<&BrainRegion> {
self.regions.iter().find(|r| r.id == id)
}
/// Get all regions in a given hemisphere.
pub fn regions_in_hemisphere(&self, hemisphere: Hemisphere) -> Vec<&BrainRegion> {
self.regions
.iter()
.filter(|r| r.hemisphere == hemisphere)
.collect()
}
/// Get all regions in a given lobe.
pub fn regions_in_lobe(&self, lobe: Lobe) -> Vec<&BrainRegion> {
self.regions.iter().filter(|r| r.lobe == lobe).collect()
}
}