---
name: zubyul-connectome-head-6a6a1d667819
description: Human Connectome Project analysis bridging cortical thickness, transcription factors, and depression biomarkers. Connects zubyul's Nikolova lab neuroscience to geomstats manifold geometry, Vertex AI protein expression, and the propagator lattice.
---

# zubyul-connectome Skill

> *Cortical manifolds as propagator cells in the brain's CellValue lattice*

## Origin: zubyul/Nikolova_lab_data_analysis

Yuliya Zubak's undergraduate thesis: "Using Human Connectome Project data to
study the relationship of cortical thickness to transcription factors for
depression." R-based analysis of HCP structural MRI data.

## What's Possible

### 1. geomstats: Cortical Manifold Geometry
=======
description: Human Connectome Project analysis bridging cortical thickness, transcription factors, and depression biomarkers. Load when working with HCP structural MRI data, cortical manifold geometry via geomstats, or Bayesian models of brain-gene relationships.
---

# zubyul-connectome

## Origin

Yuliya Zubak's undergraduate thesis: "Using Human Connectome Project data to study the relationship of cortical thickness to transcription factors for depression." R-based analysis of HCP structural MRI data. Repo: `zubyul/Nikolova_lab_data_analysis`.

## geomstats: Cortical Manifold Geometry

>>>>>>> origin/main
- Cortical surface = Riemannian manifold (genus-0 closed surface)
- Cortical thickness at each vertex = scalar field on the manifold
- Fisher-Rao metric on the statistical manifold of thickness distributions
- Geodesic regression: thickness ~ age + depression_score on SPD manifold
- geomstats `Hypersphere` / `SPDMatrices` for covariance analysis

<<<<<<< HEAD
### 2. monad-bayes: Hierarchical Bayesian Model
=======
## Hierarchical Bayesian Model

>>>>>>> origin/main
```haskell
-- Hierarchical model: cortical thickness ~ transcription + depression
corticalModel :: MonadMeasure m => HCPData -> m Parameters
corticalModel hcp = do
<<<<<<< HEAD
  -- Population-level priors
=======
>>>>>>> origin/main
  mu_thickness <- normal 2.5 0.5       -- mean cortical thickness (mm)
  sigma_region <- halfNormal 0.3        -- between-region variance
  beta_transcription <- normal 0 1      -- transcription factor effect
  beta_depression <- normal 0 0.5       -- depression effect size

<<<<<<< HEAD
  -- Region-level: each Desikan-Killiany parcel
=======
>>>>>>> origin/main
  forM_ (regions hcp) $ \region -> do
    offset <- normal 0 sigma_region
    let predicted = mu_thickness + offset
                  + beta_transcription * transcriptionLevel region
                  + beta_depression * depressionScore region
    factor $ normalDensity predicted 0.2 (observedThickness region)

  return (mu_thickness, beta_transcription, beta_depression)
```

<<<<<<< HEAD
### 3. Propagator Lattice Connection
=======
## Propagator Lattice Connection

>>>>>>> origin/main
The CellValue lattice from zig-syrup/propagator.zig maps to brain states:
- `Nothing` = unmeasured cortical region (no MRI data)
- `Value` = observed thickness measurement
- `Contradiction` = conflicting measurements across sessions

<<<<<<< HEAD
Each Desikan-Killiany parcel is a `Cell`; MRI preprocessing steps are
`Propagator`s that merge partial observations via `latticeMerge`.

AGM belief revision (continuation.zig):
- `expand` = add new parcels from additional MRI acquisitions
- `contract` = remove artifact-contaminated regions
- `revise` = Levi identity update when depression status changes

### 4. Vertex AI Protein Expression Bridge
- Transcription factors -> protein expression -> cortical development
- ESMFold: predict structure of depression-associated transcription factors
- AlphaFold batch: multi-protein complexes at cortical synapses
- GameOpt (Bal et al. 2024): optimize protein-cortex interaction network
  as combinatorial game on residue positions

### 5. EyeGestures Integration
- Gaze tracking (zubyul/EyeGestures) + cortical oculomotor regions
- Frontal eye field (FEF) thickness correlates with saccade patterns
- monad-bayes Kalman filter on gaze stream, informed by cortical priors
- Gay.jl SPI color at gaze fixation point = neurofeedback signal

### 6. GF(3) Trit Classification
| Component | Trit | Role |
|-----------|------|------|
| HCP MRI data | +1 | Generation (observation) |
| geomstats manifold | 0 | Coordination (geometry) |
| monad-bayes posterior | -1 | Validation (inference) |

Conservation: +1 + 0 + (-1) = 0

## Edges in Interactome TUI
- -> monad-bayes (w=0.75, hierarchical Bayesian)
- -> geomstats (w=0.85, cortical manifold geometry)
- -> Vertex AI Protein (w=0.70, transcription factor folding)
- -> zubyul/WGCNA (w=0.90, gene-brain network bridge)
- -> zubyul/EyeGestures (w=0.60, gaze + cortical oculomotor)
- -> zig-syrup/propagator (w=0.65, CellValue lattice for brain parcels)

## Trit: 0 (ERGODIC - bridges neuroscience to interactome)
=======
Each Desikan-Killiany parcel is a `Cell`; MRI preprocessing steps are `Propagator`s that merge partial observations via `latticeMerge`.

## Vertex AI Protein Expression Bridge

