cibrrig.utils.alf_utils

alf_utils.py

This module provides utilities for handling ALF (Alyx File) data. The primary usage is for concatenating data from multiple recordings within a session.

May be useful to expand functionality in the future.

Attributes

_log

TEMPORAL_FEATURES

Classes

Recording

Represents a recording session and provides methods to load, concatenate, and process ALF objects and logs.

Module Contents

cibrrig.utils.alf_utils._log[source]
cibrrig.utils.alf_utils.TEMPORAL_FEATURES = ['intervals', 'times', 'on_sec', 'off_sec', 'pk_time', 'inhale_peaks', 'exhale_troughs',...[source]
class cibrrig.utils.alf_utils.Recording(session_path)[source]

Represents a recording session and provides methods to load, concatenate, and process ALF objects and logs.

session_path[source]

Path to the session directory.

Type:

Path

raw_ephys_path[source]

Path to the raw electrophysiological data directory.

Type:

Path

alf_path[source]

Path to the ALF data directory.

Type:

Path

ni_fns[source]

List of NIDQ binary files in the raw ephys data directory.

Type:

list

n_recs[source]

Number of recordings found in the session.

Type:

int

breaks

Array of break times between recordings.

Type:

np.ndarray

alf_objects

List of all ALF objects in the session.

Type:

list

session_path[source]
raw_ephys_path[source]
alf_path[source]
ni_fns[source]
n_recs[source]
get_breaks_times()[source]

Calculates the break times between recordings and stores them in the breaks attribute.

This method reads the metadata from each NIDQ binary file to determine the duration of each recording and calculates the cumulative break times.

list_all_alf_objects()[source]

Lists all ALF objects present in the session and stores them in the alf_objects attribute.

This method scans the ALF directory for all ALF objects and extracts their names.

concatenate_triggers(object_name)[source]

Concatenates data of a given object (e.g., breaths, laser…) from multiple recordings (i.e. triggers) into a single ALF object.

Parameters:

object_name (str) – Name of the ALF object to concatenate.

Returns:

Concatenated ALF object.

Return type:

dict

concatenate_log(save=True, overwrite=True)[source]

Concatenates log data from multiple recordings into a single DataFrame.

Parameters:
  • save (bool, optional) – If True, save the concatenated log to a file. Defaults to True.

  • overwrite (bool, optional) – If True, overwrite existing log files. Defaults to True.

Returns:

Concatenated log DataFrame.

Return type:

pd.DataFrame

improve_opto_log(log)[source]

Enhances the optogenetic stimulation log by adding calibrated amplitudes and end times.

Parameters:

log (pd.DataFrame) – DataFrame containing the optogenetic stimulation log.

Returns:

Enhanced optogenetic stimulation log.

Return type:

pd.DataFrame

concatenate_alf_objects(save=True, overwrite=True)[source]

Concatenates all ALF objects in the session.

Parameters:
  • save (bool, optional) – If True, save the concatenated ALF objects to files. Defaults to True.

  • overwrite (bool, optional) – If True, overwrite existing ALF files. Defaults to True.

Returns:

None

concatenate_session(save=True, overwrite=True)[source]

Concatenates all ALF objects and logs in the session.

Parameters:
  • save (bool, optional) – If True, save the concatenated data to files. Defaults to True.

  • overwrite (bool, optional) – If True, overwrite existing files. Defaults to True.

Returns:

None

load_spikes()[source]