Nima Fatemi
All work

NC State UniversityConcept developed during my Ph.D.

Emotion-Adaptive Virtual Environments

A closed-loop system that adapts AI-generated indoor imagery to EEG-derived affective state in real time.

Role
Concept, system design and evaluation design
Since
2023
AI-generated bedroom interior changing as the system adjusts its visual parameters
On this page
  1. Snapshot
  2. The stimulus bottleneck
  3. Closed-loop neuroarchitecture
  4. Research question
  5. System overview
  6. The calm-focus zone
  7. The Design Dictionary
  8. EEG pipeline and its pitfalls
  9. Generative pipeline and control logic
  10. Fast loop, slow affect
  11. Evaluation design
  12. Staged validation and contingencies
  13. Direct product applications

Snapshot

Problem

Indoor affect research depends on finite, slow-to-produce stimuli. Static stimuli ignore individual state and affect regulation. The same environment affects people differently.

Idea

Make the environment the feedback display. A closed loop senses state from EEG, infers valence and arousal, and adapts AI-generated indoor imagery toward a calm-focus zone in real time.

Question

Can a closed-loop biosignal-driven system that adapts indoor environmental imagery in real time improve affective regulation relative to static and non-adaptive scripted exposure, without degrading task performance?

Status

A concept I developed during my Ph.D. The concept has been tested. This page describes the system design and the design of a full evaluation.

Problem

The stimulus bottleneck

Indoor affect research depends on finite, slow-to-produce stimuli.

Context

85 to 90 percent of waking life is spent indoors. The built environment shapes cognition, affect, and health.

Control vs. realism tradeoff

Every existing stimulus method sacrifices one dimension for the other, limiting the scope of valid inference.

Variable isolation breaks

Confounds make causal claims impossible. Changing one environmental parameter with existing tools inevitably shifts others.

No responsiveness or personalization

Static stimuli ignore individual state and affect regulation. The same environment affects people differently.

The idea

Closed-loop neuroarchitecture

Two traditions study environment and affect. Neither closes the loop with the environment itself.

Neuroarchitecture

Environment to brain. Mostly open-loop.

  • Indoor spatial variables: lighting, geometry, materials, biophilic cues
  • Stress, restoration, and attentional effects under controlled exposure
  • Photos, VR, and mobile EEG paradigms

The environment does not respond to state.

Affective neurofeedback and biocybernetic loops

Brain to system. Closed-loop, but feedback is abstract.

  • Physiological contingency: feedback responds to the participant in real time
  • Timing precision and stability constraints baked into the architecture
  • Validated in clinical, BCI, and adaptive-automation contexts

The feedback has no environmental meaning.

Closed-loop adaptive environment A cycle of four steps: sense with EEG, infer valence and arousal, compare the state to a calm-focus target, and actuate the environment. The loop closes through the participant. through theparticipant SenseEEG Infer statevalence / arousal Compare to targetcalm-focus zone Actuateenvironment valencearousal
Make the environment the feedback display.The participant is one of the elements in the loop. The environment changes, the participant's state changes, the EEG changes, and the loop continues.

Reframing evidence-based design

From offline parameter optimization to real-time environmental regulation.

The old paradigm

Environmental parameters are chosen offline. Studies inform a design specification. The environment is then built and frozen. Adaptation, if it happens at all, happens between studies, not within them.

The new paradigm

Environmental parameters are selected, adjusted, and delivered in real time, in response to measured state. The environment becomes a regulatory agent inside a feedback loop, not a manipulated variable held constant.

  1. Prior researchPublished evidence base
  2. Designer specifiesParameters chosen up front
  3. Environment built and frozenStatic configuration
  4. Occupants experienceNo mid-course adjustment

The old paradigm as a pipeline. The contribution is not a new finding about which environments matter. It is a new relationship between evidence, environment, and the participant.

Scope

Research question

Primary research questionCan a closed-loop biosignal-driven system that adapts indoor environmental imagery in real time improve affective regulation relative to static and non-adaptive scripted exposure, without degrading task performance?

