Skip to content

Repository files navigation

Dual-Process Computational Model

This repository implements a three-layer dual-process computational model of focused-attention meditation. It simulates expert and novice phenotypes across the canonical cycle of breath focus, mind wandering, meta-awareness, and redirect attention, then produces publication figures and saved JSON results for analysis.

The model couples:

  • Layer 1 neural-network dynamics over DMN, VAN, DAN, and FPN
  • Layer 2 latent thoughtseed inference and policy evaluation
  • Layer 3 metacognitive monitoring, habit priors, and meta-awareness

One run per phenotype consists of an 8,000-step fit followed by an independent 4,000-step frozen rollout.

The final 2,000 rollout steps supply Fig. 3-Fig. 5 analyses; Fig. S1 marks the frozen rollout.


Quick Start

Install dependencies:

pip install -r requirements.txt

Run the full pipeline:

python -m run_model run

Generate plots from existing saved results:

python -m run_model plot

This project runs on CPU only; no GPU support is required or used.


Architecture

Meditative Cycle Thoughtseeds Framework

  • Layer 1 is a neural generative process over four large-scale networks (DMN, VAN, DAN, FPN) with four meditation regimes (BF, MW, MA, RA) and multivariate Ornstein-Uhlenbeck dynamics.
  • Layer 2 compresses network dynamics into five thoughtseeds, performs encoder/decoder inference, and evaluates expected free energy over stay/switch policy candidates.
  • Layer 3 computes meta-awareness as gated divergence between policy evidence and habit, then selects the policy posterior that regulates action selection.
  • L1 and L2 interact through a Markov blanket carrying network activity and dwell progress upward, and descending network predictions plus policy-state probabilities downward.
  • L2 and L3 interact through a Markov blanket carrying state belief, policy evidence, and thoughtseed activations upward.

Model Summary

  • States: BF, MW, MA, RA
  • Networks: DMN, VAN, DAN, FPN
  • Thoughtseeds: attend_breath, pain_discomfort, pending_tasks, aha_moment, equanimity

Outputs

Saved Results

Running the full pipeline writes one JSON file per phenotype to data/:

  • training_results_expert_seed100.json
  • training_results_novice_seed100.json

Each file contains the full 12,000-step run:

  • state history
  • network activation history
  • thoughtseed activation history
  • thoughtseed prior activation history
  • free-energy history
  • forward-prediction-error history
  • meta-awareness history
  • raw transition events

Generated Figures

Plots are written to figures/.

Fig. S1: Convergence diagnostics

  • FigS1_Convergence_Expert.pdf
  • FigS1_Convergence_Novice.pdf
  • Fit and frozen-rollout diagnostics

Fig. 3: Expert vs novice comparison

  • fig3a.pdf: state-conditional network activation profiles
  • fig3b.pdf: dwell-time comparisons by state
  • fig3c.pdf: transition probability matrices from the plot window

Fig. 4: Hierarchical dynamics

  • fig4a.pdf: novice hierarchical traces
  • fig4b.pdf: expert hierarchical traces
  • Shows L3 meta-awareness, L2 thoughtseed trajectories, and L1 network dynamics

Fig. 5: State-space geometry

  • fig5.pdf: pooled PCA projections of L2 thoughtseed and L1 network trajectories

Fig. 6: Workspace ignition raster

  • fig6_ignition_raster.pdf: per-phenotype meta-awareness traces with discrete ignition events (onset ticks and ignited spans) from the bistable workspace gate, over the concurrent L1 state sequence

Plot window convention

  • Fig. 3-Fig. 5 and dwell/transition summaries use the final 2,000 frozen-rollout steps.
  • Fig. S1 and Fig. 6 span fit plus rollout; Fig. S1 marks the frozen rollout (steps 8,001-12,000).

Repository Layout

.
+-- run_model.py                   # Main entry point (run | plot)
+-- model/
|   +-- training_loop.py           # Online simulation loop and result packaging
|   +-- phenotype.py               # Expert/novice phenotype definitions
|   +-- substrate.py               # Layer 1 MVOU dynamics
|   +-- thoughtseeds.py            # Layer 2 inference, decoder, forward model, policy scoring
|   +-- policy.py                  # Layer 3 policy selection and habit learning
|   +-- workspace.py               # Layer 3 workspace ignition dynamics
|   +-- duration.py                # Regime-duration support and hazard
|   +-- markov_blankets.py         # Markov blanket interfaces
+-- utils/
|   +-- config/                    # Core constants, profiles, and phenotype tables
|   +-- math_utils.py              # Shared tensor/math helpers
+-- viz/
|   +-- analysis_utils.py          # Tail-window statistics and aggregation
|   +-- convergence.py             # Fig. S1
|   +-- radar_plot.py              # Fig. 3A
|   +-- hierarchy.py               # Fig. 4
|   +-- attractors.py              # Fig. 5
|   +-- plotting_utils.py          # Shared plotting style/helpers
+-- data/                          # Saved run outputs
+-- figures/                       # Generated and manuscript figure assets
+-- tests/
    +-- test_invariants.py         # Core invariants and numerical checks

Configuration

Edit config/defaults.py and config/profiles.py to modify:

  • network/state parameters (THETA_BASE, network attractors)
  • thoughtseed priors (THOUGHTSEED_STATE_PRIORS)
  • Gamma dwell means and shared variability (DWELL_MEAN_SECONDS, DWELL_CV)
  • transition priors (STATE_TRANSITION_PROBS)
  • learning rates (LEARNING_RATES)
  • numerical settings such as NOISE_LEVEL, LATENT_TAU, TRAIN_STEPS, EVALUATION_STEPS, and PLOT_STEPS

Reproducibility

The default seed is fixed at 100.

  • torch.manual_seed and np.random.seed are set in the trainer
  • Layer 1 uses its own seeded RandomState
  • stochastic transitions and process noise are therefore reproducible under the same configuration and dependency environment

This repository builds on earlier Thoughtseeds-related codebases, including:

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages