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_blackrock.py
Created October 8, 2025 13:50
stub_blackrock
"""
Script to create stubbed (reduced-size) Blackrock test files.
This creates small test files that preserve:
- All headers (basic + extended)
- A small amount of data (enough to test gap detection)
- The file structure and format
Usage:
python stub_blackrock_files.py <input_dir> <output_dir> --samples <n>
@h-mayorquin
h-mayorquin / stub_edf.py
Created August 21, 2025 02:02
This is to stub an edf file with both electrode and analog data
# /// script
# requires-python = ">=3.10"
# dependencies = [
# "pyedflib>=0.1.36",
# "numpy>=1.23"
# ]
# ///
"""
One-off script to create a short "stub" EDF/EDF+ from a full file by copying
@h-mayorquin
h-mayorquin / stub_tiff_caiman.py
Created June 18, 2025 17:02
Stub CaImAn tiff data
"""
TIFF file stubber - Creates a stub of a TIFF file with only the first n pages.
Preserves all metadata, tags, and structure of the original pages.
"""
from pathlib import Path
import tifffile
import numpy as np
@h-mayorquin
h-mayorquin / stub_caiman.py
Last active June 19, 2025 16:48
Stub CaImAn data
import h5py
import numpy as np
from typing import Optional
from scipy.sparse import csc_matrix
from pathlib import Path
def stub_caiman_hdf5(input_file: str, output_file: Optional[str] = None, n_timestamps: int = 10, n_units: Optional[int] = None, stub_one_photon_quantities: bool = True):
"""
Create a stubbed version of a CaImAn HDF5 file with reduced units and timestamps.
@h-mayorquin
h-mayorquin / testing_mermaid.md
Last active June 9, 2025 04:06
testing_mermaid
%%{ init: {
      'theme':'base',
      'themeVariables': {
        'background': '#a7d2eb',          /* light backdrop */
        'lineColor' : '#09205A',          /* navy outlines / arrows */
        'primaryColor'  : '#005CA9',      /* dark blue */
        'secondaryColor': '#238FD6',      /* light blue */
        'tertiaryColor' : '#F57C00'       /* orange accent */
      }
@h-mayorquin
h-mayorquin / extract_plugging_info_hdf5.py
Created June 5, 2025 04:32
A small script to obtain the information of all the available compression plugins on hdf5 plugin package
import hdf5plugin
import h5py
import numpy as np
from hdmf.backends.hdf5.h5_utils import H5DataIO
from pynwb.testing.mock.file import mock_NWBFile
from pathlib import Path
from pynwb import NWBHDF5IO
from pynwb.file import TimeSeries
from neuroconv.tools.nwb_helpers import AVAILABLE_HDF5_COMPRESSION_METHODS
@h-mayorquin
h-mayorquin / stub_femtonics.py
Last active June 30, 2025 19:16
Stub hdf5 femtonics
from pathlib import Path
import h5py
import numpy as np
# ────────────────────────────────────────────────────────────────────────────
def copy_group(
src_group,
dst_group,
stub_frames: int,
@h-mayorquin
h-mayorquin / stub_scan_image.py
Created May 3, 2025 17:00
Stub scan image files
#!/usr/bin/env python3
"""
stub_scan_image_file.py
──────────────────────────────────────────────────────────────────────────────
Functions for creating stub ScanImage TIFF files with modified metadata.
"""
import re
import shutil
import struct
@h-mayorquin
h-mayorquin / generate_audio_stub.py
Last active March 1, 2025 23:32
generate stub audio
from pathlib import Path
from pydub import AudioSegment
import numpy as np
import scipy.io.wavfile as wav
# Create output directory
output_dir = Path("audio_test_files")
output_dir.mkdir(exist_ok=True)
# Define output filenames with realistic names
@h-mayorquin
h-mayorquin / stub_thor_ome_tiff.py
Created February 28, 2025 18:24
Stubb Thor ome tiff
def stub_ome_dataset(file_path, num_timepoints=3, output_dir=None):
"""
Create a stubbed version of an OME-TIFF dataset based on a file path.
Parameters:
-----------
file_path : str or Path
Path to any TIFF file in the dataset
num_timepoints : int, optional
Number of timepoints to keep in the stub, default is 3