- Transcription factors -> protein expression -> cortical development
- ESMFold: predict structure of depression-associated transcription factors
- AlphaFold batch: multi-protein complexes at cortical synapses

## EyeGestures Integration

- Gaze tracking (zubyul/EyeGestures) + cortical oculomotor regions
- Frontal eye field (FEF) thickness correlates with saccade patterns

## Concrete Affordances

### Clone the Upstream Repository

```bash
git clone https://github.com/zubyul/Nikolova_lab_data_analysis.git /Users/alice/v/zubyul-nikolova-lab
```

### HCP Data Access

- **ConnectomeDB portal**: https://db.humanconnectome.org/ (requires registration + data use agreement)
- **S3 bucket** (open access subset): `s3://hcp-openaccess/HCP_1200/` (use `aws s3 ls --no-sign-request`)
- **Local convention**: download structural MRI to `/Users/alice/v/data/hcp/` with subject directories like `100307/T1w/`

```bash
# List available subjects in the open-access HCP 1200 release
aws s3 ls s3://hcp-openaccess/HCP_1200/ --no-sign-request | head -20

# Download a single subject's FreeSurfer output (cortical thickness)
aws s3 cp s3://hcp-openaccess/HCP_1200/100307/T1w/100307/surf/ \
  /Users/alice/v/data/hcp/100307/surf/ \
  --recursive --no-sign-request
```

### Geodesic Regression on Cortical Thickness (geomstats)

Fit a geodesic regression model on the SPD manifold relating cortical thickness covariances to depression scores:

```python
# pip install geomstats numpy
import numpy as np
import geomstats.backend as gs
from geomstats.geometry.spd_matrices import SPDMatrices
from geomstats.learning.geodesic_regression import GeodesicRegression

gs.random.seed(42)

# SPD(3) manifold — e.g., 3x3 covariance of thickness across 3 ROIs
spd = SPDMatrices(n=3, equip=True)

# Simulated data: N subjects, each with a 3x3 thickness covariance and a depression score
N = 30
depression_scores = np.linspace(0, 1, N).reshape(-1, 1)  # predictor (scalar)

# Generate synthetic SPD points along a geodesic + noise
base_point = spd.random_point()
tangent_vec = spd.random_tangent_vec(base_point) * 0.5
y_true = np.array([
    spd.metric.exp(t * tangent_vec, base_point)
    for t in depression_scores.flatten()
])
# Add small SPD noise
noise = np.array([spd.random_tangent_vec(y) * 0.05 for y in y_true])
y_noisy = np.array([spd.metric.exp(n, y) for n, y in zip(noise, y_true)])

# Fit geodesic regression: thickness_cov ~ depression_score
gr = GeodesicRegression(
    spd,
    center_X=False,
    method="riemannian",
    initialization="frechet",
)
gr.fit(depression_scores, y_noisy)

# Predict thickness covariance for a new depression score
new_score = np.array([[0.75]])
predicted_cov = gr.predict(new_score)
print(f"Predicted thickness covariance at depression=0.75:\n{predicted_cov[0]}")
print(f"R² (manifold): {gr.score(depression_scores, y_noisy):.4f}")
```

### FreeSurfer Cortical Thickness Extraction

Extract Desikan-Killiany parcellation stats from FreeSurfer output:

```bash
# After running FreeSurfer recon-all on HCP data
export SUBJECTS_DIR=/Users/alice/v/data/hcp

# Extract cortical thickness per parcel (Desikan-Killiany atlas)
aparcstats2table --subjects 100307 100408 101107 \
  --hemi lh \
  --meas thickness \
  --tablefile /tmp/lh_thickness.tsv

# Quick look at the output
column -t -s $'\t' /tmp/lh_thickness.tsv | head -5
```

## Edges

- -> monad-bayes (hierarchical Bayesian)
- -> geomstats (cortical manifold geometry)
- -> Vertex AI Protein (transcription factor folding)
- -> zubyul/WGCNA (gene-brain network bridge)
- -> zubyul/EyeGestures (gaze + cortical oculomotor)
- -> zig-syrup/propagator (CellValue lattice for brain parcels)
>>>>>>> origin/main


---
Source attribution: plurigrid
Original project: https://github.com/plurigrid/asi/blob/293ce9f76e3abcd5ba18db284688bc0d9ac6691d/skills/zubyul-connectome/SKILL.md
License: MIT
License information: https://opensource.org/license/mit
Original upstream instructions; downloaded from Mega AI Hub.

## Upstream license notice

MIT License

Copyright (c) 2025 SkillCreator.ai

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.



# Mega AI Hub resource metadata

Creator / publisher: plurigrid
Original project: https://github.com/plurigrid/asi/blob/293ce9f76e3abcd5ba18db284688bc0d9ac6691d/skills/zubyul-connectome/SKILL.md
Attribution basis: Source repository record

Fields of work: Data & Analytics, Design, Development & Engineering, Education & Research, Healthcare & Life Sciences
Roles: Clinical Research, Data Scientist, ML / AI Engineer, Researcher, UX Designer
Specialties: Backend, Frontend, Git
Tools: Geomstats, Monad Bayes, Vertex Ai, Zig Syrup
Country applicability: Country not specified
Classification basis: Source catalog labels
Instruction SHA-256: fea1471e41a0331bc6df29df6555e6f943e06ce58b056bc2e0dc8b7a98eff335
