Installation
This guide covers how to install the Brain Encoding Response Generator (BERG) Python package and its dependencies.
Install BERG
Note
BERG requires Python ≥ 3.11.
Recommended (includes TRIBEv2)
pip install -U "berg[full] @ git+https://github.com/gifale95/BERG.git"
We recommend creating a dedicated conda environment:
conda create -n berg python=3.11
conda activate berg
pip install -U "berg[full] @ git+https://github.com/gifale95/BERG.git"
BrainScore (optional, replaces TRIBEv2)
BERG integrates with BrainScore, giving you access to hundreds of vision models scored against macaque electrophysiology recordings (V1, V2, V4, IT), as well as GPT-family language models scored against human fMRI data.
pip install -U "berg[brainscore] @ git+https://github.com/gifale95/BERG.git"
We recommend creating a dedicated conda environment for this:
conda create -n berg_brainscore python=3.11
conda activate berg_brainscore
pip install -U "berg[brainscore] @ git+https://github.com/gifale95/BERG.git"
Note
TRIBEv2 and BrainScore cannot be installed together due to a NumPy version conflict. Choose one depending on your use case. BrainScore requires Python = 3.11 specifically.
Switching between versions
If you already have one version installed and want to switch, uninstall the conflicting packages first:
Full → BrainScore:
pip uninstall tribev2 neuralset neuraltrain -y
pip install -e ".[brainscore]"
BrainScore → Full:
pip uninstall brainscore-vision brainscore-language -y
pip install -e ".[full]"
Verify Installation
To verify that BERG is correctly installed, run:
from berg import BERG
# Initialize BERG with default data directory
berg = BERG("/path/to/brain-encoding-response-generator")
# List available models
models = berg.list_models()
print(f"Available models: {models}")
You should see a list of available models in the output.
Quick Example
Here’s a simple example of how to generate in silico neural responses using BERG:
from berg import BERG
import numpy as np
# Initialize BERG
berg = BERG("/path/to/brain-encoding-response-generator")
# Get an encoding model
model = berg.get_encoding_model("fmri-nsd-fwrf", subject=1, selection={"roi": "V1"})
# Generate responses to stimuli
stimuli = np.random.randint(0, 255, (10, 3, 224, 224), dtype=np.uint8)
responses = berg.encode(model, stimuli)
print(f"Generated responses shape: {responses.shape}")
For more detailed examples and usage instructions, please see the Quickstart tutorial. For a tutorial on BrainScore models specifically, please see the BrainScore tutorial.