# BrainCell Installation Guide (NEURON 9.0.1 + Anaconda)
## Step 1: Install Anaconda
1. Download Anaconda from **https://www.anaconda.com/download**
2. Run the installer and follow the prompts
3. Use default settings (no need to add to system PATH during install)
## Step 2: Install NEURON 9.0.1
1. Download the Windows installer:
**nrn-9.0.1.w64-mingw-py-39-310-311-312-313-314-setup.exe**
from https://github.com/neuronsimulator/nrn/releases
2. Run the installer and follow the prompts
3. Install to the default location (e.g. `C:\nrn`) — the path must **not contain spaces**
## Step 3: Add Anaconda Python to System PATH
NEURON needs to find Anaconda's Python when launching `.hoc` files.
1. Open **Anaconda PowerShell Prompt** (from Start menu)
2. Find your Python path by running:
```
python -c "import sys; print(sys.executable)"
```
Note the folder path (e.g. `C:\Users\YourName\anaconda3`)
3. Add it to the system PATH by running:
```
[Environment]::SetEnvironmentVariable("Path", $env:Path + ";C:\Users\YourName\anaconda3", "Machine")
```
*(Replace `C:\Users\YourName\anaconda3` with your actual path from step 2)*
4. Close and reopen any command prompts
## Step 4: Verify NEURON + Python Connection
Open **Anaconda Prompt** and run:
```
python -c "from neuron import h; print(h.nrnversion())"
```
You should see: `NEURON -- VERSION 9.0.1 ...`
## Step 5: Patch BrainCell for NEURON 9 Compatibility
NEURON 9 changed how mechanism functions are called — BrainCell requires a small patch to one file.
**File to edit:** `BrainCell\_Code\InterModular\UtilsAndHelpers\InterModularMechSettings.hoc`
**Change 1** — Add a temporary section declaration at the template level. Find:
```
objref this
```
Add after it:
```
create _tmpSec
```
**Change 2** — In `onDllLoad()`, add a cleanup line. Find:
```
compareNumSpeciesBetweenJsonAndInternalMech("InsideOutDiffHelper")
```
Add after it:
```
// Clean up the temporary section so it doesn't appear in cell topology
execute("_tmpSec delete_section()", this)
```
**Change 3** — Replace the entire `compareNumSpeciesBetweenJsonAndInternalMech` procedure. Find:
```
proc compareNumSpeciesBetweenJsonAndInternalMech() {
strdef intMechName, hocCommand, msgTempl, msg
intMechName = $s1
sprint(hocCommand, "_numSpeciesInMod = getNumSpeciesInMOD_%s()", intMechName)
execute(hocCommand, this)
if (getNumSpeciesInJSON() == _numSpeciesInMod) {
return
}
msgTempl = "JSON file \"diffusible_species.json\" and MOD file \"_%s.mod\" are out of sync.\n The lists of species in these files must be identical (the total number of species, their order and \"ionMechName\")."
sprint(msg, msgTempl, intMechName)
printMsgAndRaiseError(msg)
}
```
Replace with:
```
proc compareNumSpeciesBetweenJsonAndInternalMech() {
strdef intMechName, hocCommand, msgTempl, msg
intMechName = $s1
// NEURON 9 requires setdata before calling mechanism functions.
// These are SUFFIX (distributed) mechanisms, so use "insert" and access via section.
sprint(hocCommand, "_tmpSec { insert %s }", intMechName)
execute(hocCommand, this)
sprint(hocCommand, "_tmpSec { setdata_%s(0.5) }", intMechName)
execute(hocCommand, this)
sprint(hocCommand, "_tmpSec { _numSpeciesInMod = getNumSpeciesInMOD_%s() }", intMechName)
execute(hocCommand, this)
sprint(hocCommand, "_tmpSec { uninsert %s }", intMechName)
execute(hocCommand, this)
if (getNumSpeciesInJSON() == _numSpeciesInMod) {
return
}
msgTempl = "JSON file \"diffusible_species.json\" and MOD file \"_%s.mod\" are out of sync.\n The lists of species in these files must be identical (the total number of species, their order and \"ionMechName\")."
sprint(msg, msgTempl, intMechName)
printMsgAndRaiseError(msg)
}
```
## Step 6: Run BrainCell
1. Navigate to the BrainCell folder:
```
cd C:\Users\YourName\BrainCell
```
3. Launch BrainCell:
```
init.hoc
```
Alternatively, you can double-click `init.hoc` directly if the PATH was set correctly in Step 3.