SQ1

System feasibility and stability

Can the sensing, inference and generation loop operate stably enough for real-time adaptation within experimental constraints?

Loop latency, signal quality, system uptime

SQ2

Affective impact of adaptive imagery

Does adaptive imagery produce greater movement toward the calm-focus state than static imagery?

Time-in-zone, time-to-target vs Static

SQ3

Comparative advantage over scripted

Does closed-loop adaptive imagery outperform non-adaptive scripted imagery in regulating affect?

Adaptive vs Scripted (contingency isolated)

SQ4

Task performance preservation

Does the affective regulation occur without meaningful cost to task performance or workload?

Vigilance d′, RT, NASA-TLX, SAM

The concept is scoped to demonstrate feasibility and comparative advantage. It does not aim to map every architectural variable to an emotional outcome, and it does not claim full ecological realism.

CEAIL

System overview

A three-node closed loop: EEG sensing, affective inference, generative actuation. The nodes are separate processes synchronized by Lab Streaming Layer (LSL).

  1. Sense: acquisition nodeEEG streaming at 500 Hz, 32-channel research EEG, Python LSL outlet
  2. Infer and compare: processing nodeArtifact rejection (ASR), FAA and beta/alpha extraction, Schmitt trigger with hysteresis, publishes the control signal
  3. Actuate: generation nodeStable Diffusion with ControlNet, LCM-LoRA at about 200 ms inference, cross-fade to display
  • < 500 ms target loop latency
  • 500 Hz EEG acquisition, time-stamped through LSL
  • About 200 ms image inference on a local GPU

LSL tags every sample with a unified network timestamp. Without this, you cannot prove that a measured state change was caused by a specific imagery update.

What is borrowed, what is new

The novelty lives in the integration, the translation layer, and the experimental test. Not in any single component.

EEG signal lane

  • ExistingRaw EEG500 Hz, 32 channels
  • ExistingPreprocessingASR, 1–50 Hz, IAF normalization
  • ExistingFeature extractionFAA and β/α
  • NewState estimator5–10 s smoothing, Euclidean distance

Core

  • NewControl logicSchmitt trigger, hysteresis, deadband
  • NewDesign DictionaryThe translation layer
  • NewPrompt and parametersStructured text, ControlNet conditioning

AI generation lane

  • ExistingStable Diffusion coreLCM-LoRA, about 200 ms inference
  • ExistingControlNet conditioningDepth map and Canny, geometry locked
  • NewOutput frameCross-fade to display

Participant side

  • ExistingEEG cap, 32 channels
  • ExistingVigilance taskRare-target detection
  • ExistingSelf-reportSAM, NASA-TLX
  • NewUpdated indoor imagery

Adaptive imagery in action

A demonstration of parameter-driven adaptation. The system adjusts visual features such as color temperature, lighting, indoor plants, and spatial clutter in response to shifting emotional state targets, creating a dynamic, responsive environment.

State model

The calm-focus zone

The target is a region in valence and arousal space, not a point. Affective control needs a tolerance band.

-2-10+1+2-2-1+1+2 Stressed / hyper-aroused Alert / excited Anxious / withdrawn Disengaged / under-aroused Calm-focustarget zone t = 0t + 1 mint + 4 mint + 8 min Valence (FAA)Arousal (β/α)
Illustrative trajectory after a stressor, not data. Standardized window z ∈ [+0.2, +0.5] for both dimensions (example).

Valence proxy

Frontal alpha asymmetry (FAA): relative left vs. right alpha power at prefrontal electrodes. Positive FAA indicates left-frontal dominance and approach-related affect.

FAA = ln(α_right) − ln(α_left) at F4 minus F3

Arousal proxy

Beta-over-alpha ratio: elevated beta relative to alpha indicates heightened arousal. A depressed ratio indicates under-engagement.

β/α = P(β-band) / P(α-band)

Why a region, not a point

