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_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
@h-mayorquin
h-mayorquin / stub_spikeglx.py
Last active February 5, 2025 15:11
Stub routine for spikeglx files
from pathlib import Path
import numpy as np
import shutil
from typing import Union, Optional, Tuple
def get_memmap_shape(filename: Union[str, Path],
dtype: Union[str, np.dtype],
num_channels: Optional[int] = None,
offset: int = 0) -> Tuple[int, ...]:
"""Calculate the shape of a memory-mapped binary file.
@h-mayorquin
h-mayorquin / image_iterator.py
Last active February 4, 2025 15:41
Generate images for testing images iterator
from hdmf.data_utils import AbstractDataChunkIterator, DataChunk
import numpy as np
from PIL import Image
from pathlib import Path
from hdmf.backends.hdf5.h5_utils import H5DataIO
def generate_random_images(num_images, width=256, height=256, mode='RGB', seed=None,
output_dir="generated_images", format='PNG'):
"""