Modules Details
pyfiber.behavior module
The pyfiber.behavior module define two classes: Behavior and MultiBehavior, that extracts behavioral events from raw files. They possess a number of methods that are useful when dealing with complex experimental paradigm. Intervals corresponding to periods between specified timestamps can be automatically calculated by defining them in the configuration file.
- class pyfiber.behavior.Behavior(filepath, filetype=None, **kwargs)
Class extracting and analyzing behavioral data.
- Parameters:
filepath (
str) – filepath (by default must be a .dat file)filetype (
str) – must be set to user-defined format (by default takes the value of ‘BEHAVIOR_FILE_TYPE’ in the configuration filekwargs – arguments passed to _utils.PyFiber, the parent class (ex: verbosity=False)
- Variables:
filetype – input filetype (takes the default value defined in the config file)
filepath – data file filepath
df –
pandas.DataFramecontaining the extracted datastart – first timestamp of the data file, if the input is a csv and no start is provided, it takes the value 0.0
end – last timestamp of the data file, if the input is a csv file, there should be an ‘end’ column with a float value
<other> – all generated timestamps and intervals get added as instance attribute (and can be refered to their name as strings in most functions)
- property raw
Output the unprocessed data file.
- property total
Return the count for all extracted event (i.e. if events a,b and c are added, return the total count of a,b and c.)
- property data
Return the count for all extracted event for all calculated intervals. (i.e. if events a,b and c, and intervals A, B, C are added, return the count of a,b and c for each of the A, B, C intervals.)
- property description
- _extract(family, subtype, column, value)
Extract timestamps for counters from Imetronic file.
- Parameters:
family (
int) – data family (see Imetronic nomenclature)subtype (int) – data subtype
column (
str) – additional column precising event of interestvalue (int) – value needed in column to extract it
- Returns:
data corresponding to input parameters
- Return type:
pandas.DataFrame
- _create_imetronic_attributes()
Extract event specified in the configuration file, in the imetronic_events section.
This function gets called during instance initialization if the filetype is ‘IMETRONIC’ (see configuration file).
- _compute_attributes()
Create rule-based intervals and events as specified in the configuration file (in sections basic_intervals and custom)
- _translate(obj)
Translate strings into corresponding arrays.
- Parameters:
obj (
str) – name of the interval/event
Equivalent to a lookup in
self.__dict__with the addition of a call to thebehavior.set_nonfunction if the~sign is prepended to the string.
- _internal_selection(obj)
Transform string into corresponding data.
- Parameters:
obj (Any) – either the event/interval name or its data
- Returns:
object data as a list
- Return type:
list
- _graph(ax, obj, label=None, color=None, demo=True, unit='min', x_lim='default', alpha=1)
Internal function for plotting on a single axis.
- Parameters:
ax – axis on which to plot
obj – element to plot
label – figure label
color – plot color
demo – use the predifined style defined in the configuration file
unit – units for the x-axis (can be
'ms','s','min','h')x_lim – x-axis limits, by default from start to end
alpha – graph transparency
- _debug_interinj()
Return interinfusion time (between 2 consecutive pump activations).
Used to eliminate recording containing short interinfusion time.
- figure(obj, figsize='default', h=0.8, hspace=0, label_list=None, color_list=None, save=False, title=None, save_dpi=600, save_format=['png', 'pdf'], **kwargs)
Plot data.
- Parameters:
obj (
EventsorIntervals,str,dict) – data to plotsave – default is
False, filepath (without file extension)save_dpi – dpi if figure is saved
save_format – file extension for saving
- Returns:
matplotlib.pyplot.figurecontaining a eventplots or axvspan or a combination of both.
Main plotting function, calling
self._plotfor eachaxis, called itself byself.summary
- summary(demo=True, **kwargs)
Return a predifined graphical summary of main events and intervals.
- Parameters:
demo (
bool) – Demo mode (True). Provides a user defined summary of intervals and events. IfFalseplots everything.kwargs – Plotting arguments, passed to
self.figureandself._plot.
The data and the formating provided by the demo option can be configured in pyfiber.yaml.
- timestamps(events, interval='all', length=False, intersection=[], exclude=[], user_output=False)
Selects timestamps based on conditions.
- Parameters:
events (
strorEvents) – name or array of timestampsinterval (
str,List[str],List[Intervals],Intervals) – interval or intervals in which the timestamps must be contained, can be'all'intersection (
List[str],List[Intervals]) – intersection of intervals in which the timestamps must be containedexclude (
List[str],List[Intervals]) – interval or intervals in which the timestamps must not be containeduser_output (bool) – if
True, returns a tuple with all the user input data (for plotting purposes)length (Union[float, int, bool]) – distance from the start of the intervals defined in
intervalto be considered.
- Returns:
Timestamps or tuple with timestamps and considered intervals (depending on
user_output)- Return type:
Eventsortuple
- export_timestamps(events, interval='all', length=False, intersection=[], exclude=[], to_csv=True, graph=True, filename='default', start_TTL1=False, **kwargs)
User API for visualizing timestamp selection.
- Parameters:
events (
strorEvents) – name or array of timestampsinterval (
str,List[str],List[Intervals],Intervals) – interval or intervals in which the timestamps must be contained, can be'all'intersection (
List[str],List[Intervals]) – intersection of intervals in which the timestamps must be containedexclude (
List[str],List[Intervals]) – interval or intervals in which the timestamps must not be containedlength (Union[float, int, bool]) –
Wrapper for the
self.timestampsfunction, with added graphical representation and csv output.
- events(recorded=False, recorded_name='TTL1_ON', window=(0, 0))
Retrieve list of events.
- Parameters:
recorded (
bool) – only output events that are recorded(default value =False)recorded_name (
bool) – name of the attribute storing recorded intervals (default'TTL1_ON')window (tuple) – perievent analysis window
- Returns:
dictionnary with all events
- Return type:
dict
Note
Optionally only those which can be used in a perievent analysis (ie during the recording period and taking into account a perievent window).
- intervals(recorded=False, window=(0, 0))
Retrieve list of intervals.
- Parameters:
recorded (
bool) – only output events that are recorded(default value =False)recorded_name (
bool) – name of the attribute storing recorded intervals (default'TTL1_ON')window – perievent analysis window
- Returns:
dictionnary of all intervals
- Return type:
dict
Note
Optionally only those which can be used in a perievent analysis (ie during the recording period and taking into account a perievent window).
- what_data(plot=True, figsize=(20, 40))
Return dataframe summarizing the IMETRONIC dat file.
- Parameters:
plot (
bool) – return plotted data by ID tuplefigsize – plot size (default=(20,40), see
matplotlibdocumentation)
- get(name)
Extract dataframe section (IMETRONIC format).
- Parameters:
name (
strortuple) – name or ID of IMETRONIC data family- Returns:
pandas.DataFramecorresponding to selected counter name (‘name’) or tuple (‘idtuple’).
- movement(figsize=(20, 10), cmap='seismic', save=False, save_dpi=600, save_format=['png', 'pdf'])
Show number of crossings as a heatmap.
- Parameters:
figsize (
Tuple[int, int]) – size of plotcmap (
str) – color map (seematplotlib)save – default is
False, filepath (without file extension)save_dpi – dpi if figure is saved
save_format – file extension for saving
- BEHAVIOR_FILE_TYPE = 'IMETRONIC'
- basic_intervals = {'HLED': [['ON_OFF', 'both', ['hled_on', 'hled_off']], 'Houselight on (interval)'], 'LED1': [['ON_OFF', 'both', ['led1_on', 'led1_off']], 'CS light on (interval)'], 'LED2': [['ON_OFF', 'both', ['led2_on', 'led2_off']], 'Drug light on (interval)'], 'TTL1': [['ON_OFF', 'both', ['ttl1_on', 'ttl1_off']], 'TTL1 sending (interval)']}
- behavior_time_ratio = 1000
- csv_events = {'TTL1': [['timestamp', 'DI/O-1', 'Time(s)'], 'TTL1'], 'TTL2': [['timestamp', 'DI/O-2', 'Time(s)'], 'TTL2'], 'TTL3': [['timestamp', 'DI/O-3', 'Time(s)'], 'TTL3'], 'TTL4': [['timestamp', 'DI/O-4', 'Time(s)'], 'TTL4']}
- custom = {'DARK': [['INTERSECTION', ['HLED_OFF', 'LED1_OFF', 'LED2_OFF']], 'No lights on'], 'DNI': [['NEAR_EVENT', 'DARK', 'inj1', 5], 'No lights on, close to an injection'], 'DRP': [['NEAR_EVENT', 'HLEDOFF_NODARK', 'led2_on', 1], 'Period with HLED off and near a led2 switch on'], 'DRP_INJ': [['CONTAINS', 'DRP', 'inj1'], 'Drug period that is close to an injection'], 'DRP_LONG': [['DURATION', 'DRP', '>', 600], 'Drug periods longer than 600 seconds'], 'DRUG': [['UNION', ['DRP_LONG', 'DRP_INJ']], 'Drug periods'], 'DRUG_NOTO': [['INTERSECTION', ['DRUG', '~TIMEOUT']], 'Drug period without timeouts'], 'D_n': [['GENERATIVE', 'DRUG'], 'N-th drug period'], 'HLEDOFF_NODARK': [['INTERSECTION', ['HLED_OFF', '~NOTO_DARK']], 'HLED off, excluding non-timeout-dark periods'], 'ND_first': [['NEAR_EVENT', 'HLED_ON', 'switch_1', 1], 'First ND period (excluding the first one in case of NDpre paradigm'], 'ND_n': [['GENERATIVE', 'HLED_ON'], 'No drug period (HLED on)'], 'NOTO_DARK': [['INTERSECTION', ['DARK', '~TIMEOUT']], 'No lights on, not a timeout'], 'TIMEOUT': [['UNION', ['LED1_ON', 'TO_DARK']], 'CS light on + subsequent dark period'], 'TO_DARK': [['DURATION', 'DNI', '<', 45], 'No lights on, close to an injection, shorter than 45s'], 'hled_on_end': [['boundary', 'end', 'HLED_ON'], 'Ends of each no drug periods'], 'hled_on_start': [['boundary', 'start', 'HLED_ON'], 'Starts of each no drug periods'], 'inj_first': [['indexed', 'inj1', 1], 'First injection'], 'noto_dark_end': [['boundary', 'end', 'NOTO_DARK'], "End of dark period (that isn't a timeout)"], 'np1_ND_first': [['iselement', 'np1', 'ND_first'], 'Active nosepokes during the first ND period'], 'np1_NDfirst_1': [['indexed', 'np1_ND_first', 1], 'First active nosepoke of first ND period'], 'np1_n': [['generative2', ['D_n', 'np_effective'], 5], 'N-th effective nosepoke inside each drug period'], 'np2_ND_first': [['iselement', 'np2', 'ND_first'], 'Inactive nosepokes during the first ND period'], 'np2_NDfirst_1': [['indexed', 'np2_ND_first', 1], 'First inactive nosepoke of first ND period'], 'np_HF_NOTO': [['iselement', 'np1', 'DRUG_NOTO'], 'Active nosepoke not during HLED ON and not during full timeout'], 'np_effective': [['iselement', 'np_HF_NOTO', 'LED2_ON'], 'Active nosepoke that is part of the FR series'], 'npt': [['combination', ['np1', 'np2']], 'All nosepokes (active and inactive)'], 'npt_ND_first': [['iselement', 'npt', 'ND_first'], 'Nosepokes during the first ND period'], 'npt_NDfirst_1': [['indexed', 'npt_ND_first', 1], 'First nosepoke of first ND period'], 'rec_start': [['indexed', 'ttl1_on', 1], 'Start of the recording'], 'switch_1': [['indexed', 'switch_between', 1], 'First of the switches between ND and D that are between t+100s and t+3400s'], 'switch_1_D': [['indexed', 'switch_between_D', 1], 'No to-d First of the switches between ND and D that are between t+100s and t+3400s'], 'switch_between': [['timerestricted', 'switch_dto_nd', [100, 3400]], 'Switch between ND and D that are between t+100s and t+3400s'], 'switch_between_D': [['timerestricted', 'switch_d_nd', [100, 3400]], 'No to-d Switch between ND and D that are between t+100s and t+3400s'], 'switch_d_nd': [['iselement', 'hled_on_start', 'DRUG_NOTO'], 'Switch from drug to no drug (ie excluding timeout to drug)'], 'switch_dark_d1': [['iselement', 'noto_dark_end', 'LED2_ON'], 'Switch from dark to D1'], 'switch_dto_nd': [['combination', ['switch_d_nd', 'switch_to_nd']], 'Switch of either drug/timeout to no drug'], 'switch_nd1': [['boundary', 'end', 'ND_first'], 'First ND-D switch.'], 'switch_nd_d': [['iselement', 'hled_on_end', 'LED2_ON'], 'Switch from ND to D'], 'switch_to_nd': [['iselement', 'hled_on_start', 'TIMEOUT'], 'Switch from timeout to no drug']}
- elements = {'DARK': [False, 'DARK', 'k'], 'HLED_OFF': [True, 'Drug Period', '#069AF3'], 'HLED_ON': [True, 'No Drug Period', 'gold'], 'LED1_OFF': [False, 'LED1_OFF', ['darkgray', 'darkgrey']], 'LED1_ON': [True, 'Conditioned Stimulus', 'goldenrod'], 'LED2_OFF': [False, 'LED2_OFF', 'slategrey'], 'LED2_ON': [True, ' Drug Light On', 'slategrey'], 'NOTO_DARK': [False, 'NOTO_DARK', 'black'], 'TIMEOUT': [True, 'Time outs', 'k'], 'TO_DARK': [False, 'TO_DARK', 'olivedrab'], 'TTL1_ON': [True, 'Fiber Photometry Recordings', 'g'], 'all': [True, 'Session', 'b'], 'inj1': [True, 'Injections', 'k'], 'np1': [True, 'Active Nosepokes', 'r'], 'np2': [True, 'Inactive Nosepokes', 'b'], 'switch_d_nd': [False, 'Switch from D to ND', 'r'], 'switch_nd_d': [False, 'Switch from ND to D', 'b'], 'switch_to_nd': [False, 'Switch from TO to ND', 'r']}
- imetronic_events = {'hled_off': [['conditional', [1, 1], ['_P', 0]], 'houselight off'], 'hled_on': [['conditional', [1, 1], ['_P', 1]], 'houselight on'], 'inj1': [['conditional', [6, 1], ['_L', 1]], 'Injection'], 'led1_off': [['conditional', [1, 2], ['_P', 0]], 'CS light off'], 'led1_on': [['conditional', [1, 2], ['_P', 1]], 'CS light on'], 'led2_off': [['conditional', [1, 3], ['_P', 0]], 'Drug light off'], 'led2_on': [['conditional', [1, 3], ['_P', 1]], 'Drug light on'], 'np1': [['conditional', [3, 1], ['_V', 1]], 'Active Nosepoke'], 'np2': [['conditional', [3, 2], ['_V', 1]], 'Inactive nosepoke'], 'ttl1_off': [['conditional', [15, 1], ['_L', 0]], 'Recording TTL off'], 'ttl1_on': [['conditional', [15, 1], ['_L', 1]], 'Recording TTL on'], 'x_coordinates': [['simple', [9, 1], '_X'], 'X coordinates'], 'xy_timestamps': [['simple', [9, 1], 'TIME'], 'Timestamps for coordinates'], 'y_coordinates': [['simple', [9, 1], '_Y'], 'Y coordinates']}
- class pyfiber.behavior.MultiBehavior(folder, fileformat='dat', **kwargs)
Class for multiple behavioral file analysis
- Parameters:
folder (
str) – folder containing data files (the explorer recurse inside subfolders as well)fileformat (
str) – format of files to be included (default is ‘dat’)kwargs – keyword arguments passed to
pyfiber.Behaviorinstances
- Variables:
behavior_time_ratio – conversion from file unit to seconds, default 1000 (inherited from
_utils.PyFiberwhich directly reads it from the configuration file)folder – same as folder parameter
fileformat – same as fileformat parameter
paths – list of all found filepaths
filepath – list of all filepaths (this is directly extracted from each member of sessions)
names – list of all animal names (by default same as filepath)
number – number of sessions
sessions – dictionnary containing all sessions as
pyfiber.Behaviorinstances.df – list of behavioral data dataframes (see
pyfiber.Behavior(*).df)start – start for all files, as a list (see
pyfiber.Behavior(*).start)end – end for all files, as a list (see
pyfiber.Behavior(*).end)<other> – all created attributed and intervals, as a
pandas.DataFramewith filenames as index.
- _savgol(data, window=10, polyorder=3, nosmoothing=False)
- _cnt(attribute)
Return the number of events per second for a defined event for all sessions:
- Parameters:
attribute (str) – event name
- Returns:
Dictionnary with ‘filename’ and array with the number of events for each second
- Return type:
dict
- count(attribute)
Return the number of events per second for a defined event for all sessions:
- Parameters:
attribute (str) – event name
- Returns:
Data frame containing with number of events for each second for each animal
- Return type:
pandas.DataFrame
Note
Similar to private method
self._cntbut return the data as a dataframe.
- cumul(attribute, plot=True, figsize=(20, 15), save=False, save_dpi=600, save_format=['png', 'pdf'], legend=False, **kwargs)
Return the cumulative sum of a given event for all animals.
- Parameters:
attribute (str) – event name
plot (
bool) – return a plotfigsize (Tuple[int, int]) – figure size (passed to matplolib via a DataFrame)
save – default is
False, filepath (without file extension)save_dpi – dpi if figure is saved
save_format – file extension for saving
legend – show session names as labels
- Kwargs:
keyword arguments passed to the plot function of a
pandas.DataFrame- Returns:
Data Frame containing the cumulative sum, a plot (optional)
- Return type:
pandas.DataFrame
- show_rate(attribute, interval='HLED_ON', binsize=120, percentiles=[15, 50, 85], figsize=(20, 10), interval_alpha=0.3, save=False, save_dpi=600, save_format=['png', 'pdf'], legend=False, **kwargs)
Show rate for all session for any given event.
- Parameters:
attribute (
str) – event nameinterval (
strorbool) – interval shown on the graph (optional)binsize (
int) – binsize in secondspercentiles (
list) – optional plot with percentilesfigsize (
tuple) – figure sizeinterval_alpha (float) – transparency value for the interval plot
save (bool) – default is
False, filepath (without file extension)save_dpi – dpi if figure is saved
save_format – file extension for saving
legend (bool) – show session names as labels
- Rtype interval_alpha:
float
- summary(title=True, **kwargs)
Output the session summary for all sessions:
- Parameters:
kwargs – keyword arguments passed to
pyfiber.Behavior(*).summarytitle (Union[bool, list]) –
Note
See documentation for
pyfiber.Behavior
- pyfiber.behavior.Events
alias of
ndarray
- pyfiber.behavior.select_interval_by_duration(interval, condition)
Select interval based on their duration.
- Parameters:
interval (
Intervals) – interval as a list of tuplescondition (list) – user inputed condition (e.g.
['<',25])type –
list
- Returns:
Filtered intervals
- Return type:
Intervals
This function selects intervals by their duration, the conditional argument is a list containing the operator and a float (it mainly reads from the configuration file).
- pyfiber.behavior.generate_interval(on, off, end)
Compute intervals based on a two lists of right and left limits. Discards redundant values (i.e. if two consecutive right limits are provided).
- Parameters:
on (
Events) – left limits of desired intervals.off (
Events) – right limits of desired intervals.end (float) –
- Returns:
computed intervals
- Return type:
Intervals
# This function is primarly used internally by the Behavior class, but can be directly invoked >> on = [0., 5., 20., 40] >> off = [10., 11., 30., 50] # 5 and 11 are redundant and should thus be eliminated >> end = 60 # The end should be inputed, if the last command is off, the interval can thus end at the end of the experiment >> pyfiber.behavior.generate_interval(on,off,end) [(0.0, 10.0), (20.0, 30.0), (40.0, 50.0)]
Warning
This function is based on the metaphor of a light switch, hence the names ‘on’ and ‘off’. However, a number of intervals can be computed with the same principle. Importantly, it assumes that the state is ‘off’ at the beginning of the experiment. If the interval of interest is by default on at the beginning of the experiment, the complementary interval should be computed and its complement (the interval of interest) itself obtained with the
behavior.set_nonfonction.
- pyfiber.behavior.interval_is_close_to(intervals, events, nearness, closed='right')
Return a list of intervals each near of at least one event from the specified event array.
- Parameters:
intervals (
Intervals) – evaluated intervalsevents (
Events) – events of which intervals must be nearnearness (
float) – maximum distance from interval to events (in seconds)closed (
str) – seepandas.IntervalArrayfor details
- Returns:
selected intervals
- Return type:
Intervals
This function is used to calculate some of the custom events. For example, if the user wishes to isolate timestamps of particular events only if they happen near a period where a certain light is on.
- pyfiber.behavior.element_of(event_array, intervals, is_element=True, boolean=False)
Return events that are elements (or are not) of specified intervals.
- Parameters:
event_array (
Events) – input list of event timestampsintervals (
Intervals) – intervals that should (or shouldn’t) include eventsis_element (
bool) –Trueif intervals should be in intervals,Falseif they should’tboolean (
bool) – ifTrue, the function return type is a boolean, else it is the list of timestamps that pass the condition
- Returns:
Either the timestamps or a boolean
- Return type:
Eventsorbool
- pyfiber.behavior.set_union(*sets)
Find union of any number of Intervals.
- Parameters:
sets (
Intervals) – intervals to be united.- Returns:
Union of all inputed Intervals
- Return type:
Intervals
- pyfiber.behavior.set_non(A, end, start=0)
Returns the complement of a collection of sets.
- Parameters:
A (
Intervals) – Intervals of which to compute the complementend (
float) – End of experimentstart (
float) – start of experiment, default value is 0
- Returns:
Complement of A
- Return type:
Intervals
pyfiber.fiber module
This module mainly defines the Fiber Class.
Most of the function are tied to the class in order to take advantage of attributes to set default values.
However, important functions such as the fiber.normalize_signal and fiber.detect_peaks are defined outside
the class as they can be useful on their own.
- class pyfiber.fiber.Fiber(filepath, name='default', ID=None, alignment=0, filetype=None, **kwargs)
Extract and analyse fiberphotometry data.
- Variables:
data – dataframe with all data from data file
recordings – all separate recording
number_of_recordings – number of separate recordings (see note below)
peaks – dictionnary containing a data frame with peak data (timestamps, dF/F, zscore) for all recordings
rate (sampling) – mean sampling rate accross recordings
full_time – array containing all timestamps from the data file
rec_intervals – time intervals for each recording
rec_length – duration of each recording (as a list)
df – raw data as a
pandas.DataFramencl – nomenclature for reading columns, defined in the config file
columns – name of the retrieved columns (i.e. time, signal, control)
raw_columns – name of the original columns
ID – see parameters
alignment – see parameters
filepath – see parameters
filetype – see parameters
name – see parameters
FIBER_FILE_TYPE – (from
_utils.PyFiber) system file type (default: DORIC_CSV)split_recordings – (from
_utils.PyFiber) see note belowsplit_treshold – (from
_utils.PyFiber) treshold for splitting data into recording (e.g. 10 is 10 times the mean intersample distance)min_sample_per_rec – (from
_utils.PyFiber) minimun number of samples for a split to be considered a recordings (ignores one sample recordings that are bugs)trim_recording – (from
_utils.PyFiber) number of seconds automatically removed from recording start (to avoid the LED artifact)perievent_window – (from
_utils.PyFiber) default perievent analysis windowdefault_norm – (from
_utils.PyFiber) default normalization method (‘F’ or ‘Z’, see detail inpyfiber.fiber.normalize_signal)peak_window – (from
_utils.PyFiber) length in seconds of the peak detection windowpeak_distance – (from
_utils.PyFiber) minimum distance between peaks (to avoid false positives), in millisecondspeak_zscore – (from
_utils.PyFiber) full or bins choose if post normalization standardization should be done on the full recordings or for each windowpeak_baseline_MAD – (from
_utils.PyFiber) first treshold for peak analysispeak_peak_MAD – (from
_utils.PyFiber) second treshold for peak analysis
- Parameters:
filepath (
str) – fiber photometry data file pathname (
str) – session name (default is filepath without the extension)ID (hashable) – animal identifier
alignment (
float) – optional shift in the timestampsfiletype (
str) – data file type, defaults to Doric
Note
Alignment can be used if the exact time of recording start is provided by a behavioral system. It simply shift every timestamps of the fiber file accordingly.
Note
In the fiber photometry data file, locations where the timestamps are discontinuous define breakpoints where the data is split into recordings. To change this behavior, simply add
split_recordings = Falseat instantiation, or modify the configuration file :>> import pyfiber >> f = pyfiber.Fiber('filepath.csv', split_recordings = False)
# ~/.pyfiber/pyfiber.yaml [...] FIBER: split_recordings: False [...]
- _find_rec(timestamp)
Find recording number corresponding to inputed timestamp.
- Parameters:
timestamp (float) – timestamp of which to find the recording number if any
- Return type:
list
- _read_file(filepath, alignment=0)
Read file and align the timestamps if specified.
- Parameters:
filepath – the data file path
alignment – offset in seconds to align fiber datafile to behavioral data
- Return type:
DataFrame
- _extract_data()
Extract raw fiber data from Doric system.
- Return type:
DataFrame
- _split_recordings()
Cut at timestamp jumps.
The jumps are defined by a step greater than N times the mean sample space (defined in pyfiber.yaml).
- Return type:
dict
- plot(which='all', method='default', figsize=(20, 20), raw_label=['Ca-dependant', 'isosbestic'], norm_label='Normalized signal', xlabel='Time (s)', ylabel_raw='Signal (mV)', ylabel_norm='Signal (%)', title='Recording', hspace=0.5)
Plot fiber data.
- Parameters:
which (Union[str, int, List[int]]) – which recording should be plotted ; default is ‘all’
method (str) – normalization method (see
fiber.normalize_signalfor details)figsize (tuple) – figure size
raw_label (list) – plotting labels for the non normalized data
norm_label (str) – plotting labels for the normalized data
xlabel (str) – label for the x-axis
ylabel_raw (str) – y-axis label for non-normalized data
ylabel_norm (str) – y-axis label for normalized data
title (str) – plot title
hspace (float) – horizontal space between graphs
- Return type:
None
- to_csv(recordings='all', auto=True, columns=None, column_names=None, prefix='default')
Export data to csv.
- Parameters:
recording – defines which recording to export (default is all)
auto (bool) – automatically export signal and isosbestic separately with sampling_rate
columns (Optional[List[str]]) – export specific columns with their timestamps
columns_names – change default name for columns in outputted csv (the list must correspond to the column list)
prefix (str) – filename prefix (default is ‘<raw filename><recording number><data column name>’’)
recordings (Union[str, int, List[int]]) –
column_names (Optional[List[str]]) –
- Return type:
None
- FIBER_FILE_TYPE = 'DORIC'
- default_norm = 'F'
- get(column, recording=1, add_time=False, as_df=False)
Extracts a data array from a specific column of a recording.
- Parameters:
column (str) – dataframe column to extract (list of columns:
self.columns)add_time (bool) – if
Truereturn a 2D array (stack of time and signal)as_df (bool) – if
Truereturn data as a data frame (add_time will automatically be set toTrue)recording (int) –
- Return type:
Union[DataFrame, ndarray]
Note
This function is a shortcut to
<obj>.recordings[<rec_number>][<'column_name'>].to_numpy()with multiple queries (time) as an option.
- min_sample_per_rec = 5
- peak_baseline_MAD = 2
- peak_distance = '50ms'
- peak_peak_MAD = 3
- peak_window = 10
- peak_zscore = 'full'
- perievent_window = [1.0, 1.0]
- split_recordings = True
- split_treshold = 10
- trim_recording = 1.0
- norm(rec=1, method='default', add_time=True)
Normalize data with specified method.
- Parameters:
rec (int) – recording number
method (str) – normalization method (see :ref`note <n>`)
add_time (bool) – include timestamps with output
- Return type:
ndarray
Note
This method is a wrapper of the
fiber.normalize_signalfunction, see its documentation for more details.
- _detect_peaks(rec=False, arr=[], time=[], signal=[], window='default', distance='default', plot=True, figsize=(30, 10), zscore='full', bMAD='default', pMAD='default', **kwargs)
Detect peaks in a normalized fiberphotometry signal.
API for
fiber.detect_peaks, with class default. :param arr: numpy array with timestamps in first column and signal values in second column :param time: timestamps :param signal: fiber photometry signal :param window: size of each succesive bins were peaks are computed (default is 10s) :param distance: minimum distance between successive peaks (in milliseconds), see note :param plot: output a plot :param figsize: figure size :param zscore: defines if standardisation should occur at the bin level or the whole recording level :param bMAD: baseline treshold (all timepoint belowbMADtimes the MAD are removed) :param pMAD: peak treshold (peaks have to be at leastpMADtimes higher than the computed baseline) :param kwargs: keyword argument passed toscipy.signal.find_peaks, see noteNote
The final peak detection is handled by
scipy.signal.find_peaks. By default, distance, provided in string format in milliseconds (ex: ‘50ms’) is converted in a number of samples based on the provided timestamp array. Additionnally, any keyword argument catched by kwargs is passed tofind_peaksso more precise criteria can be used.- Parameters:
window (Union[str, float]) –
distance (str) –
plot (bool) –
figsize (tuple) –
zscore (str) –
bMAD (Union[str, float]) –
pMAD (Union[str, float]) –
- Return type:
DataFrame
- plot_transients(value='zscore', figsize=(20, 20), rec='all', colors='k', alpha=0.3, save=False, save_dpi=600, save_format=['png', 'pdf'], **kwargs)
Show graphical representation of detected transients with their amplitude.
- Parameters:
value (str) – show either Z-scores (
'zscore) or \(\frac{\Delta F}{F_0}\) ('dF/F')figsize (tuple) – figure size
rec (Union[str, int]) – recordings to plot, default is all
colors (str) – bar colors
alpha (float) – transparency
kwargs – keyworg arguments passed to
matplotlibsave – default is
False, filepath (without file extension)save_dpi – dpi if figure is saved
save_format – file extension for saving
- Return type:
None
- peakFA(a, b)
Return peak analysis: frequency and amplitude results for given interval.
- Parameters:
a (float) – left limit of the interval
b (float) – right limit of the interval
- Returns:
Mean frequency, mean peak amplitude, max peak amplitude, full peak data frame (all peaks from the interval)
- Return type:
dict
- pyfiber.fiber.normalize_signal(signal, control, method)
Normalize the signal using a control channel.
- Parameters:
signal (
np.ndarray) – calcium-dependant signalcontrol (
np.ndarray) – isosbestic signalmethod (str) – normalization method
- Return type:
ndarray
Note
Two normalization method can be used.
'F'is the standard \(\frac{\Delta F}{F_0}\).'Z'is the z-score difference of signal and control.
pyfiber.analysis module
- class pyfiber.analysis.Session(behavior, fiber, ID=None, **kwargs)
Create object containing both fiber recordings and behavioral files.
- classmethod from_folder(folderpath, fiber_marker='.csv', behavior_marker='.dat', **kwargs)
Create session object from folder.
- Parameters:
folderpath (str) – folder path
fiber_marker (str) – string present only in fiber data file (default is
'.csv')behavior_marker (str) – string present only in fiber data file (default is
'.dat')kwargs – keyword arguments passed to __init__
- _sample(time_array, event_time, window)
Get indices of a timeseries sample of the recording.
- Parameters:
time_array (ndarray) – an array of timestamp
event_time (float) – event of interest
window (tuple) – time window left and right of the event of interest
- Returns:
indices for the start, event and end of the sample, relative to the input array
- Return type:
tuple
- _recorded_timestamps(events, window, **kwargs)
Return analyzable timestamps (i.e. both recorded and not overlapping the perievent window on the edges).
- Parameters:
events (Union[str, List[str]]) – name of events of interest
window (tuple) – perievent analysis window
kwargs – keyword arguments passed on to
pyfiber.Behavior.timestamps
- Returns:
array of timestamps corresponding to input and occuring during recorded intervals
- Return type:
ndarray
- events(**kwargs)
See
pyfiber.Behavior.events.- Parameters:
recorded (
bool) – only output events that are recorded(default value =False)recorded_name (
bool) – name of the attribute storing recorded intervals (default'TTL1_ON')window – perievent analysis window
- Returns:
dictionnary with all events
- Return type:
dict
- intervals(**kwargs)
See
pyfiber.Behavior.intervals- Parameters:
recorded (
bool) – only output events that are recorded(default value =False)recorded_name (
bool) – name of the attribute storing recorded intervals (default'TTL1_ON')window – perievent analysis window
- Returns:
dictionnary of all intervals
- Return type:
dict
- analyze(event_time, window='default', norm='default')
Return Analysis object, related to defined perievent window.
- Parameters:
event_time (float) – event of interest timestamp
window (Union[str, tuple]) – perievent analysis window
norm (str) – normalization method
- Returns:
object containing all the analysis data and methods to display them
- Return type:
object
Note
The normalization parameter correspond the process of taking into account the
- update_window(new_window)
Change perievent window.
- plot(what='events')
Plot either events or intervals.
Tests if they happen within recording timeframe.
- BEHAVIOR_FILE_TYPE = 'IMETRONIC'
- FIBER_FILE_TYPE = 'DORIC'
- basic_intervals = {'HLED': [['ON_OFF', 'both', ['hled_on', 'hled_off']], 'Houselight on (interval)'], 'LED1': [['ON_OFF', 'both', ['led1_on', 'led1_off']], 'CS light on (interval)'], 'LED2': [['ON_OFF', 'both', ['led2_on', 'led2_off']], 'Drug light on (interval)'], 'TTL1': [['ON_OFF', 'both', ['ttl1_on', 'ttl1_off']], 'TTL1 sending (interval)']}
- behavior_time_ratio = 1000
- csv_events = {'TTL1': [['timestamp', 'DI/O-1', 'Time(s)'], 'TTL1'], 'TTL2': [['timestamp', 'DI/O-2', 'Time(s)'], 'TTL2'], 'TTL3': [['timestamp', 'DI/O-3', 'Time(s)'], 'TTL3'], 'TTL4': [['timestamp', 'DI/O-4', 'Time(s)'], 'TTL4']}
- custom = {'DARK': [['INTERSECTION', ['HLED_OFF', 'LED1_OFF', 'LED2_OFF']], 'No lights on'], 'DNI': [['NEAR_EVENT', 'DARK', 'inj1', 5], 'No lights on, close to an injection'], 'DRP': [['NEAR_EVENT', 'HLEDOFF_NODARK', 'led2_on', 1], 'Period with HLED off and near a led2 switch on'], 'DRP_INJ': [['CONTAINS', 'DRP', 'inj1'], 'Drug period that is close to an injection'], 'DRP_LONG': [['DURATION', 'DRP', '>', 600], 'Drug periods longer than 600 seconds'], 'DRUG': [['UNION', ['DRP_LONG', 'DRP_INJ']], 'Drug periods'], 'DRUG_NOTO': [['INTERSECTION', ['DRUG', '~TIMEOUT']], 'Drug period without timeouts'], 'D_n': [['GENERATIVE', 'DRUG'], 'N-th drug period'], 'HLEDOFF_NODARK': [['INTERSECTION', ['HLED_OFF', '~NOTO_DARK']], 'HLED off, excluding non-timeout-dark periods'], 'ND_first': [['NEAR_EVENT', 'HLED_ON', 'switch_1', 1], 'First ND period (excluding the first one in case of NDpre paradigm'], 'ND_n': [['GENERATIVE', 'HLED_ON'], 'No drug period (HLED on)'], 'NOTO_DARK': [['INTERSECTION', ['DARK', '~TIMEOUT']], 'No lights on, not a timeout'], 'TIMEOUT': [['UNION', ['LED1_ON', 'TO_DARK']], 'CS light on + subsequent dark period'], 'TO_DARK': [['DURATION', 'DNI', '<', 45], 'No lights on, close to an injection, shorter than 45s'], 'hled_on_end': [['boundary', 'end', 'HLED_ON'], 'Ends of each no drug periods'], 'hled_on_start': [['boundary', 'start', 'HLED_ON'], 'Starts of each no drug periods'], 'inj_first': [['indexed', 'inj1', 1], 'First injection'], 'noto_dark_end': [['boundary', 'end', 'NOTO_DARK'], "End of dark period (that isn't a timeout)"], 'np1_ND_first': [['iselement', 'np1', 'ND_first'], 'Active nosepokes during the first ND period'], 'np1_NDfirst_1': [['indexed', 'np1_ND_first', 1], 'First active nosepoke of first ND period'], 'np1_n': [['generative2', ['D_n', 'np_effective'], 5], 'N-th effective nosepoke inside each drug period'], 'np2_ND_first': [['iselement', 'np2', 'ND_first'], 'Inactive nosepokes during the first ND period'], 'np2_NDfirst_1': [['indexed', 'np2_ND_first', 1], 'First inactive nosepoke of first ND period'], 'np_HF_NOTO': [['iselement', 'np1', 'DRUG_NOTO'], 'Active nosepoke not during HLED ON and not during full timeout'], 'np_effective': [['iselement', 'np_HF_NOTO', 'LED2_ON'], 'Active nosepoke that is part of the FR series'], 'npt': [['combination', ['np1', 'np2']], 'All nosepokes (active and inactive)'], 'npt_ND_first': [['iselement', 'npt', 'ND_first'], 'Nosepokes during the first ND period'], 'npt_NDfirst_1': [['indexed', 'npt_ND_first', 1], 'First nosepoke of first ND period'], 'rec_start': [['indexed', 'ttl1_on', 1], 'Start of the recording'], 'switch_1': [['indexed', 'switch_between', 1], 'First of the switches between ND and D that are between t+100s and t+3400s'], 'switch_1_D': [['indexed', 'switch_between_D', 1], 'No to-d First of the switches between ND and D that are between t+100s and t+3400s'], 'switch_between': [['timerestricted', 'switch_dto_nd', [100, 3400]], 'Switch between ND and D that are between t+100s and t+3400s'], 'switch_between_D': [['timerestricted', 'switch_d_nd', [100, 3400]], 'No to-d Switch between ND and D that are between t+100s and t+3400s'], 'switch_d_nd': [['iselement', 'hled_on_start', 'DRUG_NOTO'], 'Switch from drug to no drug (ie excluding timeout to drug)'], 'switch_dark_d1': [['iselement', 'noto_dark_end', 'LED2_ON'], 'Switch from dark to D1'], 'switch_dto_nd': [['combination', ['switch_d_nd', 'switch_to_nd']], 'Switch of either drug/timeout to no drug'], 'switch_nd1': [['boundary', 'end', 'ND_first'], 'First ND-D switch.'], 'switch_nd_d': [['iselement', 'hled_on_end', 'LED2_ON'], 'Switch from ND to D'], 'switch_to_nd': [['iselement', 'hled_on_start', 'TIMEOUT'], 'Switch from timeout to no drug']}
- default_norm = 'F'
- elements = {'DARK': [False, 'DARK', 'k'], 'HLED_OFF': [True, 'Drug Period', '#069AF3'], 'HLED_ON': [True, 'No Drug Period', 'gold'], 'LED1_OFF': [False, 'LED1_OFF', ['darkgray', 'darkgrey']], 'LED1_ON': [True, 'Conditioned Stimulus', 'goldenrod'], 'LED2_OFF': [False, 'LED2_OFF', 'slategrey'], 'LED2_ON': [True, ' Drug Light On', 'slategrey'], 'NOTO_DARK': [False, 'NOTO_DARK', 'black'], 'TIMEOUT': [True, 'Time outs', 'k'], 'TO_DARK': [False, 'TO_DARK', 'olivedrab'], 'TTL1_ON': [True, 'Fiber Photometry Recordings', 'g'], 'all': [True, 'Session', 'b'], 'inj1': [True, 'Injections', 'k'], 'np1': [True, 'Active Nosepokes', 'r'], 'np2': [True, 'Inactive Nosepokes', 'b'], 'switch_d_nd': [False, 'Switch from D to ND', 'r'], 'switch_nd_d': [False, 'Switch from ND to D', 'b'], 'switch_to_nd': [False, 'Switch from TO to ND', 'r']}
- imetronic_events = {'hled_off': [['conditional', [1, 1], ['_P', 0]], 'houselight off'], 'hled_on': [['conditional', [1, 1], ['_P', 1]], 'houselight on'], 'inj1': [['conditional', [6, 1], ['_L', 1]], 'Injection'], 'led1_off': [['conditional', [1, 2], ['_P', 0]], 'CS light off'], 'led1_on': [['conditional', [1, 2], ['_P', 1]], 'CS light on'], 'led2_off': [['conditional', [1, 3], ['_P', 0]], 'Drug light off'], 'led2_on': [['conditional', [1, 3], ['_P', 1]], 'Drug light on'], 'np1': [['conditional', [3, 1], ['_V', 1]], 'Active Nosepoke'], 'np2': [['conditional', [3, 2], ['_V', 1]], 'Inactive nosepoke'], 'ttl1_off': [['conditional', [15, 1], ['_L', 0]], 'Recording TTL off'], 'ttl1_on': [['conditional', [15, 1], ['_L', 1]], 'Recording TTL on'], 'x_coordinates': [['simple', [9, 1], '_X'], 'X coordinates'], 'xy_timestamps': [['simple', [9, 1], 'TIME'], 'Timestamps for coordinates'], 'y_coordinates': [['simple', [9, 1], '_Y'], 'Y coordinates']}
- min_sample_per_rec = 5
- peak_baseline_MAD = 2
- peak_distance = '50ms'
- peak_peak_MAD = 3
- peak_window = 10
- peak_zscore = 'full'
- perievent_window = [1.0, 1.0]
- split_recordings = True
- split_treshold = 10
- trim_recording = 1.0
- class pyfiber.analysis.MultiSession(folder, debug=0.8, **kwargs)
Group analyses or multiple events for single subject.
- Parameters:
folder – path of the main folder containing session folders
- Variables:
folder – path of the folder
sessions – dictionnary containing
Sessioninstances for each sessionremoved – list of removed file (if debug is set and a problem was detected)
names – subfolder nmaes, ideally reflecting session names
details – extracted session details from folder names (if set in the configuration file)
Input file structure# folder and filenames can vary main_folder/ ├── session_1/ │ ├── behavior_1.dat │ └── fiber_1.csv ├── session_2/ │ ├── behavior_2.dat │ └── fiber_2.csv ├── session_3/ │ ├── behavior_3.dat │ └── fiber_3.csv ├── session_4/ │ ├── behavior_4.dat │ └── fiber_4.csv ...
- _import_folder(folder)
- _getID()
- show_rates(**kwargs)
Show rates for specified events.
- analyze(events, window='default', norm='default', sessions='all', save=False, save_dpi=600, save_format=['png', 'pdf'], **kwargs)
Analyze specific events.
events : ex: ‘np1’ window=’default’ : peri-event window (default is specified in config.yaml) norm=’default’ : normalization method used
- compare_behavior(attribute, save=False, save_dpi=600, save_format=['png', 'pdf'])
Compare behavior (input should be event name)
- Parameters:
save – default is
False, filepath (without file extension)save_dpi – dpi if figure is saved
save_format – file extension for saving
- BEHAVIOR_FILE_TYPE = 'IMETRONIC'
- FIBER_FILE_TYPE = 'DORIC'
- basic_intervals = {'HLED': [['ON_OFF', 'both', ['hled_on', 'hled_off']], 'Houselight on (interval)'], 'LED1': [['ON_OFF', 'both', ['led1_on', 'led1_off']], 'CS light on (interval)'], 'LED2': [['ON_OFF', 'both', ['led2_on', 'led2_off']], 'Drug light on (interval)'], 'TTL1': [['ON_OFF', 'both', ['ttl1_on', 'ttl1_off']], 'TTL1 sending (interval)']}
- behavior_time_ratio = 1000
- csv_events = {'TTL1': [['timestamp', 'DI/O-1', 'Time(s)'], 'TTL1'], 'TTL2': [['timestamp', 'DI/O-2', 'Time(s)'], 'TTL2'], 'TTL3': [['timestamp', 'DI/O-3', 'Time(s)'], 'TTL3'], 'TTL4': [['timestamp', 'DI/O-4', 'Time(s)'], 'TTL4']}
- custom = {'DARK': [['INTERSECTION', ['HLED_OFF', 'LED1_OFF', 'LED2_OFF']], 'No lights on'], 'DNI': [['NEAR_EVENT', 'DARK', 'inj1', 5], 'No lights on, close to an injection'], 'DRP': [['NEAR_EVENT', 'HLEDOFF_NODARK', 'led2_on', 1], 'Period with HLED off and near a led2 switch on'], 'DRP_INJ': [['CONTAINS', 'DRP', 'inj1'], 'Drug period that is close to an injection'], 'DRP_LONG': [['DURATION', 'DRP', '>', 600], 'Drug periods longer than 600 seconds'], 'DRUG': [['UNION', ['DRP_LONG', 'DRP_INJ']], 'Drug periods'], 'DRUG_NOTO': [['INTERSECTION', ['DRUG', '~TIMEOUT']], 'Drug period without timeouts'], 'D_n': [['GENERATIVE', 'DRUG'], 'N-th drug period'], 'HLEDOFF_NODARK': [['INTERSECTION', ['HLED_OFF', '~NOTO_DARK']], 'HLED off, excluding non-timeout-dark periods'], 'ND_first': [['NEAR_EVENT', 'HLED_ON', 'switch_1', 1], 'First ND period (excluding the first one in case of NDpre paradigm'], 'ND_n': [['GENERATIVE', 'HLED_ON'], 'No drug period (HLED on)'], 'NOTO_DARK': [['INTERSECTION', ['DARK', '~TIMEOUT']], 'No lights on, not a timeout'], 'TIMEOUT': [['UNION', ['LED1_ON', 'TO_DARK']], 'CS light on + subsequent dark period'], 'TO_DARK': [['DURATION', 'DNI', '<', 45], 'No lights on, close to an injection, shorter than 45s'], 'hled_on_end': [['boundary', 'end', 'HLED_ON'], 'Ends of each no drug periods'], 'hled_on_start': [['boundary', 'start', 'HLED_ON'], 'Starts of each no drug periods'], 'inj_first': [['indexed', 'inj1', 1], 'First injection'], 'noto_dark_end': [['boundary', 'end', 'NOTO_DARK'], "End of dark period (that isn't a timeout)"], 'np1_ND_first': [['iselement', 'np1', 'ND_first'], 'Active nosepokes during the first ND period'], 'np1_NDfirst_1': [['indexed', 'np1_ND_first', 1], 'First active nosepoke of first ND period'], 'np1_n': [['generative2', ['D_n', 'np_effective'], 5], 'N-th effective nosepoke inside each drug period'], 'np2_ND_first': [['iselement', 'np2', 'ND_first'], 'Inactive nosepokes during the first ND period'], 'np2_NDfirst_1': [['indexed', 'np2_ND_first', 1], 'First inactive nosepoke of first ND period'], 'np_HF_NOTO': [['iselement', 'np1', 'DRUG_NOTO'], 'Active nosepoke not during HLED ON and not during full timeout'], 'np_effective': [['iselement', 'np_HF_NOTO', 'LED2_ON'], 'Active nosepoke that is part of the FR series'], 'npt': [['combination', ['np1', 'np2']], 'All nosepokes (active and inactive)'], 'npt_ND_first': [['iselement', 'npt', 'ND_first'], 'Nosepokes during the first ND period'], 'npt_NDfirst_1': [['indexed', 'npt_ND_first', 1], 'First nosepoke of first ND period'], 'rec_start': [['indexed', 'ttl1_on', 1], 'Start of the recording'], 'switch_1': [['indexed', 'switch_between', 1], 'First of the switches between ND and D that are between t+100s and t+3400s'], 'switch_1_D': [['indexed', 'switch_between_D', 1], 'No to-d First of the switches between ND and D that are between t+100s and t+3400s'], 'switch_between': [['timerestricted', 'switch_dto_nd', [100, 3400]], 'Switch between ND and D that are between t+100s and t+3400s'], 'switch_between_D': [['timerestricted', 'switch_d_nd', [100, 3400]], 'No to-d Switch between ND and D that are between t+100s and t+3400s'], 'switch_d_nd': [['iselement', 'hled_on_start', 'DRUG_NOTO'], 'Switch from drug to no drug (ie excluding timeout to drug)'], 'switch_dark_d1': [['iselement', 'noto_dark_end', 'LED2_ON'], 'Switch from dark to D1'], 'switch_dto_nd': [['combination', ['switch_d_nd', 'switch_to_nd']], 'Switch of either drug/timeout to no drug'], 'switch_nd1': [['boundary', 'end', 'ND_first'], 'First ND-D switch.'], 'switch_nd_d': [['iselement', 'hled_on_end', 'LED2_ON'], 'Switch from ND to D'], 'switch_to_nd': [['iselement', 'hled_on_start', 'TIMEOUT'], 'Switch from timeout to no drug']}
- default_norm = 'F'
- elements = {'DARK': [False, 'DARK', 'k'], 'HLED_OFF': [True, 'Drug Period', '#069AF3'], 'HLED_ON': [True, 'No Drug Period', 'gold'], 'LED1_OFF': [False, 'LED1_OFF', ['darkgray', 'darkgrey']], 'LED1_ON': [True, 'Conditioned Stimulus', 'goldenrod'], 'LED2_OFF': [False, 'LED2_OFF', 'slategrey'], 'LED2_ON': [True, ' Drug Light On', 'slategrey'], 'NOTO_DARK': [False, 'NOTO_DARK', 'black'], 'TIMEOUT': [True, 'Time outs', 'k'], 'TO_DARK': [False, 'TO_DARK', 'olivedrab'], 'TTL1_ON': [True, 'Fiber Photometry Recordings', 'g'], 'all': [True, 'Session', 'b'], 'inj1': [True, 'Injections', 'k'], 'np1': [True, 'Active Nosepokes', 'r'], 'np2': [True, 'Inactive Nosepokes', 'b'], 'switch_d_nd': [False, 'Switch from D to ND', 'r'], 'switch_nd_d': [False, 'Switch from ND to D', 'b'], 'switch_to_nd': [False, 'Switch from TO to ND', 'r']}
- imetronic_events = {'hled_off': [['conditional', [1, 1], ['_P', 0]], 'houselight off'], 'hled_on': [['conditional', [1, 1], ['_P', 1]], 'houselight on'], 'inj1': [['conditional', [6, 1], ['_L', 1]], 'Injection'], 'led1_off': [['conditional', [1, 2], ['_P', 0]], 'CS light off'], 'led1_on': [['conditional', [1, 2], ['_P', 1]], 'CS light on'], 'led2_off': [['conditional', [1, 3], ['_P', 0]], 'Drug light off'], 'led2_on': [['conditional', [1, 3], ['_P', 1]], 'Drug light on'], 'np1': [['conditional', [3, 1], ['_V', 1]], 'Active Nosepoke'], 'np2': [['conditional', [3, 2], ['_V', 1]], 'Inactive nosepoke'], 'ttl1_off': [['conditional', [15, 1], ['_L', 0]], 'Recording TTL off'], 'ttl1_on': [['conditional', [15, 1], ['_L', 1]], 'Recording TTL on'], 'x_coordinates': [['simple', [9, 1], '_X'], 'X coordinates'], 'xy_timestamps': [['simple', [9, 1], 'TIME'], 'Timestamps for coordinates'], 'y_coordinates': [['simple', [9, 1], '_Y'], 'Y coordinates']}
- min_sample_per_rec = 5
- peak_baseline_MAD = 2
- peak_distance = '50ms'
- peak_peak_MAD = 3
- peak_window = 10
- peak_zscore = 'full'
- perievent_window = [1.0, 1.0]
- split_recordings = True
- split_treshold = 10
- trim_recording = 1.0
- class pyfiber.analysis.Analysis(ID)
Instantiated by using
Sessionmethodanalyze.Contains all automatically retrieved and computed about a single peri-event analysis.
- Variables:
event_time – timestamps of the analyzed event
window – perievent window
rec_number – recording number in the Fiber instance data
recordingdata – 2D-array with time and normalized signal (full recording)
rawdata – 2D-array with time, raw signal and control (full recording)
normalisation – normalization method used
raw_signal – raw signal (peri-event)
raw_control – raw control (peri-event)
data – 2D-array with time and normalized signal (peri-event)
signal – normalized signal (peri-event)
preevent – normalized signal (pre-event)
postevent – normalized signal (post-event)
sampling_rate – mean sampling rate (peri-event)
time – timestamps (peri-event)
pre_time – timestamps (pre-event)
post_time – timestamps (post-event)
pre_raw_sig – raw signal (pre-event)
post_raw_sig – raw signal (post-event)
post_raw_ctrl – raw control (post-event)
pre_raw_AUC – raw signal area under curve (pre-event)
post_raw_AUC – raw signal area under curve (post-event)
zscores – Z-scores with pre-event as baseline (peri-event)
pre_zscores – Z-scores with pre-event as baseline (pre-event)
post_zscores – Z-scores with pre-event as baseline (post-event)
rob_zscores – robust Z-scores with pre-event as baseline (peri-event)
pre_Rzscores – robust Z-scores with pre-event as baseline (pre-event)
post_Rzscores – robust Z-scores with pre-event as baseline (post-event)
preAVG_dF – average normalized signal (pre-event)
postAVG_dF – average normalized signal (post-event)
preAVG_Z – average Z-scores (pre-event)
postAVG_Z – average Z-scores (post-event)
preAVG_RZ – average robust Z-scores (pre-event)
postAVG_RZ – average robust Z-scores (post-event)
preAUC – = normalized signal area under curve (pre-event)
postAUC – = normalized signal area under curve (post-event)
preZ_AUC – = Z-scores area under curve (pre-event)
postZ_AUC – = Z-scores area under curve (post-event)
preRZ_AUC – = robust Z-scores area under curve (pre-event)
postRZ_AUC – = robust Z-scores area under curve (post-event)
post_peak_avg_Z – post-event average transient Z-scores
post_peak_avg_dFF – post-event average transient amplitude
post_peak_frequency – post-event transient frequency
post_peak_max_Z – post-event maximum Z-scores of transients
post_peak_max_dFF – post-event maximum amplitude of transients
pre_peak_avg_Z – pre-event average transient Z-scores
pre_peak_avg_dFF – pre-event average transient amplitud
pre_peak_frequency – pre-event transient frequency
pre_peak_max_Z – pre-event maximum Z-scores of transients
pre_peak_max_dFF – pre-event maximum amplitude of transients
- _savgol(data, window=10, polyorder=3, nosmoothing=False)
- plot(data, ylabel=None, xlabel='time', plot_title=None, figsize=(20, 10), event=True, event_label='event', linewidth=2, smth_method='savgol', smooth=True, smth_window='default', show_non_smoothed=True, xlim=None, ylim=None, save=None, save_dpi=600, save_format=['png', 'pdf'])
Visualize data.
- Parameters:
save – default is
False, filepath (without file extension)save_dpi – dpi if figure is saved
save_format – file extension for saving
By default smoothes data with Savitski Golay filter (window size 250ms).
- _possible_data()
- smooth(data, method='savgol', window='default', polyorder=3, add_time=True)
Return smoothed data.
- Possible methods:
Savitsky-Golay filter
rolling average.
- class pyfiber.analysis.MultiAnalysis
Contains results of multiple analysis of similar peri-event intervals.
- Variables:
exclude_list – optional list of excluded sessions in the analysis
nb_of_points – mean number of data points for all sessions (used to interpolate each session data)
WINDOW – peri-event window
dict – dictionnary containing a list of
Analysisobjects for each sessionkey – corresponding session for each event in each session
event_id – unique event identifier (session name + event time)
epoch – interpolated epochs for each event in each session
EPOCH – reference epoch (based on
nb_of_pointsandWINDOW)interpolated_raw_control – interpolated raw control for each event in each session
RAW_CONTROL – mean raw control
interpolated_raw_signal – interpolated raw signal for each event in each session
RAW_SIGNAL – mean raw signal
interpolated_rob_zscores – interpolated robust Z-scores for each event in each session
ROB_ZSCORES – mean robust Z-scores
interpolated_signal – interpolated normalized signal for each event in each session
SIGNAL – mean normalized signal
interpolated_time – interpolated time for each event in each session
TIME – mean time for all recordings (automatically generated)
interpolated_zscores – interpolated Z-scores for each event in each session
ZSCORES – mean Z-scores
interpolated_epoch – reference timestamps,
event_name – queried event (defined in config file)
event_time – timestamps of the analyzed event for each event in each session
window – perievent windows for each event in each session
rec_number – recording number in the Fiber instance data for each event in each session
recordingdata – list of 2D-arrays with time and normalized signal (full recording) for each event in each session
rawdata – list of 2D-arrays with time, raw signal and control (full recording) for each event in each session
normalisation – normalization method used for each event in each session
raw_signal – raw signal (peri-event) for each event in each session
raw_control – raw control (peri-event) for each event in each session
data – 2D-array with time and normalized signal (peri-event) for each event in each session
signal – normalized signal (peri-event) for each event in each session
preevent – normalized signal (pre-event) for each event in each session
postevent – normalized signal (post-event) for each event in each session
sampling_rate – mean sampling rate (peri-event) for each event in each session
time – timestamps (peri-event) for each event in each session
pre_time – timestamps (pre-event) for each event in each session
post_time – timestamps (post-event) for each event in each session
pre_raw_sig – raw signal (pre-event) for each event in each session
post_raw_sig – raw signal (post-event) for each event in each session
post_raw_ctrl – raw control (post-event) for each event in each session
pre_raw_AUC – raw signal area under curve (pre-event) for each event in each session
post_raw_AUC – raw signal area under curve (post-event) for each event in each session
zscores – Z-scores with pre-event as baseline (peri-event) for each event in each session
pre_zscores – Z-scores with pre-event as baseline (pre-event) for each event in each session
post_zscores – Z-scores with pre-event as baseline (post-event) for each event in each session
rob_zscores – robust Z-scores with pre-event as baseline (peri-event) for each event in each session
pre_Rzscores – robust Z-scores with pre-event as baseline (pre-event) for each event in each session
post_Rzscores – robust Z-scores with pre-event as baseline (post-event) for each event in each session
preAVG_dF – average normalized signal (pre-event) for each event in each session
postAVG_dF – average normalized signal (post-event) for each event in each session
preAVG_Z – average Z-scores (pre-event) for each event in each session
postAVG_Z – average Z-scores (post-event) for each event in each session
preAVG_RZ – average robust Z-scores (pre-event) for each event in each session
postAVG_RZ – average robust Z-scores (post-event) for each event in each session
preAUC – normalized signal area under curve (pre-event) for each event in each session
postAUC – normalized signal area under curve (post-event) for each event in each session
preZ_AUC – Z-scores area under curve (pre-event) for each event in each session
postZ_AUC – Z-scores area under curve (post-event) for each event in each session
preRZ_AUC – robust Z-scores area under curve (pre-event) for each event in each session
postRZ_AUC – robust Z-scores area under curve (post-event) for each event in each session
post_peak_avg_Z – post-event average transient Z-scores
post_peak_avg_dFF – post-event average transient amplitude
post_peak_frequency – post-event transient frequency
post_peak_max_Z – post-event maximum Z-scores of transients
post_peak_max_dFF – post-event maximum amplitude of transients
pre_peak_avg_Z – pre-event average transient Z-scores
pre_peak_avg_dFF – pre-event average transient amplitud
pre_peak_frequency – pre-event transient frequency
pre_peak_max_Z – pre-event maximum Z-scores of transients
pre_peak_max_dFF – pre-event maximum amplitude of transients
- property data
- property full_data
- BEHAVIOR_FILE_TYPE = 'IMETRONIC'
- FIBER_FILE_TYPE = 'DORIC'
- basic_intervals = {'HLED': [['ON_OFF', 'both', ['hled_on', 'hled_off']], 'Houselight on (interval)'], 'LED1': [['ON_OFF', 'both', ['led1_on', 'led1_off']], 'CS light on (interval)'], 'LED2': [['ON_OFF', 'both', ['led2_on', 'led2_off']], 'Drug light on (interval)'], 'TTL1': [['ON_OFF', 'both', ['ttl1_on', 'ttl1_off']], 'TTL1 sending (interval)']}
- behavior_time_ratio = 1000
- csv_events = {'TTL1': [['timestamp', 'DI/O-1', 'Time(s)'], 'TTL1'], 'TTL2': [['timestamp', 'DI/O-2', 'Time(s)'], 'TTL2'], 'TTL3': [['timestamp', 'DI/O-3', 'Time(s)'], 'TTL3'], 'TTL4': [['timestamp', 'DI/O-4', 'Time(s)'], 'TTL4']}
- custom = {'DARK': [['INTERSECTION', ['HLED_OFF', 'LED1_OFF', 'LED2_OFF']], 'No lights on'], 'DNI': [['NEAR_EVENT', 'DARK', 'inj1', 5], 'No lights on, close to an injection'], 'DRP': [['NEAR_EVENT', 'HLEDOFF_NODARK', 'led2_on', 1], 'Period with HLED off and near a led2 switch on'], 'DRP_INJ': [['CONTAINS', 'DRP', 'inj1'], 'Drug period that is close to an injection'], 'DRP_LONG': [['DURATION', 'DRP', '>', 600], 'Drug periods longer than 600 seconds'], 'DRUG': [['UNION', ['DRP_LONG', 'DRP_INJ']], 'Drug periods'], 'DRUG_NOTO': [['INTERSECTION', ['DRUG', '~TIMEOUT']], 'Drug period without timeouts'], 'D_n': [['GENERATIVE', 'DRUG'], 'N-th drug period'], 'HLEDOFF_NODARK': [['INTERSECTION', ['HLED_OFF', '~NOTO_DARK']], 'HLED off, excluding non-timeout-dark periods'], 'ND_first': [['NEAR_EVENT', 'HLED_ON', 'switch_1', 1], 'First ND period (excluding the first one in case of NDpre paradigm'], 'ND_n': [['GENERATIVE', 'HLED_ON'], 'No drug period (HLED on)'], 'NOTO_DARK': [['INTERSECTION', ['DARK', '~TIMEOUT']], 'No lights on, not a timeout'], 'TIMEOUT': [['UNION', ['LED1_ON', 'TO_DARK']], 'CS light on + subsequent dark period'], 'TO_DARK': [['DURATION', 'DNI', '<', 45], 'No lights on, close to an injection, shorter than 45s'], 'hled_on_end': [['boundary', 'end', 'HLED_ON'], 'Ends of each no drug periods'], 'hled_on_start': [['boundary', 'start', 'HLED_ON'], 'Starts of each no drug periods'], 'inj_first': [['indexed', 'inj1', 1], 'First injection'], 'noto_dark_end': [['boundary', 'end', 'NOTO_DARK'], "End of dark period (that isn't a timeout)"], 'np1_ND_first': [['iselement', 'np1', 'ND_first'], 'Active nosepokes during the first ND period'], 'np1_NDfirst_1': [['indexed', 'np1_ND_first', 1], 'First active nosepoke of first ND period'], 'np1_n': [['generative2', ['D_n', 'np_effective'], 5], 'N-th effective nosepoke inside each drug period'], 'np2_ND_first': [['iselement', 'np2', 'ND_first'], 'Inactive nosepokes during the first ND period'], 'np2_NDfirst_1': [['indexed', 'np2_ND_first', 1], 'First inactive nosepoke of first ND period'], 'np_HF_NOTO': [['iselement', 'np1', 'DRUG_NOTO'], 'Active nosepoke not during HLED ON and not during full timeout'], 'np_effective': [['iselement', 'np_HF_NOTO', 'LED2_ON'], 'Active nosepoke that is part of the FR series'], 'npt': [['combination', ['np1', 'np2']], 'All nosepokes (active and inactive)'], 'npt_ND_first': [['iselement', 'npt', 'ND_first'], 'Nosepokes during the first ND period'], 'npt_NDfirst_1': [['indexed', 'npt_ND_first', 1], 'First nosepoke of first ND period'], 'rec_start': [['indexed', 'ttl1_on', 1], 'Start of the recording'], 'switch_1': [['indexed', 'switch_between', 1], 'First of the switches between ND and D that are between t+100s and t+3400s'], 'switch_1_D': [['indexed', 'switch_between_D', 1], 'No to-d First of the switches between ND and D that are between t+100s and t+3400s'], 'switch_between': [['timerestricted', 'switch_dto_nd', [100, 3400]], 'Switch between ND and D that are between t+100s and t+3400s'], 'switch_between_D': [['timerestricted', 'switch_d_nd', [100, 3400]], 'No to-d Switch between ND and D that are between t+100s and t+3400s'], 'switch_d_nd': [['iselement', 'hled_on_start', 'DRUG_NOTO'], 'Switch from drug to no drug (ie excluding timeout to drug)'], 'switch_dark_d1': [['iselement', 'noto_dark_end', 'LED2_ON'], 'Switch from dark to D1'], 'switch_dto_nd': [['combination', ['switch_d_nd', 'switch_to_nd']], 'Switch of either drug/timeout to no drug'], 'switch_nd1': [['boundary', 'end', 'ND_first'], 'First ND-D switch.'], 'switch_nd_d': [['iselement', 'hled_on_end', 'LED2_ON'], 'Switch from ND to D'], 'switch_to_nd': [['iselement', 'hled_on_start', 'TIMEOUT'], 'Switch from timeout to no drug']}
- default_norm = 'F'
- elements = {'DARK': [False, 'DARK', 'k'], 'HLED_OFF': [True, 'Drug Period', '#069AF3'], 'HLED_ON': [True, 'No Drug Period', 'gold'], 'LED1_OFF': [False, 'LED1_OFF', ['darkgray', 'darkgrey']], 'LED1_ON': [True, 'Conditioned Stimulus', 'goldenrod'], 'LED2_OFF': [False, 'LED2_OFF', 'slategrey'], 'LED2_ON': [True, ' Drug Light On', 'slategrey'], 'NOTO_DARK': [False, 'NOTO_DARK', 'black'], 'TIMEOUT': [True, 'Time outs', 'k'], 'TO_DARK': [False, 'TO_DARK', 'olivedrab'], 'TTL1_ON': [True, 'Fiber Photometry Recordings', 'g'], 'all': [True, 'Session', 'b'], 'inj1': [True, 'Injections', 'k'], 'np1': [True, 'Active Nosepokes', 'r'], 'np2': [True, 'Inactive Nosepokes', 'b'], 'switch_d_nd': [False, 'Switch from D to ND', 'r'], 'switch_nd_d': [False, 'Switch from ND to D', 'b'], 'switch_to_nd': [False, 'Switch from TO to ND', 'r']}
- imetronic_events = {'hled_off': [['conditional', [1, 1], ['_P', 0]], 'houselight off'], 'hled_on': [['conditional', [1, 1], ['_P', 1]], 'houselight on'], 'inj1': [['conditional', [6, 1], ['_L', 1]], 'Injection'], 'led1_off': [['conditional', [1, 2], ['_P', 0]], 'CS light off'], 'led1_on': [['conditional', [1, 2], ['_P', 1]], 'CS light on'], 'led2_off': [['conditional', [1, 3], ['_P', 0]], 'Drug light off'], 'led2_on': [['conditional', [1, 3], ['_P', 1]], 'Drug light on'], 'np1': [['conditional', [3, 1], ['_V', 1]], 'Active Nosepoke'], 'np2': [['conditional', [3, 2], ['_V', 1]], 'Inactive nosepoke'], 'ttl1_off': [['conditional', [15, 1], ['_L', 0]], 'Recording TTL off'], 'ttl1_on': [['conditional', [15, 1], ['_L', 1]], 'Recording TTL on'], 'x_coordinates': [['simple', [9, 1], '_X'], 'X coordinates'], 'xy_timestamps': [['simple', [9, 1], 'TIME'], 'Timestamps for coordinates'], 'y_coordinates': [['simple', [9, 1], '_Y'], 'Y coordinates']}
- min_sample_per_rec = 5
- peak_baseline_MAD = 2
- peak_distance = '50ms'
- peak_peak_MAD = 3
- peak_window = 10
- peak_zscore = 'full'
- perievent_window = [1.0, 1.0]
- possible_data()
Return dictionnary of possible data to plot
- split_recordings = True
- split_treshold = 10
- trim_recording = 1.0
- exclude(list_of_sessions)
- update(nb_of_points='default')
Recalculate mean values for all relevant values (perievent data). “nb of points” is the desired number of points for the new aligned data. Default is mean number of points of the data.
- plot(data='signal', smooth_data=True, smooth_mean=True, data_window=500, mean_window=500, label=None, save=False, save_dpi=600, save_format=['png', 'pdf'], **kwargs)
Visualize specified data.
- Parameters:
save – default is
False, filepath (without file extension)save_dpi – dpi if figure is saved
save_format – file extension for saving
pyfiber._utils module
- class pyfiber._utils.PyFiber(**kwargs)
Bases:
objectParent object for Behavioral, Fiber and Analysis objects.
- Variables:
CFG – dictionnary containing the whole
'pyfiber.yaml'file content- Parameters:
verbose – if
False, activates silent mode (the log is still available inself.log)kwargs – add additional attribute or modify config option at runtine
- FOLDER = '/home/docs/.pyfiber'
- _config_path = '/home/docs/.pyfiber/pyfiber.yaml'
- _sample_config = '/home/docs/checkouts/readthedocs.org/user_builds/pyfiber/checkouts/latest/src/pyfiber/pyfiber.yaml'
- CFG
- property log
Show the history of most of the operation (extraction, normalization, errors, …) for all classes derived of
_utils.PyFiber. Users can optionnaly add information to the log, by assigning the new information:In [10]: obj.log '15:29:36 --- did something' '15:29:37 --- did something else' In [11]: obj.log = "new entry" In [12]: obj.log '15:29:36 --- did something' '15:29:37 --- did something else' '15:35:10 --- new entry'
- property help
- property _help
- property info
- _list(anything)
Convert user input into list if not already.
- BEHAVIOR = {'BEHAVIOR_FILE_TYPE': 'IMETRONIC', 'basic_intervals': {'HLED': [['ON_OFF', 'both', ['hled_on', 'hled_off']], 'Houselight on (interval)'], 'LED1': [['ON_OFF', 'both', ['led1_on', 'led1_off']], 'CS light on (interval)'], 'LED2': [['ON_OFF', 'both', ['led2_on', 'led2_off']], 'Drug light on (interval)'], 'TTL1': [['ON_OFF', 'both', ['ttl1_on', 'ttl1_off']], 'TTL1 sending (interval)']}, 'behavior_time_ratio': 1000, 'csv_events': {'TTL1': [['timestamp', 'DI/O-1', 'Time(s)'], 'TTL1'], 'TTL2': [['timestamp', 'DI/O-2', 'Time(s)'], 'TTL2'], 'TTL3': [['timestamp', 'DI/O-3', 'Time(s)'], 'TTL3'], 'TTL4': [['timestamp', 'DI/O-4', 'Time(s)'], 'TTL4']}, 'custom': {'DARK': [['INTERSECTION', ['HLED_OFF', 'LED1_OFF', 'LED2_OFF']], 'No lights on'], 'DNI': [['NEAR_EVENT', 'DARK', 'inj1', 5], 'No lights on, close to an injection'], 'DRP': [['NEAR_EVENT', 'HLEDOFF_NODARK', 'led2_on', 1], 'Period with HLED off and near a led2 switch on'], 'DRP_INJ': [['CONTAINS', 'DRP', 'inj1'], 'Drug period that is close to an injection'], 'DRP_LONG': [['DURATION', 'DRP', '>', 600], 'Drug periods longer than 600 seconds'], 'DRUG': [['UNION', ['DRP_LONG', 'DRP_INJ']], 'Drug periods'], 'DRUG_NOTO': [['INTERSECTION', ['DRUG', '~TIMEOUT']], 'Drug period without timeouts'], 'D_n': [['GENERATIVE', 'DRUG'], 'N-th drug period'], 'HLEDOFF_NODARK': [['INTERSECTION', ['HLED_OFF', '~NOTO_DARK']], 'HLED off, excluding non-timeout-dark periods'], 'ND_first': [['NEAR_EVENT', 'HLED_ON', 'switch_1', 1], 'First ND period (excluding the first one in case of NDpre paradigm'], 'ND_n': [['GENERATIVE', 'HLED_ON'], 'No drug period (HLED on)'], 'NOTO_DARK': [['INTERSECTION', ['DARK', '~TIMEOUT']], 'No lights on, not a timeout'], 'TIMEOUT': [['UNION', ['LED1_ON', 'TO_DARK']], 'CS light on + subsequent dark period'], 'TO_DARK': [['DURATION', 'DNI', '<', 45], 'No lights on, close to an injection, shorter than 45s'], 'hled_on_end': [['boundary', 'end', 'HLED_ON'], 'Ends of each no drug periods'], 'hled_on_start': [['boundary', 'start', 'HLED_ON'], 'Starts of each no drug periods'], 'inj_first': [['indexed', 'inj1', 1], 'First injection'], 'noto_dark_end': [['boundary', 'end', 'NOTO_DARK'], "End of dark period (that isn't a timeout)"], 'np1_ND_first': [['iselement', 'np1', 'ND_first'], 'Active nosepokes during the first ND period'], 'np1_NDfirst_1': [['indexed', 'np1_ND_first', 1], 'First active nosepoke of first ND period'], 'np1_n': [['generative2', ['D_n', 'np_effective'], 5], 'N-th effective nosepoke inside each drug period'], 'np2_ND_first': [['iselement', 'np2', 'ND_first'], 'Inactive nosepokes during the first ND period'], 'np2_NDfirst_1': [['indexed', 'np2_ND_first', 1], 'First inactive nosepoke of first ND period'], 'np_HF_NOTO': [['iselement', 'np1', 'DRUG_NOTO'], 'Active nosepoke not during HLED ON and not during full timeout'], 'np_effective': [['iselement', 'np_HF_NOTO', 'LED2_ON'], 'Active nosepoke that is part of the FR series'], 'npt': [['combination', ['np1', 'np2']], 'All nosepokes (active and inactive)'], 'npt_ND_first': [['iselement', 'npt', 'ND_first'], 'Nosepokes during the first ND period'], 'npt_NDfirst_1': [['indexed', 'npt_ND_first', 1], 'First nosepoke of first ND period'], 'rec_start': [['indexed', 'ttl1_on', 1], 'Start of the recording'], 'switch_1': [['indexed', 'switch_between', 1], 'First of the switches between ND and D that are between t+100s and t+3400s'], 'switch_1_D': [['indexed', 'switch_between_D', 1], 'No to-d First of the switches between ND and D that are between t+100s and t+3400s'], 'switch_between': [['timerestricted', 'switch_dto_nd', [100, 3400]], 'Switch between ND and D that are between t+100s and t+3400s'], 'switch_between_D': [['timerestricted', 'switch_d_nd', [100, 3400]], 'No to-d Switch between ND and D that are between t+100s and t+3400s'], 'switch_d_nd': [['iselement', 'hled_on_start', 'DRUG_NOTO'], 'Switch from drug to no drug (ie excluding timeout to drug)'], 'switch_dark_d1': [['iselement', 'noto_dark_end', 'LED2_ON'], 'Switch from dark to D1'], 'switch_dto_nd': [['combination', ['switch_d_nd', 'switch_to_nd']], 'Switch of either drug/timeout to no drug'], 'switch_nd1': [['boundary', 'end', 'ND_first'], 'First ND-D switch.'], 'switch_nd_d': [['iselement', 'hled_on_end', 'LED2_ON'], 'Switch from ND to D'], 'switch_to_nd': [['iselement', 'hled_on_start', 'TIMEOUT'], 'Switch from timeout to no drug']}, 'elements': {'DARK': [False, 'DARK', 'k'], 'HLED_OFF': [True, 'Drug Period', '#069AF3'], 'HLED_ON': [True, 'No Drug Period', 'gold'], 'LED1_OFF': [False, 'LED1_OFF', ['darkgray', 'darkgrey']], 'LED1_ON': [True, 'Conditioned Stimulus', 'goldenrod'], 'LED2_OFF': [False, 'LED2_OFF', 'slategrey'], 'LED2_ON': [True, ' Drug Light On', 'slategrey'], 'NOTO_DARK': [False, 'NOTO_DARK', 'black'], 'TIMEOUT': [True, 'Time outs', 'k'], 'TO_DARK': [False, 'TO_DARK', 'olivedrab'], 'TTL1_ON': [True, 'Fiber Photometry Recordings', 'g'], 'all': [True, 'Session', 'b'], 'inj1': [True, 'Injections', 'k'], 'np1': [True, 'Active Nosepokes', 'r'], 'np2': [True, 'Inactive Nosepokes', 'b'], 'switch_d_nd': [False, 'Switch from D to ND', 'r'], 'switch_nd_d': [False, 'Switch from ND to D', 'b'], 'switch_to_nd': [False, 'Switch from TO to ND', 'r']}, 'imetronic_events': {'hled_off': [['conditional', [1, 1], ['_P', 0]], 'houselight off'], 'hled_on': [['conditional', [1, 1], ['_P', 1]], 'houselight on'], 'inj1': [['conditional', [6, 1], ['_L', 1]], 'Injection'], 'led1_off': [['conditional', [1, 2], ['_P', 0]], 'CS light off'], 'led1_on': [['conditional', [1, 2], ['_P', 1]], 'CS light on'], 'led2_off': [['conditional', [1, 3], ['_P', 0]], 'Drug light off'], 'led2_on': [['conditional', [1, 3], ['_P', 1]], 'Drug light on'], 'np1': [['conditional', [3, 1], ['_V', 1]], 'Active Nosepoke'], 'np2': [['conditional', [3, 2], ['_V', 1]], 'Inactive nosepoke'], 'ttl1_off': [['conditional', [15, 1], ['_L', 0]], 'Recording TTL off'], 'ttl1_on': [['conditional', [15, 1], ['_L', 1]], 'Recording TTL on'], 'x_coordinates': [['simple', [9, 1], '_X'], 'X coordinates'], 'xy_timestamps': [['simple', [9, 1], 'TIME'], 'Timestamps for coordinates'], 'y_coordinates': [['simple', [9, 1], '_Y'], 'Y coordinates']}}
- DORIC_CSV = {'AIn-1 - Demodulated(Lock-In)': 'signal', 'AIn-2 - Demodulated(Lock-In)': 'control', 'DI/O-1': 'TTL1', 'DI/O-2': 'TTL2', 'DI/O-3': 'TTL3', 'DI/O-4': 'TTL4', 'Time(s)': 'time'}
- DORIC_HDF = {'DataAcquisition/FPConsole/Signals/Series0001/AIN01xAOUT01-LockIn/Time': 'time', 'DataAcquisition/FPConsole/Signals/Series0001/AIN01xAOUT01-LockIn/Values': 'signal', 'DataAcquisition/FPConsole/Signals/Series0001/AIN02xAOUT02-LockIn/Values': 'control', 'DataAcquisition/FPConsole/Signals/Series0001/DigitalIO/DIO01': 'TTL1', 'DataAcquisition/FPConsole/Signals/Series0001/DigitalIO/DIO02': 'TTL2', 'DataAcquisition/FPConsole/Signals/Series0001/DigitalIO/DIO03': 'TTL3', 'DataAcquisition/FPConsole/Signals/Series0001/DigitalIO/DIO04': 'TTL4'}
- EXAMPLE_NOMENCLATURE = {'control_column': 'control', 'signal_column': 'signal', 'time_column': 'time', 'ttl1': 'TTL1'}
- FIBER = {'FIBER_FILE_TYPE': 'DORIC', 'default_norm': 'F', 'min_sample_per_rec': 5, 'peak_baseline_MAD': 2, 'peak_distance': '50ms', 'peak_peak_MAD': 3, 'peak_window': 10, 'peak_zscore': 'full', 'perievent_window': [1.0, 1.0], 'split_recordings': True, 'split_treshold': 10, 'trim_recording': 1.0}
- GENERAL = {'ID': 'Not specified', 'folder_nomenclature': {'ID': ['experiment', 'rat_number'], 'meanings': ['experiment', '', 'rat_number', 'experiment_type', 'session_number'], 'naming': '@_rat_@_@_j@', 'separator': '_'}}
- ID = 'Not specified'
- IMETRONIC = {'DISTRIBUTEUR': {'D1': [4, 1], 'D10': [4, 10], 'D11': [4, 11], 'D12': [4, 12], 'D2': [4, 2], 'D3': [4, 3], 'D4': [4, 4], 'D5': [4, 5], 'D6': [4, 6], 'D7': [4, 7], 'D8': [4, 8], 'D9': [4, 9]}, 'DIVERS': {'EVT': [10, 5], 'ON': [10, 1]}, 'DIVERS_CA': {'ADC': [6, 8], 'BUL': [6, 13], 'FL': [6, 10], 'INJ1': [6, 1], 'INJ2': [6, 7], 'OD': [6, 12], 'PUSH': [6, 5], 'RD': [6, 11], 'SHK': [6, 4], 'SND': [6, 2], 'SNDpP': [6, 9], 'TOP': [6, 6], 'WH': [6, 14], 'WN': [6, 3]}, 'DIVERS_NON_STOCKES': {'I': [11, 4]}, 'LEVERS': {'L1': [2, 1], 'L2': [2, 2], 'L3': [2, 3], 'L4': [2, 4], 'L5': [2, 5], 'L6': [2, 6]}, 'LICKMETER': {'LK1': [5, 1], 'LK2': [5, 2], 'LK3': [5, 3], 'LK4': [5, 4], 'LK5': [5, 5]}, 'LIGHTS': {'HLED': [1, 1], 'LED1': [1, 2], 'LED2': [1, 3], 'LED3': [1, 4], 'LED4': [1, 5], 'LED5': [1, 6], 'LED6': [1, 7], 'LED7': [1, 8]}, 'MESSAGE': {'STR1': [13, 1], 'STR2': [13, 2], 'STR3': [13, 3], 'STR4': [13, 4]}, 'NOSEPOKE': {'NP1': [3, 1], 'NP2': [3, 2], 'NP3': [3, 3], 'NP4': [3, 4], 'NP5': [3, 5]}, 'PORTE': {'G1': [7, 1], 'G10': [7, 10], 'G11': [7, 11], 'G12': [7, 12], 'G2': [7, 2], 'G3': [7, 3], 'G4': [7, 4], 'G5': [7, 5], 'G6': [7, 6], 'G7': [7, 7], 'G8': [7, 8], 'G9': [7, 9]}, 'RFID': {'I1': [12, 1], 'I2': [12, 2], 'I3': [12, 3], 'I4': [12, 4]}, 'ZONE': {'Z1': [9, 1], 'Z10': [9, 10], 'Z11': [9, 11], 'Z12': [9, 12], 'Z13': [9, 13], 'Z2': [9, 2], 'Z3': [9, 3], 'Z4': [9, 4], 'Z5': [9, 5], 'Z6': [9, 6], 'Z7': [9, 7], 'Z8': [9, 8], 'Z9': [9, 9]}}
- SYSTEM = {'DORIC_CSV': {'AIn-1 - Demodulated(Lock-In)': 'signal', 'AIn-2 - Demodulated(Lock-In)': 'control', 'DI/O-1': 'TTL1', 'DI/O-2': 'TTL2', 'DI/O-3': 'TTL3', 'DI/O-4': 'TTL4', 'Time(s)': 'time'}, 'DORIC_HDF': {'DataAcquisition/FPConsole/Signals/Series0001/AIN01xAOUT01-LockIn/Time': 'time', 'DataAcquisition/FPConsole/Signals/Series0001/AIN01xAOUT01-LockIn/Values': 'signal', 'DataAcquisition/FPConsole/Signals/Series0001/AIN02xAOUT02-LockIn/Values': 'control', 'DataAcquisition/FPConsole/Signals/Series0001/DigitalIO/DIO01': 'TTL1', 'DataAcquisition/FPConsole/Signals/Series0001/DigitalIO/DIO02': 'TTL2', 'DataAcquisition/FPConsole/Signals/Series0001/DigitalIO/DIO03': 'TTL3', 'DataAcquisition/FPConsole/Signals/Series0001/DigitalIO/DIO04': 'TTL4'}, 'EXAMPLE_NOMENCLATURE': {'control_column': 'control', 'signal_column': 'signal', 'time_column': 'time', 'ttl1': 'TTL1'}, 'IMETRONIC': {'DISTRIBUTEUR': {'D1': [4, 1], 'D10': [4, 10], 'D11': [4, 11], 'D12': [4, 12], 'D2': [4, 2], 'D3': [4, 3], 'D4': [4, 4], 'D5': [4, 5], 'D6': [4, 6], 'D7': [4, 7], 'D8': [4, 8], 'D9': [4, 9]}, 'DIVERS': {'EVT': [10, 5], 'ON': [10, 1]}, 'DIVERS_CA': {'ADC': [6, 8], 'BUL': [6, 13], 'FL': [6, 10], 'INJ1': [6, 1], 'INJ2': [6, 7], 'OD': [6, 12], 'PUSH': [6, 5], 'RD': [6, 11], 'SHK': [6, 4], 'SND': [6, 2], 'SNDpP': [6, 9], 'TOP': [6, 6], 'WH': [6, 14], 'WN': [6, 3]}, 'DIVERS_NON_STOCKES': {'I': [11, 4]}, 'LEVERS': {'L1': [2, 1], 'L2': [2, 2], 'L3': [2, 3], 'L4': [2, 4], 'L5': [2, 5], 'L6': [2, 6]}, 'LICKMETER': {'LK1': [5, 1], 'LK2': [5, 2], 'LK3': [5, 3], 'LK4': [5, 4], 'LK5': [5, 5]}, 'LIGHTS': {'HLED': [1, 1], 'LED1': [1, 2], 'LED2': [1, 3], 'LED3': [1, 4], 'LED4': [1, 5], 'LED5': [1, 6], 'LED6': [1, 7], 'LED7': [1, 8]}, 'MESSAGE': {'STR1': [13, 1], 'STR2': [13, 2], 'STR3': [13, 3], 'STR4': [13, 4]}, 'NOSEPOKE': {'NP1': [3, 1], 'NP2': [3, 2], 'NP3': [3, 3], 'NP4': [3, 4], 'NP5': [3, 5]}, 'PORTE': {'G1': [7, 1], 'G10': [7, 10], 'G11': [7, 11], 'G12': [7, 12], 'G2': [7, 2], 'G3': [7, 3], 'G4': [7, 4], 'G5': [7, 5], 'G6': [7, 6], 'G7': [7, 7], 'G8': [7, 8], 'G9': [7, 9]}, 'RFID': {'I1': [12, 1], 'I2': [12, 2], 'I3': [12, 3], 'I4': [12, 4]}, 'ZONE': {'Z1': [9, 1], 'Z10': [9, 10], 'Z11': [9, 11], 'Z12': [9, 12], 'Z13': [9, 13], 'Z2': [9, 2], 'Z3': [9, 3], 'Z4': [9, 4], 'Z5': [9, 5], 'Z6': [9, 6], 'Z7': [9, 7], 'Z8': [9, 8], 'Z9': [9, 9]}}}
- _savgol(data, window=10, polyorder=3, nosmoothing=False)
- f = <_io.TextIOWrapper name='/home/docs/.pyfiber/pyfiber.yaml' mode='r' encoding='UTF-8'>
- folder_nomenclature = {'ID': ['experiment', 'rat_number'], 'meanings': ['experiment', '', 'rat_number', 'experiment_type', 'session_number'], 'naming': '@_rat_@_@_j@', 'separator': '_'}
- _print(thing)
- pyfiber._utils.Events
alias of
ndarray