The calm-focus zone is where task engagement is stable. The controller uses error-to-zone, not error-to-setpoint. The dual metric prevents confusing calm with boredom.

Calm-focus sits at the peak, not the trough

Operationally bounded moderate engagement. CEAIL restrains the ceiling, it does not lift the floor.

Calm-focus zone Stressorinduction CEAILadaptation Inattentive /non-alertDistractible /stressed LowHigh Arousal / activation Performance (d′)
Vigilance is stressful, and the stressor before each block raises arousal further. The risk the system manages is over-activation, not under-activation.

Phasic LC mode = peak

Moderate tonic norepinephrine plus sharp phasic bursts to task-relevant events. High signal detection sensitivity.

Aston-Jones & Cohen 2005 · Arnsten 2009

d′ peaks at intermediate arousal

Across 28 participants and 6 tasks, an inverted-U fit beats linear by ΔAIC = 31.0, ΔBIC = 26.7.

Beerendonk et al. 2024

Vigilance is stressful

Sustained monitoring elevates urinary catecholamines and NASA-TLX. Over-activation is the live risk.

Warm, Parasuraman, Matthews 2008

Operationally, calm-focus is a bounded middle zone, evaluated on four convergent indicators: β/α within baseline ± 0.5 SD; FAA at or above baseline; d′ maintained or improving; subjective arousal not in the stress range.

Translation layer

The Design Dictionary

A three-layer evidence infrastructure, from neuroarchitecture papers to a queryable database the live system consumes. It translates biosignal-derived state estimates into structured prompts and image-conditioning parameters for the generative AI.

  1. Layer 1: primary literature60+ papers coded
  2. Layer 2: evidence unitsNine coded dimensions per unit, controlled vocabulary throughout
  3. Layer 3: QC and normalizationControlled vocabulary, QC_FLAGS filter, auditable provenance
  4. Output: queryable DictionaryProbabilistic parameter-affect mappings, live input to the generative pipeline

Probabilistic, not deterministic

Each parameter-affect mapping carries an evidence weight. The system uses weighted probabilities to guide adaptation, not hard rules. Individual variability is treated as information, not noise.

Bounded scope

Parameter families with mechanistic evidence linking environmental manipulations to valence or arousal, for indoor visual environments represented as images.

Lighting Color Spatial configuration Clutter and order Material naturalness Biophilic cues

Dual function

Inside CEAIL, it is the translation layer between state estimates and generative AI prompts. Outside CEAIL, it is a standalone methodological artifact: an evidence-synthesis database the field can reuse.

Three named limitations

Literature dependency

The Dictionary synthesizes what the field has studied, not what necessarily matters most for architectural affect. The evidence base is biased toward experimentally convenient parameters.

Cultural and individual specificity

Design-affect mappings are encoded predominantly from Western laboratory samples. The probabilistic weights should not be read as cross-culturally stable or individually deterministic.

Researcher discretion in coding

Translating a published finding into a normalized evidence unit requires interpretive judgments. The QC_FLAG layer surfaces these uncertainties explicitly but does not eliminate them.

Out of scope: multisensory experience, embodied spatial behavior, auditory and olfactory modalities. Generative models may also reflect demographic and cultural biases. Mitigation: constrained prompts, seed validation, manual diversity review.

Sensing

EEG pipeline and its pitfalls

Raw scalp signal to two state proxies: valence via FAA, arousal via β/α.

  1. Acquisition32-channel EEG, 500 Hz
  2. PreprocessingASR or threshold artifact rejection, 1–50 Hz bandpass, IAF normalization per session
  3. Two proxiesFAA for valence, β/α for arousal
  4. Smoothing5–10 s window, 1 s overlap
  5. State vector(FAA, β/α) in valence and arousal space

Why IAF normalization

Individual alpha frequency varies meaningfully across people. A fixed 8–13 Hz band misreads slow-alpha and fast-alpha participants. Each session opens with a calibration window that locates the participant's alpha peak.

Klimesch 1999

