API Documentation

API reference for the module.

Table of Contents

File I/O

Functions for file I/O.

NWB & Custom file I/O

save_nwbfile(nwbfile, file_name[, folder])

Save out an NWB file.

load_nwbfile(file_name[, folder, return_io])

Load an NWB file.

save_config(cdict, file_name[, folder])

Save out a config file.

load_config(file_name[, folder])

Load an individual config file.

load_configs(files[, folder])

Load all configs together.

save_object(custom_object, file_name[, folder])

Save a custom object.

load_object(file_name[, folder])

Load a custom object.

General file I/O

save_txt(text, file_name[, folder])

Save out text to a txt file.

load_txt(file_name[, folder])

Load text from a txt file.

save_json(data, file_name[, folder])

Save out a dictionary of data to a JSON file.

load_json(file_name[, folder])

Load from a JSON file.

save_jsonlines(data, file_name[, folder])

Save out data to a JSONlines file.

load_jsonlines(file_name[, folder])

Load from a JSON lines file.

load_matfile(file_name[, folder, version])

Load a .mat file.

load_jsons_to_df(files[, folder])

Load a collection of JSON files into a dataframe.

open_h5file(file_name[, folder, mode, ext])

Context manager to open a HDF5 file.

save_to_h5file(data, file_name[, folder, ext])

Save data to a HDF5 file.

load_from_h5file(fields, file_name[, ...])

Load one or more specified field(s) from a HDF5 file.

Utilities

get_files(folder[, select, ignore, ...])

Get a list of files from a specified folder.

get_subfolders(folder[, select, ignore])

Get a list of sub-folders from a given folder.

make_session_name(subject, experiment, session)

Create a standardized session name.

make_file_list(experiment, files[, ext])

Make a list of subject files.

Validate Functions

validate_nwb(file_name[, folder, ...])

Validate a NWB file.

NSP

Functionality related to NSP (Neural Signal Processors).

I/O

load_blackrock(file_name, folder[, ...])

Load a set of Blackrock files.

Checks

check_blackrock_file_info(reader)

Check some basic information and metadata from a set of Blackrock files.

Objects

Custom objects.

Electrodes

Electrodes([subject, fs])

Object for collecting / managing electrode information.

TaskBase

TaskBase()

Base object for collecting task information.

Paths

Path management.

Paths Object

Paths(project_path[, subject, experiment, ...])

Paths object for a session of single-unit data.

Directory Creators

make_folder(path)

Make a folder, if it does not already exist.

create_project_directory(base_path, project)

Create the folder structure for a project.

create_subject_directory(project_path, subject)

Create the folder structure for a subject.

create_session_directory(project_path, ...)

Create the folder structure for a session of data.

Plots

Plotting functions and utilities.

Timestamps

plot_alignment(sync1, sync2[, n_pulses, ax])

Plot the alignment between synchronization pulses.

plot_peaks(data, peak_inds, peak_heights[, ax])

Plot detected peaks on a time series.

Timestamps

Functions and helpers for managing timestamps and temporal alignment.

Alignment

fit_sync_alignment(sync_behav, sync_neural)

Fit a model to align synchronization pulses from different recording systems.

predict_times(times, intercept, coef)

Predict times alignment from model coefficients.

predict_times_model(times, model)

Predict times alignment from a model object.

match_pulses(sync_behav, sync_neural, n_pulses)

Match pulses to each other based on ISIs.

Peaks

detect_peaks(data, fs, height[, distance, ...])

Process peaks from a time series.

Update

offset_time(times, offset)

Apply an offset to timestamps.

change_time_units(times, value[, operation])

Change the units of timestamps.

change_sampling_rate(times, fs_from, fs_to)

Change the effective sampling rate for a set of times values.

Utils

convert_samples_to_time(n_samples, fs[, output])

Convert a number of samples to corresponding time length.

create_timestamps_from_samples(samples, fs)

Create a set of timestamps for a set of samples.

Sorting

Spike sorting related functionality.

I/O

load_spike_data_file(channel, folder, polarity)

Load a spike detection output file from Combinato - files with the form data_chan_XX.h5.

load_sorting_data_file(channel, folder, ...)

Load a combinato sorting output file - files with the file name sort_cat.h5.

save_units(units, folder)

Save out units information.

load_units(folder)

Load a set of units files from a folder.

Processing

collect_all_sorting(spike_data, sort_data)

Collect together all the organized spike sorting information for a channel of data.

process_combinato_data(channel, ...[, ...])

Helper function to run the process of going from combinato -> extracted units files.

Utilities

get_group_labels(class_labels, groups)

Get the group label for each spike (based on spike class + group mapping).

get_sorting_kept_labels(groups)

Get the valid clas / group information from the combinato organized groups info array.

extract_clusters(data)

Extract individual clusters from a channel of data.

Utils

Utilities & helper functions.

Check Functions

is_empty(var)

Check if a variable is empty, across possible types.

is_type(var, var_type)

Check is a variable is of the given type(s).

check_str_contents(str_to_check, contents)

Check whether a given string has specified contents.

clean_strings(lst)

Helper function to clean a list of string values for adding to NWB.

Convert Functions

convert_str_to_bool(string)

Convert a string to a boolean.

convert_strlist_to_bool(lst)

Convert a list of strings to a list of boolean.

convert_type(variable, dtype)

Convert type of a given variable.

convert_to_array(data, dtype)

Convert to an array of specified data type.

convert_time_to_date(timestamp[, tz])

Convert a time value to a datetime date.

Extract Functions

get_event_time(event_times, start, end)

Select a (single) event based on time range, returning NaN if not found.

get_trial_value(trials, data, trial[, dtype])

Extract a value for a specified trial.

Log Functions

print_status(verbose, message[, level])

Print a status update.

Run Functions

catch_error(proceed, name, path[, verbose, ...])

Catch a raised error, with the option to save an error log and proceed.

Tool Functions

incrementer([start, end])

Generator that returns an incrementing index value.

get_current_date([tz])

Get the current datetime.