Skip to content

Instantly share code, notes, and snippets.

View bendichter's full-sized avatar
🏠
Working from home

Ben Dichter bendichter

🏠
Working from home
View GitHub Profile
@bendichter
bendichter / README.md
Created July 27, 2026 15:43
Repairing DANDI dandiset 000044: SpatialSeries rate stored as period, 16-bit wraparound in units/spike_times_index (dandi/helpdesk#154)

Repairing dandiset 000044 (Grosmark & Buzsáki hippocampal recordings)

Scripts used to diagnose and repair the defects reported in dandi/helpdesk#154, across all 8 assets of dandiset 000044.

Every edit is an in-place HDF5 attribute or single-element write. No dataset is resized, and no sample data — position, spike times, or ephys — is modified.

Defect 1 — SpatialSeries rate held the period, not the frequency

@bendichter
bendichter / README.md
Last active July 27, 2026 14:55
DANDI:000728 - root cause and fix for the truncated raw ophys asset in session 712919679 (dandi/helpdesk#209)

DANDI:000728 — truncated raw ophys asset for session 712919679

Investigation notes for dandi/helpdesk#209.

Confirmed, root cause identified, and it is exactly one file out of 1518. The affected asset is a stub_test=True conversion of the conversion script's hardcoded test session that was uploaded during initial development and then made permanently invisible to the batch converter by its own already-done check.

| | |

@bendichter
bendichter / README.md
Last active July 25, 2026 16:24
Auditing data & code availability in Nature Neuroscience: 856 primary research articles (2021-2026), 3,961 dataset/repo/accession links resolved. 7.1% of papers have at least one broken data or code link.

Auditing data & code availability in neuroscience journals

A reproducible pipeline that takes every primary research article published in a journal over a date window, parses its Data availability and Code availability statements, and then actually tries to resolve every dataset, repository and accession they point to. Run in depth on Nature Neuroscience (scraped from nature.com, including paywalled articles) and across four neuroscience journals via PMC full text.

It exists because of a single observation: a 2026 Nature Neuroscience paper cites a Zenodo DOI for its imaging software that was never registered, so the link 404s. That is

@bendichter
bendichter / EXAMPLE_OUTPUT.txt
Created July 16, 2026 17:59
Verify suite2p rfft2 registration change against unmodified main: numerical equivalence + timing
Reference output, suite2p main (90be895) vs the rfft2 branch.
300 frames of 512x512, CPU (Apple Silicon, 10 cores), torch 2.6.0.
$ python verify_rfft2_registration.py compare old.npz new.npz
key identical max diff shape
--------------------------------------------------------------
nr_frames False 4.000e+01 (300, 512, 512)
nr_meanImg False 1.338e-01 (512, 512)
nr_off0 True 0.000e+00 (300,)
@bendichter
bendichter / README.md
Created July 16, 2026 15:07
rastermap: bit-exactness check for the sort.py speedup (52 cases, 0 mismatches)

Bit-exactness check for the rastermap sorting change

These scripts record the output of rastermap's sorting and compare it across two commits. They accompany a change to rastermap/sort.py that speeds up the travelling salesman sort, and they support the claim that the output is bit-identical rather than approximately equal.

Running It

The comparison needs a recording from each commit:

@bendichter
bendichter / gist:d0814dfa7aeba429bcb8e111f2c57181
Created March 25, 2026 20:36
visualize icephys data for DANDI paper
# analyze data from https://dandiarchive.org/dandiset/001753/0.260220.1838
"""Visualize intracellular electrophysiology data from an NWB file."""
import h5py
import numpy as np
import matplotlib
matplotlib.use("Agg")
import matplotlib.pyplot as plt
from matplotlib import cm
@bendichter
bendichter / zarr_metadata.py
Last active July 4, 2024 15:52
Create zarr metadata to read arbitrary binary file
import numpy as np
import json
import base64
def _add_dataset_to_rfs(
rfs: dict,
shape: list[int],
dtype: np.dtype,
dset_name: str,
@bendichter
bendichter / constrained_array.py
Created January 8, 2024 20:04
constrainedarray
from typing import Tuple, Type, Any, Union, Optional
from pydantic import BaseModel
import numpy as np
def get_shape(data):
"""
Get the shape of various data structures: NumPy array, h5py dataset, Zarr dataset, or a nested list of arbitrary depth.
Parameters
@bendichter
bendichter / convert_ephys_dandiset_to_bids.ipynb
Last active December 18, 2023 15:06
convert_ephys_dandiset_to_bids
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.