Why a 5-to-10-second window

Single-epoch fluctuations are not affective state changes. The smoothing window enforces the requirement that the system respond to sustained shifts, not transient artifacts.

Six pitfalls, six mitigations

EEG is the right instrument for a real-time affective loop. It is also high-dimensional, non-stationary, and indirect.

Occipital alpha contaminates frontal sites

Continuous viewing of dynamic imagery generates large posterior alpha that spreads onto frontal electrodes via volume conduction.

Smith et al. 2017
Mitigation

CSD re-referencing. Current source density transformation via surface Laplacian attenuates volume conduction.

Artifacts amplified under emotional engagement

Facial muscle activity and blinks overlap spectrally with frontal alpha.

Smith et al. 2017
Mitigation

ICA + MARA, calibrated. ICA-based artifact correction with calibrated aggressive-versus-lenient tradeoffs.

Cross-frequency ratios are interpretively fragile

Beta-over-alpha is broadband-susceptible to myogenic contamination and IAF variability.

Klimesch 1999
Mitigation

IAF normalization at baseline. A per-session calibration window locates the alpha peak. Smoothing and hysteresis bound myogenic risk.

FAA was not built for moderate states

The approach-withdrawal framework may look different for sustained calm-focus than for resting states.

Davidson 1998
Mitigation

Trajectory analysis, not endpoint. Time-in-zone captures evolution over the regulation phase.

Single-session baseline is a noisy anchor

Test-retest ICCs range from 0.53 to 0.72. Half of individual variance is day-to-day noise.

Tomarken et al. 1992
Mitigation

Within-subjects design. Counterbalancing prevents day-to-day baseline shifts from masquerading as condition effects.

Not every participant regulates

Non-regulator proportions range from 16 to 57%.

Alkoby 2018
Mitigation

Asymmetric disadvantage logged. Poor EEG generators contribute noise to adaptive conditions. Named and treated as a known limitation.

Actuation

Generative pipeline and control logic

Parametric decoupling holds geometry constant. Hysteresis prevents the environment from chasing noise.

  1. Control signalFrom the Schmitt trigger controller
  2. Design Dictionary translatorMaps state to prompt tokens and parameter deltas
  3. Stable Diffusion coreLCM-LoRA
  4. ControlNet conditioningDepth map and Canny edges
  5. Output frameCross-fade to display

Locked

Room layout, perspective, major furniture positions.

Variable

Lighting warmth (CCT), texture and material cues, clutter density.

Why geometry must be locked

If every adaptation changed the room itself, the experiment would confound parameter manipulation with scene identity. ControlNet conditioning on depth and edge maps keeps walls, perspective, and major furniture constant.

Why naive thresholds fail

Physiology fluctuates around its mean. A single threshold causes oscillation and visual flicker. The system needs separate entry and exit thresholds, plus a deadband, and a sustained-crossing requirement.

Stability as a design requirement

Schmitt trigger logic implements thermostat-like behavior, holding state and acting only on sustained deviation.

00.30.50.71 Deadband Active (actuate) Inactive (hold) Deviation from target zone (normalized)
Schmitt trigger hysteresis modelActuation triggers if deviation exceeds 0.7 for at least 3 s. It ceases if deviation falls below 0.3 for at least 3 s. Analogous to a thermostat: it prevents the system from flickering at the boundary.

Scope

Fast loop, slow affect

The system operates in milliseconds. The phenomena it engages move in minutes, hours, and years. The asymmetry is a methodological opportunity, not a defect.

  1. 2 msEEG sampleraw acquisition at 500 Hz
  2. about 200 msImage generationsingle-step latency
  3. under 500 msLoop targethard upper bound
  4. 5 to 10 sSmoothingsustained shift
  5. minutesModulationthe scoped target
  6. Scope boundary
  7. tens of minutesVigilance dropTeichner 1974
  8. hoursMood shiftsout of scope
  9. a dayCircadian affectout of scope
  10. yearsPlace attachmentout of scope

