allensdk.brain_observatory.ecephys.stimulus_analysis.natural_scenes module

class allensdk.brain_observatory.ecephys.stimulus_analysis.natural_scenes.NaturalScenes(ecephys_session, col_image='frame', trial_duration=0.25, **kwargs)[source]

Bases: allensdk.brain_observatory.ecephys.stimulus_analysis.stimulus_analysis.StimulusAnalysis

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

To use, pass in a EcephysSession object::
session = EcephysSession.from_nwb_path(‘/path/to/my.nwb’) ns_analysis = NaturalScenes(session)
or, alternatively, pass in the file path::
ns_analysis = NaturalScenes(‘/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:

ns_analysis = NaturalScenes(session, filter={'location': 'probeC', 'ecephys_structure_acronym': 'VISp'})
To get a table of the individual unit metrics ranked by unit ID::
metrics_table_df = ns_analysis.metrics()
METRICS_COLUMNS
frames
images

Array of iamge labels

images_nonblank
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.

metrics

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

name

Return the stimulus name.

null_condition

Stimulus condition ID for null (blank) stimulus

number_images

Number of images shown

number_nonblank

Number of images shown (excluding blank condition)

allensdk.brain_observatory.ecephys.stimulus_analysis.natural_scenes.image_selectivity(spike_means, num_steps=1000)[source]

Quantifies how selective a cell is for images, based on Quian Quiroga et al., 2007. A value of 0 indicates the cell responds the same no mater what the image. While if the neuron only responds to a single image it will have a selectivity of 1 - 2/N (1.0 and N goes to inf).

Parameters:
spike_means : array of floats

Averaged spiking responses to a series of images for a given neuron

num_steps : int

Number of threshold values used to build response distribution (default to 1000 as in Quian paper)

Returns:
selectivity : float

selectivity of neuron to images