Upload a video, audio clip, or piece of text and see which parts of your brain it activates — predicted fMRI activity mapped to real psychological experiences.
Built on META TRIBEv2, the state-of-the-art brain encoding model from Meta AI Research.
Not a medical tool. Exploration and creative use only.
- You upload media (video, audio, or text)
- TRIBEv2 predicts fMRI brain activations across 20,484 cortical vertices
- Vertices are mapped to the HCP-MMP1 atlas (360 named cortical regions)
- Each region is translated to psychological experiences (e.g. V1 → visual edges, Broca's → language production)
- Results stream back with animated brain visualizations, waveform, and stimulation tips
BrainStim ships with a simulation mode so you can explore the full interface without installing the multi-gigabyte TRIBEv2 stack:
git clone https://github.com/reshadat/brainstim
cd brainstim
# Install the deps (see note below — start.sh alone is not enough)
python3 -m venv .venv && source .venv/bin/activate
pip install -r requirements.txt fastapi "uvicorn[standard]" python-multipart soundfile
# Launch
python -m uvicorn main:app --app-dir api --port 8000Open http://localhost:8000 and pick one of the sample stimuli ("Ocean
Documentary", "Live Jazz Set", "Spoken Poem", "Thriller Trailer", "Stand-up
Comedy"). Each runs a complete analysis with real nilearn cortical-surface
renders driven by synthesized activation, plus region and emotion breakdowns
drawn from the same HCP-MMP1 atlas data the live pipeline uses.
If you upload your own media while TRIBEv2 isn't installed, BrainStim automatically falls back to simulation so the experience still works end-to-end. A badge marks any result that came from simulation.
Note:
start.shonly installs the web-server packages (fastapi,uvicorn,python-multipart,soundfile). It does not installrequirements.txt, so simulation mode needsnilearn,matplotlib, andnumpyinstalled separately — hence the explicitpip install -r requirements.txtabove. Thefsaverage5mesh (~10 MB) downloads once on first run.
The live pipeline runs real fMRI prediction with Meta's TRIBEv2. It needs a capable machine (ideally a CUDA GPU) and several GB of model downloads. On a laptop — especially Apple Silicon without CUDA — expect slow inference and prefer simulation mode above.
- Python 3.11+ (TRIBEv2 requires 3.11+; the simulation venv's 3.9 is not enough for the full pipeline)
- ffmpeg (for video/audio processing)
- TRIBEv2 installed (see below)
- A Hugging Face account with approved access to
meta-llama/Llama-3.2-3B. The model is gated: request access on its model page (approval is typically minutes to hours), create a read token, thenhuggingface-cli login. TRIBEv2 loads Llama 3.2 internally, so inference fails without this even after everything else installs.
TRIBEv2 weights (
facebook/tribev2) are released under CC BY-NC 4.0 — non-commercial use only.
brew install python@3.12 ffmpeggit clone https://github.com/facebookresearch/tribev2
cd tribev2
python3.12 -m venv .venv && source .venv/bin/activate
pip install -e ".[plotting]"This pulls PyTorch and the multimodal encoders — several GB. The first
inference also downloads the facebook/tribev2 weights plus supporting models
(Llama 3.2, V-JEPA2, Wav2Vec-BERT); subsequent runs use the cache.
huggingface-cli login # paste a token from an account approved for Llama-3.2-3Bgit clone https://github.com/reshadat/brainstim
cd brainstim
# Point VENV at the tribev2 environment created in step 2:
VENV=/path/to/tribev2/.venv ./start.sh
# Or activate that venv first, then:
./start.sh
# Custom port:
./start.sh 9000Open http://localhost:8000. API docs at http://localhost:8000/docs. With
TRIBEv2 importable and Llama access granted, uploads run real inference and
results no longer carry the "simulated": true badge.
Note:
start.shfalls back to system/active Python whenVENVis unset. Either setVENVto your real tribev2 virtualenv (e.g./path/to/tribev2/.venv) or activate that environment before running.
| Method | Path | Description |
|---|---|---|
| POST | /api/infer |
Upload file → returns job_id |
| GET | /api/samples |
List sample stimuli for simulation mode |
| POST | /api/demo?scenario_id=… |
Run a simulated analysis on a sample → returns job_id |
| GET | /api/job/{id} |
Poll job status and progress |
| GET | /api/job/{id}/stream |
SSE stream of live progress |
| GET | /api/job/{id}/results |
Full results: frames, ROIs, waveform |
| GET | /api/brain_feelings |
Brain region → feelings mapping |
Simulated results carry "simulated": true and a "scenario" label in the
results payload.
Results payload:
{
"n_timesteps": 53,
"n_vertices": 20484,
"frames": ["<base64 PNG>", "..."],
"waveform": "<base64 PNG>",
"top_regions": [
{
"roi": "V1-lh",
"activation": 0.84,
"name": "Primary Visual Cortex",
"experience": "Raw edges, brightness, contrast",
"category": "Visual",
"tip": "Add vivid imagery..."
}
],
"emotions": [
{ "emotion": "Curiosity", "percentage": 34.2 }
],
"words": [{ "text": "hello", "start": 1.2, "duration": 0.3 }]
}brainstim/
├── api/
│ ├── main.py # FastAPI app and routes
│ ├── inference.py # TRIBEv2 pipeline + job store
│ ├── rendering.py # Brain frame (nilearn) + waveform (matplotlib)
│ ├── demo.py # Simulation mode: synthetic activation + sample stimuli
│ └── data.py # HCP-MMP1 region → feelings + stimulation tips
├── web/
│ └── index.html # Single-file frontend (Tailwind + vanilla JS)
├── requirements.txt
└── start.sh
| Type | Extensions |
|---|---|
| Video | .mp4 .avi .mkv .mov .webm |
| Audio | .wav .mp3 .flac .ogg |
| Text | .txt |
- No image support — TRIBEv2 processes temporal media only
- Jobs are lost on server restart (result JSON files survive; job index doesn't)
- Single-user, no auth — designed for local use
- Inference takes 1–5 minutes depending on file length and hardware
MIT