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_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'):
"""
@h-mayorquin
h-mayorquin / mac_os_kb_ubuntu_like.md
Created October 7, 2024 23:02 — forked from girip11/mac_os_kb_ubuntu_like.md
Configuring Mac OS keyboard shortcuts to resemble Ubuntu

Setup MacOS shortcuts to be same as Ubuntu

I have been using Ubuntu for last few years. Now I have to work on Mac OS for work. But I still use personal laptop which has Ubuntu. So I decided to setup the Mac OS shortcuts to be exactly same as in Ubuntu.

Prerequisites

@h-mayorquin
h-mayorquin / artificial_phy_data.ipynb
Last active September 17, 2024 18:41
Artificial data to showcase corrected of neuroconv PR https://github.com/catalystneuro/neuroconv/pull/961
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

Install Google Fonts

Download desired fonts

https://fonts.google.com/?selection.family=Open+Sans

Install Google Fonts on Ubuntu

cd /usr/share/fonts
sudo mkdir googlefonts
cd googlefonts
sudo unzip -d . ~/Downloads/Open_Sans.zip

@h-mayorquin
h-mayorquin / plot_raster.py
Created August 9, 2024 14:30
Plot nice raster
import matplotlib.pyplot as plt
from spikeinterface.core import generate_sorting
# Generate sorting data
total_duration = 40.0
sorting = generate_sorting(num_units=50, durations=[total_duration])
unit_ids = sorting.get_unit_ids()
spike_times_pero_unit = {uid: sorting.get_unit_spike_train(uid, return_times=True) for uid in unit_ids}
@h-mayorquin
h-mayorquin / error.md
Created May 23, 2024 16:14
Some error
    def close(self):
        """ Close the file.  All open objects become invalid """
        with phil:
            # Check that the file is still open, otherwise skip
            if self.id.valid:
                # We have to explicitly murder all open objects related to the file

                # Close file-resident objects first, then the files.
                # Otherwise we get errors in MPI mode.
@h-mayorquin
h-mayorquin / profile_memray.py
Last active June 20, 2024 21:11
Profile memray script
import subprocess
from pathlib import Path
import argparse
def run_profile_generate(file_path: Path, tag: str = "", verbose: bool = True, notemporal: bool = False):
program_folder = file_path.parent
program_name = file_path.stem
bin_file_name = f"memray_{program_name}.bin"