API

percephone.core

class percephone.core.recording.Recording(input_path, rois_path, mean_f_bsl, cache=True, detection=True)[source]

The Recording class represents a recording session for one mouse and provides methods to analyze the data.

filename

The filename of the recording session.

Type:

int

sf

The sampling frequency of the recording session.

Type:

float

genotype

The genotype of the mouse recorded.

Type:

str

threshold

The threshold stimulation amplitude.

Type:

float

input_path

The path to the folder containing the recording data (ending with /).

Type:

str

matrices

Stores the different matrices computed from the recording as 2D numpy.ndarray. The first dictionary has 2 keys : “EXC” and “INH” neurons, each having a dictionary as value. Both dictionaries are then keyed by the computed parameters (“Responsivity”, “AUC”, etc…) and have a 2D np.ndarray (nb neurons * nb stimulations) as value.

Type:

dict[str, dict[str, numpy.ndarray]]

df_f_exc

Stores the computed ΔF/F values for excitatory neurons at each timestep as a 2D numpy.ndarray (nb neurons * nb frames)

Type:

numpy.ndarray

df_f_inh

Stores the computed ΔF/F values for inhibitory neurons at each timestep as a 2D numpy.ndarray (nb neurons * nb frames)

Type:

numpy.ndarray

spks_exc

Stores the spikes trains for excitatory neurons at each timestep as a 2D numpy.ndarray (nb neurons * nb frames)

Type:

numpy.ndarray #TODO: check where it is computed

spks_inh

Stores the spikes trains for inhibitory neurons at each timestep as a 2D numpy.ndarray (nb neurons * nb frames)

Type:

numpy.ndarray

auc()[source]

Computes the zscore AUC matrices of the signal during the response period.

Note

Computes the AUC between 0 (the neuron normalized baseline) and the positive part of the curve for positive responses, or between 0 and the negative part of the curve for negative responses. 10 interpolated values are added between each frame for a more precise calculation of the AUC.

This method updates the ‘AUC’ matrices for the excitatory and inhibitory neurons in the ‘matrices’ attribute.

compute_df_f(cell_ids, save_path, mean_f_bsl)[source]

Compute ΔF/F and save it as a numpy.ndarray

Note

Defining The Baseline F0: Portera-Cailliau baseline (He et al., Goel et al.): “baseline period is the 10-s period with the lowest variation (s.d.) in ΔF/F.” Since to get the ΔF/F we already need to define a baseline, here the Baseline Period was defined as the 10s period with the lowest variation in F_neuropil_corrected

Parameters:
  • mean_f_bsl (boolean compute df/f with mean F for correction) –

  • cell_ids (list) – ids of cells for which the df_f will be computed.

  • save_path (str) – The folder where the df_f matrix will be saved (same as the input path)

Returns:

df_f_percen – ΔF/F of all the cells selected (nb neurons * nb frames)

Return type:

numpy.ndarray

delay_onset_map()[source]

Calculate the delay onset map for the excitatory and inhibitory neurons.

This method updates the ‘Delay_onset’ matrices for the excitatory and inhibitory neurons in the ‘matrices’ attribute.

get_perc_resp(pattern=1, n_type='EXC', dff_resp=False)[source]

Returns an array of the percentage of responsive neurons per across trials

peak_delay_amp()[source]

Calculate the zscore peak delay and peak amplitude for each neuron and each stimulation. The peak is the maximum amplitude when the responsivity is 1 or the minimum amplitude when the responsivity is -1. numpy.NaN is added to the matrix when the responsivity is 0.

This method updates the “Peak_delay” and “Peak_amplitude” matrices for the excitatory and inhibitory neurons in the “matrices” attribute.

responsivity(dff=False)[source]

Compute responsivity matrices for both excitatory and inhibitory neurons. For a given neuron and a given stimulation, one integer among the following is added to the matrix :

  • 1 if there is an increase in the neuron’s activity

  • 0 if there is no change in the neuron’s activity

  • -1 if there is a decrease in the neuron’s activity

This method updates the ‘Responsivity’ matrices for the excitatory and inhibitory neurons in the ‘matrices’ attribute.

zscore(dff)[source]

Computes the standardized zscore from the ΔF/F.

Parameters:

dff (numpy.ndarray) – delta f over f array from inh or exc

Returns:

zscore – zscore for one set of neurons (inh or exc)

Return type:

numpy.ndarray

class percephone.core.recording.RecordingAmplDet(input_path, starting_trial, rois_path, tuple_mesc=None, mean_f=False, correction=False, cache=True, iti='ITI2', habituation=False)[source]

Class for analyzing recording data with amplitude detection. Inherits from the Recording class.

analog

Analog file stored as a pandas DataFrame.

Type:

pandas.DataFrame

xls

bpod file stored as a pandas DataFrame.

Type:

pandas.DataFrame

stim_time

A 1D numpy.ndarray of the stimulation times in frames.

Type:

numpy.ndarray of int

stim_ampl

A 1D numpy.ndarray of the stimulation amplitudes.

Type:

numpy.ndarray of float TODO: why not int

stim_durations

A 1D numpy.ndarray of the stimulation’s durations

Type:

numpy.ndarray of float TODO: why not int

reward_time

A 1D numpy.ndarray of the reward times in frames.

Type:

numpy.ndarray of int

timeout_time

A 1D numpy.ndarray of the timeout (no-go times) in frames.

Type:

numpy.ndarray of int

lick_time

A 1D numpy.ndarray of the lick times in frames.

Type:

numpy.ndarray of int

detected_stim

A 1D numpy.ndarray of if the mouse responded to a stimulation.

Type:

numpy.ndarray of bool

mlr_labels_exc

TODO: to fill

mlr_labels_inh

TODO: to fill

json

Read of the file params_trials.json

Type:

list[dict]

zscore_exc

A 2D numpy.ndarray of the zscore of each excitatory neuron at each frame of the recording (nb neurons * nb frames)

Type:

numpy.ndarray of float

zscore_inh

A 2D numpy.ndarray of the zscore of each inhibitory neuron at each frame of the recording (nb neurons * nb frames)

Type:

numpy.ndarray of float

synchronization_with_iti(starting_trial, analog_s, correction, iti, habituation)[source]

Update the analog file with information on stimulus time, reward time and timeout time

Note

Get the ITI2, stimulus and reward time from the Excel Synchronize the ITI2 from the Excel with the ITI from the analog

Parameters:
  • file (analog) –

  • file

  • trials) (starting trial for the recording (relative to the behavioral) –

  • frequency (analog_s analog sampling) –

  • starting_trial

  • Output

  • ------

  • stimulus (Updated analog file (csv) with the) –

  • timeout

  • time (reward) –

zscore(dff)

Computes the standardized zscore from the ΔF/F.

Parameters:

dff (numpy.ndarray) – delta f over f array from inh or exc

Returns:

zscore – zscore for one set of neurons (inh or exc)

Return type:

numpy.ndarray