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 / stub_pl2.py
Created October 2, 2026 03:13
Stub Plexon .pl2 fixtures (time cut inside data blocks, STOP written at the cut, footer index rebuilt)
# /// script
# requires-python = ">=3.10"
# dependencies = ["numpy"]
# ///
"""Write the PL2 fixtures of the gin `plexon/pl2/` folder from their source recordings.
Usage::
uv run stub_pl2.py [fixture_name ...] # no names: every fixture in FIXTURES
@h-mayorquin
h-mayorquin / stub_plx.py
Created October 2, 2026 03:13
Stub Plexon .plx fixtures (whole data blocks kept byte for byte, time cuts or up to the n-th Stop, header counts recomputed)
# /// script
# requires-python = ">=3.10"
# dependencies = ["numpy"]
# ///
"""Write the PLX fixtures of the gin `plexon/plx/` folder from their source recordings.
The fixture `plx/timestamp_clock/one_megahertz_forty_bit_timestamps/` is written by a separate script with
the same machinery, `stub_plx_forty_bit_timestamps.py`, because its source file is not public.
Usage::
@h-mayorquin
h-mayorquin / stub_heka_dat.py
Created August 31, 2026 17:59
Stub HEKA PatchMaster .dat (drop whole groups, series and sweeps; survivors kept at full length)
# /// script
# requires-python = ">=3.10"
# dependencies = [
# "numpy",
# "load-heka-python @ git+https://github.com/easy-electrophysiology/load-heka-python",
# ]
# ///
"""Shrink a HEKA PatchMaster bundled .dat by keeping whole sweeps of truncated traces.
Source: any DAT2 bundle (see the per-fixture calls in stubs/README.md)
@h-mayorquin
h-mayorquin / make_keypoint_moseq_3d_and_csv.py
Last active August 29, 2026 19:35
Generate a keypoint-MoSeq 3D results.h5 and the CSV form (same deposit's 14-keypoint 3D coordinates, which widen centroid to (T, 3); save_results_as_csv run over both the 2D and 3D fits)
#!/usr/bin/env -S uv run --script
# /// script
# requires-python = ">=3.10,<3.12"
# dependencies = [
# "keypoint-moseq==0.6.10",
# "h5py",
# "pandas",
# "tables",
# ]
# ///
@h-mayorquin
h-mayorquin / make_keypoint_moseq_results.py
Last active August 29, 2026 19:35
Generate a keypoint-MoSeq 2D results.h5 (real keypoint-moseq 0.6.10 fit on the Weinreb 2024 open-field DeepLabCut keypoints, Zenodo 10636983, plus a truncated 3 x 500-frame copy)
#!/usr/bin/env -S uv run --script
# /// script
# requires-python = ">=3.10,<3.12"
# dependencies = [
# "keypoint-moseq==0.6.10",
# "h5py",
# "pandas",
# "tables",
# "requests",
# ]
@h-mayorquin
h-mayorquin / stub_intan_split_digital.py
Last active August 14, 2026 18:18
Stub Nelson Lab time-split Intan Traditional .rhd (4 files x 47 blocks, one contiguous run re-split so timestamps stay continuous across the boundaries, camera sync on DIGITAL-IN-14 plus 3 aux inputs)
# /// script
# requires-python = ">=3.11"
# dependencies = [
# "neo>=0.14.3",
# "numpy",
# ]
# ///
"""Stub a split Intan Traditional (header-attached) recording that carries digital and aux lines.
Source: ~/data/nelson_lab/Intan files/64 site example 2 camera example/pm231213a_240205_240205_120954
@h-mayorquin
h-mayorquin / stub_rwd_csv_sessions.py
Created August 13, 2026 16:58
Stub RWD Fluorescence CSV sessions (whole-row windows, Events and Outputs filtered to match, settings and header lines byte for byte)
# /// script
# requires-python = ">=3.10"
# dependencies = []
# ///
"""Cut RWD Life Science fiber photometry sessions down to test-fixture size.
Source: ~/data/rwd/zenodo_21842013_laing/session_R2 (1 channel, 410+470, 10 fps)
~/data/rwd/zenodo_17645091_cjdae8/20241004_DAL01_..._AirPuff (2 channels, 50 fps, marked)
~/data/rwd/zenodo_17645091_cjdae8/20240920_DAL01_... (2 channels, 50 fps, unmarked)
Output: ~/data/rwd/stubs/{fiber_photometry_datasets,events_datasets}/rwd/...
@h-mayorquin
h-mayorquin / stub_pyphotometry_events.py
Created August 13, 2026 16:58
Stub pyPhotometry .ppd digital-line windows (narrow pulses beside an idle line, a window open at both ends, wide pulses on two lines)
# /// script
# requires-python = ">=3.10"
# dependencies = [
# "numpy",
# ]
# ///
"""Cut pyPhotometry ``.ppd`` windows for the digital lines they carry, keeping the header untouched.
A ``.ppd`` word holds fifteen bits of an analog sample and one bit of a digital line, so the lines cannot
be cut out of a recording: a window carries the fluorescence with them. What can be chosen is which shape
@h-mayorquin
h-mayorquin / stub_two_colour_time_division.py
Created August 13, 2026 16:58
Stub Blanco-Pozo OSF pyPhotometry .ppd (93 min to 20 s, cut on a whole cycle, header byte for byte)
# /// script
# requires-python = ">=3.10"
# dependencies = []
# ///
"""Cut a pyPhotometry ``.ppd`` recording down to its first seconds, keeping the header untouched.
Source: an hour-and-a-half recording from the Blanco-Pozo, Akam and Walton OSF deposit (CC BY 4.0),
header version 0.2, mode ``2 colour time div.``, 130 Hz, about 2.9 MB.
Output: the same header and the leading whole cycles of samples, about 20 KB.
@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.