This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
from sleap_io import ( | |
PredictedInstance, | |
Skeleton, | |
Track, | |
Video, | |
Node, | |
LabeledFrame, | |
Labels, | |
) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
from pathlib import Path | |
data_dir_path = Path("/home/heberto/Murthy-data-share/one2one-mapping") | |
tiff_dir_path = data_dir_path / "raw_data" / "calcium_imaging" / "example_tiffs" | |
tiff_file_path_list = list(tiff_dir_path.iterdir()) | |
tiff_file_path = tiff_file_path_list[0] | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pickle | |
import timeit | |
from pathlib import Path | |
from statistics import mean, stdev | |
from spikeinterface.extractors import SpikeGLXRecordingExtractor | |
from spikeinterface.core import load_extractor, BaseRecording | |
def pickling(recording): | |
pickled_recording = pickle.dumps(recording) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- name: Installad datalad | |
run: | | |
pip install datalad-installer | |
if [ ${{ runner.os }} = 'Linux' ]; then | |
datalad-installer --sudo ok git-annex --method datalad/packages | |
elif [ ${{ runner.os }} = 'macOS' ]; then | |
datalad-installer --sudo ok git-annex --method brew | |
elif [ ${{ runner.os }} = 'Windows' ]; then | |
datalad-installer --sudo ok git-annex --method datalad/git-annex:release | |
fi |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import h5py | |
def remove_fields(input_file, output_file, fields_to_remove): | |
with h5py.File(input_file, "r") as input_h5: | |
with h5py.File(output_file, "w") as output_h5: | |
for key in input_h5.keys(): | |
if key not in fields_to_remove: | |
input_h5.copy(key, output_h5) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import tempfile | |
import os | |
import shutil | |
from pathlib import Path | |
from tempfile import tempdir | |
from spikeinterface.core.datasets import download_dataset | |
from spikeinterface.extractors import SpikeGLXRecordingExtractor | |
from spikeinterface.core.segmentutils import concatenate_recordings |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
try: | |
file_path.write_text( | |
json.dumps(dump_dict, indent=4, cls=SIJsonEncoder), | |
encoding='utf8', | |
) | |
except TypeError as e: | |
accepted_type = [str, int, float, bool or None] | |
def log_value_types_of_dict(dictionary): | |
if isinstance(dictionary, dict): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from pathlib import Path | |
import time | |
import os | |
import mmap | |
import itertools | |
import numpy as np | |
import matplotlib.pyplot as plt | |
import psutil | |
from tqdm.auto import tqdm |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import mmap | |
import os | |
from pathlib import Path | |
import numpy as np | |
def count_int16_elements(file_path): | |
file_size = os.path.getsize(file_path) | |
int16_size = np.dtype(np.int16).itemsize | |
return file_size // int16_size |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def calculate_peaks_spike_recall(peaks, sorting_ground_truth, tolerance_ms=0.4): | |
""" | |
Calculate the spike recall of the peaks (which are the output of a peak detection method) | |
against a ground truth of spike_trains. This function is used to test the quality of a peak detection method | |
in the context of a specific sorting. | |
Recall close to 1 means that all the spike in the spike_train are present in a peak whereas recall | |
close to 0 means that no spike in the spike_train are present in a peak. | |
More technically, this calculates the number of True positives divided by |