← ~/projects/

RBC-Aggregation-Analysis

github.com/AbdallahAbou/RBC-Aggregation-Analysis
Rust nalgebra Rayon Scientific Computing Biophysics
High-performance analysis toolkit for red blood cell aggregation from confocal microscopy data. Computes morphological descriptors, spatial statistics, and aggregation metrics from 3D mesh data.
Pipeline
┌──────────────┐    ┌──────────────┐    ┌──────────────┐    ┌──────────────┐
│    TIFF      │───▶│  ML Segm.    │───▶│     OBJ      │───▶│   Spatial    │
│    Stack     │    │  (ilastik)   │    │    Meshes    │    │   Analysis   │
└──────────────┘    └──────────────┘    └──────────────┘    └──────────────┘
       │                                       │                    │
       ▼                                       ▼                    ▼
┌──────────────┐                        ┌──────────────┐    ┌──────────────┐
│  Intensity   │                        │   Inertia    │    │     g(r)     │
│   Profile    │                        │    Tensor    │    │   Function   │
└──────────────┘                        └──────────────┘    └──────────────┘
Shape Classification via Inertia Tensor
RBC morphology encoded in eigenvalues (λ₁ ≥ λ₂ ≥ λ₃) of the gyration tensor:
                        SHAPE SPACE
                        
       λ₁/λ₂  ▲
              │   Elliptocyte ·
              │        ·    ·      Stomatocyte
              │   ·         ·           ·
              │      Discocyte (healthy)
              │   ·              ·
              │                Spherocyte ·
              └──────────────────────────────▶ λ₂/λ₃

       Asphericity   = λ₁ - ½(λ₂ + λ₃)  → sphere deviation
       Acylindricity = λ₂ - λ₃          → cylinder deviation
Pair Correlation Function g(r)
         g(r)
          ▲
          │     ╭─╮
          │    ╱   ╲    ← Aggregation peak
        1 │───╱─────╲────────────────
          │  ╱       ╲_______________
          └──────────────────────────▶ r
                 │
                 └── Contact distance (~8μm)

       g(r) = 1 → random distribution
       g(r) > 1 → clustering / aggregation
       g(r) < 1 → repulsion / ordering
Why Rust?
ConcernSolution
Large meshes (100K+ vertices)Zero-copy parsing, stack allocation
Batch processing (1000s cells)Rayon parallel iterators
Numerical stabilitynalgebra with proper epsilon handling
Memory safetyBorrow checker prevents data races
Application: Quantifying RBC aggregation is clinically relevant — abnormal rouleaux formation indicates inflammatory states, plasma protein abnormalities, or hematological disorders. This toolkit enables automated, reproducible analysis of 3D confocal data.
Key Modules
src/
├── mesh/
│   ├── parser.rs      # OBJ/PLY parsing with streaming
│   └── geometry.rs    # Volume, surface area, centroid
├── analysis/
│   ├── inertia.rs     # Gyration tensor, eigendecomposition
│   ├── shape.rs       # Asphericity, acylindricity metrics
│   └── spatial.rs     # Pair correlation g(r), RDF
├── stats/
│   └── aggregation.rs # Cluster detection, aggregation index
└── io/
    └── export.rs      # CSV, JSON output formats