allensdk.brain_observatory.ecephys.stimulus_analysis.drifting_gratings module

class allensdk.brain_observatory.ecephys.stimulus_analysis.drifting_gratings.DriftingGratings(ecephys_session, col_ori='orientation', col_tf='temporal_frequency', col_contrast='contrast', trial_duration=2.0, **kwargs)[source]

Bases: StimulusAnalysis

A class for computing single-unit metrics from the drifting gratings stimulus of an ecephys session NWB file.

To use, pass in a EcephysSession object::

session = EcephysSession.from_nwb_path(‘/path/to/my.nwb’) dg_analysis = DriftingGratings(session)

or, alternatively, pass in the file path::

dg_analysis = DriftingGratings(‘/path/to/my.nwb’)

You can also pass in a unit filter dictionary which will only select units with certain properties. For example to get only those units which are on probe C and found in the VISp area:

dg_analysis = DriftingGratings(session, filter={'location': 'probeC', 'structure_acronym': 'VISp'})
To get a table of the individual unit metrics ranked by unit ID::

metrics_table_df = dg_analysis.metrics()

property METRICS_COLUMNS
property conditionwise_statistics_contrast

Conditionwise statistics for contrast stimulus

property contrastvals

Array of grating temporal frequency conditions

classmethod known_stimulus_keys()[source]

Used for discovering the correct stimulus_name key for a given StimulusAnalysis subclass (when stimulus_key is not explicity set). Should return a list of “stimulus_name” strings.

make_star_plot(unit_id)[source]

Make a 2P-style Star Plot based on presentationwise spike counts

property metrics

Returns a pandas DataFrame of the stimulus response metrics for each unit.

property name

Return the stimulus name.

property null_condition

Stimulus condition ID for null (blank) stimulus

property number_contrast

Number of grating temporal frequency conditions

property number_ori

Number of grating orientation conditions

property number_tf

Number of grating temporal frequency conditions

property orivals

Array of grating orientation conditions

plot_raster(stimulus_condition_id, unit_id)[source]

Plot raster for one condition and one unit

plot_response_summary(unit_id, bar_thickness=0.25)[source]

Plot the spike counts across conditions

property stim_table_contrast
property stimulus_conditions_contrast

Stimulus conditions for contrast stimulus

property tfvals

Array of grating temporal frequency conditions

allensdk.brain_observatory.ecephys.stimulus_analysis.drifting_gratings.c50(contrasts, responses)[source]

Computes C50, the halfway point between the maximum and minimum values in a curved fitted against a difference of gaussian for the contrast values and their responese (mean spike rates)

Parameters:
contrastsarray of floats

list of different contrast stimuli

responsesarray of floats

array of responses (spike rates)

Returns:
c50float
allensdk.brain_observatory.ecephys.stimulus_analysis.drifting_gratings.f1_f0(arr, tf, trial_duration)[source]

Computes F1/F0 of a drifting grating response

Parameters:
arr

DataArray with trials x bin-times

tf

temporal frequency of the stimulus

Returns:
f1_f0float

metric

allensdk.brain_observatory.ecephys.stimulus_analysis.drifting_gratings.modulation_index(response_psth, tf, sample_rate)[source]

Depth of modulation by each cycle of a drifting grating; similar to F1/F0

ref: Matteucci et al. (2019) Nonlinear processing of shape information

in rat lateral extrastriate cortex. J Neurosci 39: 1649-1670

Parameters:
response_pstharray of floats

the binned responses of a unit for a given stimuli

tffloat

the temporal frequency

sample_ratefloat

the sampling rate of response_psth

Returns:
modulation_indexfloat

the mi value