Approximate positions on a logarithmic scale.

The honest scope limit

The concept claims short-term, within-session modulation only. It does not claim lasting emotional change, place attachment, or longitudinal architectural experience.

Why the asymmetry becomes useful

Because the loop runs continuously and logs EEG state and image updates at high temporal resolution, a study can construct trajectory-level metrics that endpoint paradigms cannot access. Speed is not the goal. Speed creates the resolution that makes the slow processes measurable.

Time-to-target Time-in-zone target zone Time within the regulation phase
Trajectory metrics enabled by the fast loopEndpoint paradigms cannot observe these. Schematic, not data.

Full evaluation

Evaluation design

A within-subjects, counterbalanced comparison of three conditions, designed for 40 participants. It compares contingency against non-contingent change and against static exposure.

A · Adaptive

EEG-contingent updates that target the calm-focus zone.

Isolates: contingency

B · Scripted (active control)

A predefined sequence, not contingent on EEG.

Isolates: visual change without contingency

C · Static (baseline)

A single fixed image with no updates.

Isolates: exposure only

Inside one 15-minute block

Stressor3 minStroop or paced arithmetic, counterbalanced
Regulation phase12 minVigilance task plus the condition's imagery
Self-reportabout 2 minNASA-TLX and SAM

The vigilance task runs only during the regulation phase. The stressor establishes a consistent arousal ceiling at block onset.

Outcomes

Primary · confirmatory

Behavioral sensitivity

d′ = z(H) − z(FA)

Perceptual sensitivity on a successive-discrimination vigilance task with a 10–20% target rate. The criterion c separates a sensitivity gain from a shift in response strategy.

Process · mechanism

EEG-derived trajectory

Time-in-zone, time-to-target, and biocybernetic efficacy: the coupling between system output and observed state shifts.

Subjective · validation

Self-report convergence

SAM for valence and arousal, NASA-TLX for workload. Convergence with the EEG trajectory supports interpretation. Divergence triggers re-examination.

Outcome ~ Condition × Time + (1 | Participant)

A linear mixed-effects model estimated separately for each outcome, with pairwise contrasts between the three conditions, Bonferroni-corrected.

Quality

Staged validation and contingencies

Five stages, each with a gate. Each stage delivers its output with its uncertainty attached.

  1. 1 · Literature codingPre-specified inclusion criteria, blind double-coding on about 20% of the set
  2. 2 · Prompt libraryExpert review, seed validation, bias audit
  3. 3 · Closed loopSynthetic-signal test suite, latency under full load
  4. 4 · PilotFunctional validation with pre-specified stopping rules
  5. 5 · Main studyPre-registered hypotheses and analysis

If the loop does not hold up

Three pre-specified tiers. The Design Dictionary is preserved at every tier.

Tier 1

Methodological adjustment

Swap the measurement modality or reconfigure processing parameters. The research question and design are preserved.

Tier 2

Design pivot

Decouple the adaptive intervention from the real-time EEG requirement. Compare static, scripted, and adaptive imagery without the sub-500 ms latency constraint.

Tier 3

Paradigm shift

If closed-loop adaptation fails entirely, the Design Dictionary becomes the primary contribution, published as an open, queryable resource.

Beyond the lab

Direct product applications

Adaptive AI & Agentic Systems

Enables AI assistants to adjust their tone, pace, or visual presentation when they detect user frustration or cognitive overload, building trust through responsiveness.

Digital Wellbeing & Productivity

Informs the development of tools that actively help users regulate focus and stress through contextual interface shifts, not just usage timers.

Dynamic User Interfaces

Provides a blueprint for interfaces that adjust layout, information density, and contrast based on real-time user state, moving beyond static design systems.

Immersive Computing (AR/VR)

Creates a foundation for environments that dynamically adapt to maintain comfort, reduce simulator sickness, and sustain engagement.

If my work resonates with you, feel free to reach out. I’m always happy to connect.

nfatemi@ncsu.edu