Skip to content

Instantly share code, notes, and snippets.

View h-mayorquin's full-sized avatar

Heberto Mayorquin h-mayorquin

View GitHub Profile
@h-mayorquin
h-mayorquin / generate_event_markers.py
Created July 31, 2026 20:19
Generate a synthetic BDF+ trigger stream (541 zero-duration numeric annotations over 90 trials, 4 annotation signals, onsets running past the end of the signal)
# /// script
# requires-python = ">=3.10"
# dependencies = [
# "pyedflib",
# "numpy",
# ]
# ///
"""
Generate a synthetic BDF+ file carrying a trigger stream at realistic length.
@h-mayorquin
h-mayorquin / generate_event_edge_cases.py
Created July 31, 2026 18:38
Generate a synthetic EDF+ with annotation edge cases (11 annotations: omitted vs zero duration, three shared onsets, overlapping intervals, sub-second onset, past-end interval, UTF-8 labels)
# /// script
# requires-python = ">=3.10"
# dependencies = [
# "pyedflib",
# "numpy",
# ]
# ///
"""
Generate a small EDF+C file whose annotations are shaped the awkward ways real writers emit them.
@h-mayorquin
h-mayorquin / generate_full_metadata.py
Last active July 31, 2026 19:10
Generate a synthetic EDF+ with every header metadata field populated (patient and recording identification subfields, per-signal transducer and prefiltering, 4ch x 256 Hz x 10 s)
# /// script
# requires-python = ">=3.10"
# dependencies = [
# "pyedflib",
# "numpy",
# ]
# ///
"""
Generate a small EDF+C file that populates every metadata field the format offers.
@h-mayorquin
h-mayorquin / generate_kilosort4_output.py
Last active July 31, 2026 14:26
Generate Kilosort 4 output (real KS 4.1.7 CPU run on a synthetic 32-channel recording, 6 units, 1.16 MB)
# /// script
# requires-python = ">=3.10"
# dependencies = [
# "kilosort==4.1.7",
# "spikeinterface==0.104.8",
# "numpy",
# "torch",
# ]
#
# [[tool.uv.index]]
@h-mayorquin
h-mayorquin / generate_biocam_v3_synthetic.py
Last active July 31, 2026 14:43
Generate BioCAM BRW v3.x files from the format spec (Version 100 matrix and 101 flat Raw layouts, 64ch x 1000 frames, self-identifying sample values)
# /// script
# requires-python = ">=3.10"
# dependencies = [
# "h5py",
# "numpy",
# ]
# ///
"""Generate small synthetic BRW v3.x (BioCam / 3Brain) files with known sample values.
Source: none. These are written from the format specification, not cut down from a
@h-mayorquin
h-mayorquin / stub_npm_extra.py
Created July 27, 2026 21:08
Stub GuPPy sampleData_NPM_3 and NPM_2 Neurophotometrics sessions (two-timestamp and per-excitation split layouts, 40-41 rows each)
# /// script
# requires-python = ">=3.10"
# dependencies = []
# ///
"""Stub two Neurophotometrics (NPM) sessions from the GuPPy sample set.
sampleData_NPM_3 -> multi_timestamp/ a column-multiplexed recording carrying two timestamp
columns, SystemTimestamp (device clock) and ComputerTimestamp (host clock),
with four regions in the short G0-G3 naming. Its companion ttls.csv event
file is already tiny and is copied verbatim.
@h-mayorquin
h-mayorquin / stub_npm.py
Created July 27, 2026 21:08
Stub GuPPy sampleData_NPM_4 and NPM_5 Neurophotometrics sessions (signal CSVs to 40 rows on whole LED cycles, event CSVs verbatim)
# /// script
# requires-python = ">=3.10"
# dependencies = ["pandas"]
# ///
"""Stub the two Neurophotometrics (NPM) sample sessions down to tiny CI fixtures.
Source: the two raw NPM sessions from gin ophys PR #48 (extracted to ../source/):
- npm4 = sampleData_NPM_4 (NEWER format: header + `Flags`/LedState column,
`Region*G` columns; events labelled True/False)
- npm5 = sampleData_NPM_5 (OLDER format: no header, 4 columns time+3 regions,
@h-mayorquin
h-mayorquin / stub_npm_startup_state_zero.py
Created July 27, 2026 21:01
Stub fibermagic arena Neurophotometrics CSV (startup coded 0 + 20 three-excitation cycles)
# /// script
# requires-python = ">=3.10"
# dependencies = []
# ///
"""Cut a Neurophotometrics prefix whose startup frame is coded 0.
The startup frame is written three different ways across recordings: 0 here, 7 in the multifile_split
and multi_timestamp files, and 16 in by_column and red_and_green_emission. All three mean the same
thing, a frame that is not a single excitation, so a reader keying on any particular value rather
than on the excitation bits fails on at least one of them.
@h-mayorquin
h-mayorquin / stub_npm_red_and_green_emission.py
Created July 27, 2026 21:01
Stub PhAT Sample1 Neurophotometrics CSV (startup + 20 three-excitation cycles, 2 red + 2 green regions)
# /// script
# requires-python = ">=3.10"
# dependencies = []
# ///
"""Cut a Neurophotometrics prefix carrying red and green emission columns side by side.
Two red and two green regions in the long Region<N><band> naming, so the emission band has to be
read off the column name. Three excitations rather than the usual two, each strobed on its own frame
(17, 18, 20 = 415, 470, 560 with output 0 held high for the whole recording), plus a startup frame
of 16.
@h-mayorquin
h-mayorquin / stub_npm_multi_wavelength_per_led_state.py
Created July 27, 2026 21:01
Stub GABASnFr Neurophotometrics CSV (60 rows, LedState 1/6, no 2 in the file)
# /// script
# requires-python = ">=3.10"
# dependencies = []
# ///
"""Cut a Neurophotometrics prefix in which one state value covers two excitations.
The inverse of the multi_led_state_per_wavelength case. This rig strobes 470 nm and 560 nm together
in one frame and 415 nm alone in the next, so the state column alternates 6 and 1 and the file
contains no 2 anywhere. The two simultaneous excitations do not interfere because their emission
bands land on opposite halves of the camera sensor, and therefore in different columns: a single 6