diff --git a/000409/IBL/bwm_usage_notebook.ipynb b/000409/IBL/bwm_usage_notebook.ipynb
index 76a1d10..3616646 100644
--- a/000409/IBL/bwm_usage_notebook.ipynb
+++ b/000409/IBL/bwm_usage_notebook.ipynb
@@ -15,7 +15,7 @@
"source": [
"## Installing requirements\n",
"\n",
- "The cell below installs every Python package needed to run this notebook, at fully pinned versions, using [`uv`](https://github.com/astral-sh/uv) for fast resolution. In Colab the cell is collapsed by default — click the ▶ button to run it."
+ "The cell below installs every Python package needed to run this notebook, at fully pinned versions, using [`uv`](https://github.com/astral-sh/uv) for fast resolution. In Colab the cell is collapsed by default \u2014 click the \u25b6 button to run it."
]
},
{
@@ -27,7 +27,7 @@
},
"outputs": [],
"source": [
- "#@title Installing requirements (click ▶ to run) { display-mode: \"form\" }\n",
+ "#@title Installing requirements (click \u25b6 to run) { display-mode: \"form\" }\n",
"# Colab provides Python 3.12. We install with `uv --system` because Colab's\n",
"# kernel runs outside a virtualenv. All versions (direct + transitive) are\n",
"# pinned below so the notebook is reproducible regardless of resolver drift.\n",
@@ -242,9 +242,9 @@
"id": "a5595879",
"metadata": {},
"source": [
- "> **⚠️ Restart runtime after install**\n",
+ "> **\u26a0\ufe0f Restart runtime after install**\n",
">\n",
- "> The install may upgrade packages already loaded in the kernel. Go to **Runtime → Restart session**, then **Run all cells below** (skip this install cell on re-run)."
+ "> The install may upgrade packages already loaded in the kernel. Go to **Runtime \u2192 Restart session**, then **Run all cells below** (skip this install cell on re-run)."
]
},
{
@@ -478,7 +478,7 @@
" });\n",
" });\n",
" \n",
- "
resolution: -1.0
comments: no comments
description: Acquisition traces for the ElectricalSeriesProbe00AP.
conversion: 2.34375e-06
offset: 0.0
unit: volts
data
HDF5 dataset
| Data type | int16 |
|---|
| Shape | (164362247, 384) |
|---|
| Array size | 117.56 GiB |
|---|
| Chunk shape | (13020, 384) |
|---|
| Compression | gzip |
|---|
| Compression opts | 4 |
|---|
| Uncompressed size (bytes) | 126230205696 |
|---|
| Compressed size (bytes) | 61453524661 |
|---|
| Compression ratio | 2.0540759279851195 |
|---|
timestamps
HDF5 dataset
| Data type | float64 |
|---|
| Shape | (164362247,) |
|---|
| Array size | 1.22 GiB |
|---|
| Chunk shape | (1250000,) |
|---|
| Compression | gzip |
|---|
| Compression opts | 4 |
|---|
| Uncompressed size (bytes) | 1314897976 |
|---|
| Compressed size (bytes) | 793462428 |
|---|
| Compression ratio | 1.6571647624378756 |
|---|
timestamps_unit: seconds
interval: 1
electrodes (DynamicTableRegion)
description: electrode_table_region
table (ElectrodesTable)
description: metadata about extracellular electrodes
columns
location
Location of the electrode (channel).
group
Reference to the ElectrodeGroup.
electrode_name
Unique identifier derived from probe contact ids.
contact_shapes
Contact shape per electrode as defined by the probe.
channel_name
The name of this channel, showing all recording streams for the electrode (e.g., 'AP379,LF379').
rel_x
Relative x coordinate on the probe (µm).
rel_y
Relative y coordinate on the probe (µm).
probe_name
IBL probe name in canonical format (e.g., 'Probe00', 'Probe01').
contact_ids
Channel IDs as specified by the probe manufacturer.
shank_ids
Shank ID for each electrode (for multi-shank probes).
adc_group
ADC group index from SpikeGLX metadata.
adc_sample_order
ADC sample order from SpikeGLX metadata.
group_name
Name of the ElectrodeGroup.
x
x coordinate of the channel location in the brain.
y
y coordinate of the channel location in the brain.
z
z coordinate of the channel location in the brain.
imp
Impedance of the channel, in ohms.
filtering
Description of hardware filtering.
table
\n",
+ " resolution: -1.0
comments: no comments
description: Acquisition traces for the ElectricalSeriesProbe00AP.
conversion: 2.34375e-06
offset: 0.0
unit: volts
data
HDF5 dataset
| Data type | int16 |
|---|
| Shape | (164362247, 384) |
|---|
| Array size | 117.56 GiB |
|---|
| Chunk shape | (13020, 384) |
|---|
| Compression | gzip |
|---|
| Compression opts | 4 |
|---|
| Uncompressed size (bytes) | 126230205696 |
|---|
| Compressed size (bytes) | 61453524661 |
|---|
| Compression ratio | 2.0540759279851195 |
|---|
timestamps
HDF5 dataset
| Data type | float64 |
|---|
| Shape | (164362247,) |
|---|
| Array size | 1.22 GiB |
|---|
| Chunk shape | (1250000,) |
|---|
| Compression | gzip |
|---|
| Compression opts | 4 |
|---|
| Uncompressed size (bytes) | 1314897976 |
|---|
| Compressed size (bytes) | 793462428 |
|---|
| Compression ratio | 1.6571647624378756 |
|---|
timestamps_unit: seconds
interval: 1
electrodes (DynamicTableRegion)
description: electrode_table_region
table (ElectrodesTable)
description: metadata about extracellular electrodes
columns
location
Location of the electrode (channel).
group
Reference to the ElectrodeGroup.
electrode_name
Unique identifier derived from probe contact ids.
contact_shapes
Contact shape per electrode as defined by the probe.
channel_name
The name of this channel, showing all recording streams for the electrode (e.g., 'AP379,LF379').
rel_x
Relative x coordinate on the probe (\u00b5m).
rel_y
Relative y coordinate on the probe (\u00b5m).
probe_name
IBL probe name in canonical format (e.g., 'Probe00', 'Probe01').
contact_ids
Channel IDs as specified by the probe manufacturer.
shank_ids
Shank ID for each electrode (for multi-shank probes).
adc_group
ADC group index from SpikeGLX metadata.
adc_sample_order
ADC sample order from SpikeGLX metadata.
group_name
Name of the ElectrodeGroup.
x
x coordinate of the channel location in the brain.
y
y coordinate of the channel location in the brain.
z
z coordinate of the channel location in the brain.
imp
Impedance of the channel, in ohms.
filtering
Description of hardware filtering.
table
\n",
" \n",
" \n",
" | \n",
@@ -703,7 +703,7 @@
" });\n",
" });\n",
" \n",
- " resolution: -1.0
comments: no comments
description: Acquisition traces for the ElectricalSeriesProbe00LF.
conversion: 4.6875e-06
offset: 0.0
unit: volts
data
HDF5 dataset
| Data type | int16 |
|---|
| Shape | (13696854, 384) |
|---|
| Array size | 9.80 GiB |
|---|
| Chunk shape | (13020, 384) |
|---|
| Compression | gzip |
|---|
| Compression opts | 4 |
|---|
| Uncompressed size (bytes) | 10519183872 |
|---|
| Compressed size (bytes) | 5364846101 |
|---|
| Compression ratio | 1.9607615342477835 |
|---|
timestamps
HDF5 dataset
| Data type | float64 |
|---|
| Shape | (13696854,) |
|---|
| Array size | 104.50 MiB |
|---|
| Chunk shape | (1250000,) |
|---|
| Compression | gzip |
|---|
| Compression opts | 4 |
|---|
| Uncompressed size (bytes) | 109574832 |
|---|
| Compressed size (bytes) | 71276130 |
|---|
| Compression ratio | 1.5373285839172244 |
|---|
timestamps_unit: seconds
interval: 1
electrodes (DynamicTableRegion)
description: electrode_table_region
table (ElectrodesTable)
description: metadata about extracellular electrodes
columns
location
Location of the electrode (channel).
group
Reference to the ElectrodeGroup.
electrode_name
Unique identifier derived from probe contact ids.
contact_shapes
Contact shape per electrode as defined by the probe.
channel_name
The name of this channel, showing all recording streams for the electrode (e.g., 'AP379,LF379').
rel_x
Relative x coordinate on the probe (µm).
rel_y
Relative y coordinate on the probe (µm).
probe_name
IBL probe name in canonical format (e.g., 'Probe00', 'Probe01').
contact_ids
Channel IDs as specified by the probe manufacturer.
shank_ids
Shank ID for each electrode (for multi-shank probes).
adc_group
ADC group index from SpikeGLX metadata.
adc_sample_order
ADC sample order from SpikeGLX metadata.
group_name
Name of the ElectrodeGroup.
x
x coordinate of the channel location in the brain.
y
y coordinate of the channel location in the brain.
z
z coordinate of the channel location in the brain.
imp
Impedance of the channel, in ohms.
filtering
Description of hardware filtering.
table
\n",
+ " resolution: -1.0
comments: no comments
description: Acquisition traces for the ElectricalSeriesProbe00LF.
conversion: 4.6875e-06
offset: 0.0
unit: volts
data
HDF5 dataset
| Data type | int16 |
|---|
| Shape | (13696854, 384) |
|---|
| Array size | 9.80 GiB |
|---|
| Chunk shape | (13020, 384) |
|---|
| Compression | gzip |
|---|
| Compression opts | 4 |
|---|
| Uncompressed size (bytes) | 10519183872 |
|---|
| Compressed size (bytes) | 5364846101 |
|---|
| Compression ratio | 1.9607615342477835 |
|---|
timestamps
HDF5 dataset
| Data type | float64 |
|---|
| Shape | (13696854,) |
|---|
| Array size | 104.50 MiB |
|---|
| Chunk shape | (1250000,) |
|---|
| Compression | gzip |
|---|
| Compression opts | 4 |
|---|
| Uncompressed size (bytes) | 109574832 |
|---|
| Compressed size (bytes) | 71276130 |
|---|
| Compression ratio | 1.5373285839172244 |
|---|
timestamps_unit: seconds
interval: 1
electrodes (DynamicTableRegion)
description: electrode_table_region
table (ElectrodesTable)
description: metadata about extracellular electrodes
columns
location
Location of the electrode (channel).
group
Reference to the ElectrodeGroup.
electrode_name
Unique identifier derived from probe contact ids.
contact_shapes
Contact shape per electrode as defined by the probe.
channel_name
The name of this channel, showing all recording streams for the electrode (e.g., 'AP379,LF379').
rel_x
Relative x coordinate on the probe (\u00b5m).
rel_y
Relative y coordinate on the probe (\u00b5m).
probe_name
IBL probe name in canonical format (e.g., 'Probe00', 'Probe01').
contact_ids
Channel IDs as specified by the probe manufacturer.
shank_ids
Shank ID for each electrode (for multi-shank probes).
adc_group
ADC group index from SpikeGLX metadata.
adc_sample_order
ADC sample order from SpikeGLX metadata.
group_name
Name of the ElectrodeGroup.
x
x coordinate of the channel location in the brain.
y
y coordinate of the channel location in the brain.
z
z coordinate of the channel location in the brain.
imp
Impedance of the channel, in ohms.
filtering
Description of hardware filtering.
table
\n",
" \n",
" \n",
" | \n",
@@ -1177,7 +1177,7 @@
"
\n",
" \n",
"
\n",
- "384 rows × 18 columns
\n",
+ "384 rows \u00d7 18 columns
\n",
" "
],
"text/plain": [
@@ -1317,7 +1317,7 @@
" });\n",
" });\n",
" \n",
- " description: metadata about extracellular electrodes
columns
location
Location of the electrode (channel).
group
Reference to the ElectrodeGroup.
electrode_name
Unique identifier derived from probe contact ids.
contact_shapes
Contact shape per electrode as defined by the probe.
channel_name
The name of this channel, showing all recording streams for the electrode (e.g., 'AP379,LF379').
rel_x
Relative x coordinate on the probe (µm).
rel_y
Relative y coordinate on the probe (µm).
probe_name
IBL probe name in canonical format (e.g., 'Probe00', 'Probe01').
contact_ids
Channel IDs as specified by the probe manufacturer.
shank_ids
Shank ID for each electrode (for multi-shank probes).
adc_group
ADC group index from SpikeGLX metadata.
adc_sample_order
ADC sample order from SpikeGLX metadata.
group_name
Name of the ElectrodeGroup.
x
x coordinate of the channel location in the brain.
y
y coordinate of the channel location in the brain.
z
z coordinate of the channel location in the brain.
imp
Impedance of the channel, in ohms.
filtering
Description of hardware filtering.
table
\n",
+ " description: metadata about extracellular electrodes
columns
location
Location of the electrode (channel).
group
Reference to the ElectrodeGroup.
electrode_name
Unique identifier derived from probe contact ids.
contact_shapes
Contact shape per electrode as defined by the probe.
channel_name
The name of this channel, showing all recording streams for the electrode (e.g., 'AP379,LF379').
rel_x
Relative x coordinate on the probe (\u00b5m).
rel_y
Relative y coordinate on the probe (\u00b5m).
probe_name
IBL probe name in canonical format (e.g., 'Probe00', 'Probe01').
contact_ids
Channel IDs as specified by the probe manufacturer.
shank_ids
Shank ID for each electrode (for multi-shank probes).
adc_group
ADC group index from SpikeGLX metadata.
adc_sample_order
ADC sample order from SpikeGLX metadata.
group_name
Name of the ElectrodeGroup.
x
x coordinate of the channel location in the brain.
y
y coordinate of the channel location in the brain.
z
z coordinate of the channel location in the brain.
imp
Impedance of the channel, in ohms.
filtering
Description of hardware filtering.
table
\n",
" \n",
" \n",
" | \n",
@@ -2277,30 +2277,60 @@
}
],
"source": [
- "# Workaround: brainglobe-atlasapi 2.3.1 fetches its atlas-version manifest\n",
- "# from a Colab-unfriendly S3 endpoint that returns 403 for some Colab IPs.\n",
- "# Pre-seed the cache so BrainGlobeAtlas() below can find a version manifest\n",
- "# even when the live fetch fails. See https://github.com/brainglobe/brainglobe-atlasapi/issues/738\n",
+ "# --- Robustly make the Allen 25um atlas available to brainglobe-atlasapi 2.3.1 ---\n",
+ "# brainglobe-atlasapi 2.3.1 (the latest release) downloads atlases from GIN\n",
+ "# (gin.g-node.org/brainglobe/atlases), where allen_mouse_25um is version 1.2.\n",
+ "# Two things break this on Colab:\n",
+ "# 1. Some Colab IPs get a 403 when atlasapi live-fetches the version manifest.\n",
+ "# atlasapi then falls back to a cached last_versions.conf -- so we pre-seed\n",
+ "# that cache. We must seed GIN's version (1.2): brainglobe's newer S3 catalog\n",
+ "# lists an incompatible version 3.0 that does NOT exist on GIN, which would\n",
+ "# make atlasapi request a nonexistent v3.0 tarball.\n",
+ "# 2. atlasapi's downloader does not check the HTTP status, so a 403/404 HTML\n",
+ "# page gets written to disk as the \"tarball\" -> \"ReadError: not a gzip file\".\n",
+ "# To sidestep both, we download and validate the tarball ourselves, then unpack\n",
+ "# it into ~/.brainglobe so BrainGlobeAtlas() finds it locally and never downloads.\n",
"from pathlib import Path\n",
+ "import tarfile\n",
"import urllib.request\n",
"\n",
+ "_ATLAS = \"allen_mouse_25um\"\n",
+ "_VERSION = \"1.2\"\n",
+ "_GIN = \"https://gin.g-node.org/brainglobe/atlases/raw/master\"\n",
"_bg_dir = Path.home() / \".brainglobe\"\n",
- "_manifest_url = (\n",
- " \"https://brainglobe.s3.us-west-2.amazonaws.com/atlas/atlases/last_versions.conf\"\n",
- ")\n",
+ "_bg_dir.mkdir(parents=True, exist_ok=True)\n",
+ "\n",
+ "# Seed the version manifest (overwrite any stale/wrong cache from a prior run).\n",
"try:\n",
- " _manifest = urllib.request.urlopen(_manifest_url, timeout=20).read().decode()\n",
+ " _manifest = urllib.request.urlopen(f\"{_GIN}/last_versions.conf\", timeout=30).read().decode()\n",
+ " if f\"{_ATLAS} = {_VERSION}\" not in _manifest:\n",
+ " raise ValueError(\"unexpected manifest contents\")\n",
"except Exception as _e: # noqa: BLE001\n",
- " print(f\"Couldn't reach brainglobe manifest ({_e}); writing a minimal fallback.\")\n",
- " _manifest = \"[atlases]\\nallen_mouse_25um = 3.0\\n\"\n",
- "\n",
- "# Write to both the V1 and V2 cache paths so whichever brainglobe-atlasapi\n",
- "# code path reads from disk finds the file.\n",
+ " print(f\"Couldn't reach GIN manifest ({_e}); writing a minimal fallback.\")\n",
+ " _manifest = f\"[atlases]\\n{_ATLAS} = {_VERSION}\\n\"\n",
"for _p in (_bg_dir / \"last_versions.conf\",\n",
" _bg_dir / \"brainglobe-atlasapi\" / \"atlases\" / \"last_versions.conf\"):\n",
" _p.parent.mkdir(parents=True, exist_ok=True)\n",
- " if not _p.exists():\n",
- " _p.write_text(_manifest)\n",
+ " _p.write_text(_manifest)\n",
+ "\n",
+ "# Pre-install the atlas data unless it is already unpacked locally.\n",
+ "_atlas_dir = _bg_dir / f\"{_ATLAS}_v{_VERSION}\"\n",
+ "if not _atlas_dir.exists():\n",
+ " _tar = _bg_dir / f\"{_ATLAS}_v{_VERSION}.tar.gz\"\n",
+ " print(f\"Downloading {_ATLAS} v{_VERSION} from GIN...\")\n",
+ " urllib.request.urlretrieve(f\"{_GIN}/{_ATLAS}_v{_VERSION}.tar.gz\", _tar)\n",
+ " # Validate gzip magic bytes so an HTML error page can't masquerade as a tarball.\n",
+ " with open(_tar, \"rb\") as _fh:\n",
+ " if _fh.read(2) != b\"\\x1f\\x8b\":\n",
+ " _tar.unlink(missing_ok=True)\n",
+ " raise RuntimeError(\n",
+ " \"Atlas download is not a gzip file (likely an HTTP 403/404 from GIN \"\n",
+ " \"for this runtime's IP). Re-run, or fetch the atlas from a reachable mirror.\"\n",
+ " )\n",
+ " with tarfile.open(_tar) as _t:\n",
+ " _t.extractall(path=_bg_dir)\n",
+ " _tar.unlink(missing_ok=True)\n",
+ " print(f\"Atlas ready at {_atlas_dir}\")\n",
"\n",
"import matplotlib.pyplot as plt\n",
"import numpy as np\n",
@@ -4249,7 +4279,7 @@
"
\n",
" \n",
"
\n",
- "892 rows × 17 columns
\n",
+ "892 rows \u00d7 17 columns
\n",
" "
],
"text/plain": [
@@ -5939,4 +5969,4 @@
},
"nbformat": 4,
"nbformat_minor": 5
-}
+}
\ No newline at end of file