plugin Package

This package provides support for writing plugins for Spyke Viewer. It belongs to spykeutils so that plugins can be executed in an evironment where the spykeviewer package and its dependencies are not installed (e.g. servers).

spykeutils installs a script named “spykeplugin” that can be used to start plugins directly from the command line, supplying selection and plugin parameter information. It is also the default script that Spyke Viewer uses when starting plugins remotely. If you want to implement your own script for starting plugins remotely, e.g. on a server, you should conform to the interface of this script.

analysis_plugin Module

class AnalysisPlugin[source]

Bases: spykeutils.plugin.gui_data.DataSet

Base class for Analysis plugins. Inherit this class to create a plugin.

The two most important methods are get_name() and start(). Both should be overridden by every plugin. The class also has functionality for GUI configuration and saving/restoring analysis results.

The GUI configuration uses guidata. Because AnalysisPlugin inherits from DataSet, configuration options can easily be added directly to the class definition. For example, the following code creates an analysis that has two configuration options which are used in the start() method to print to the console:

from spykeutils.plugin.analysis_plugin import AnalysisPlugin

class ExampleAnalysis(AnalysisPlugin):
    some_time = di.FloatItem('Some time', default=2.0, unit='ms')
    print_more = di.BoolItem('Print additional info', default=True)

    def start(self, current, selections):
        print 'The selected time is', some_time, 'milliseconds.'
        if print_more:
            print 'This is important additional information!'

The class attribute data_dir contains a base directory for saving and loading data. It is set by Spyke Viewer to the directory specified in the settings. When using an AnalysisPlugin without Spyke Viewer, the default value is an empty string (so the current directory will be used) and the attribute can be set to an arbitrary directory.

configure()[source]

Configure the analysis. Override if a different or additional configuration apart from guidata is needed.

get_name()[source]

Return the name of an analysis. Override to specify analysis name.

Returns:The name of the plugin.
Return type:str
get_parameters()[source]

Return a dictionary of the configuration that can be read with deserialize_parameters(). Override both if non-guidata attributes need to be serialized or if some guidata parameters should not be serialized (e.g. they only affect the visual presentation).

Returns:A dictionary of all configuration parameters.
Return type:dict
load(name, selections, params=None, consider_guiparams=True)[source]

Return the most recent HDF5 file for a certain parameter configuration. If no such file exists, return None. This function works with the files created by save().

Parameters:
  • name (str) – The name of the results to load.
  • selections (sequence) – A list of DataProvider objects that are relevant for the analysis results.
  • params (dict) – A dictionary, indexed by strings (which should be valid as python identifiers), with parameters apart from GUI configuration used to obtain the results. All keys have to be integers, floats, strings or lists of these types.
  • consider_guiparams (bool) – Determines if the guidata parameters of the class should be considered if they exist in the HDF5 file. This should be set to False if save() is used with save_guiparams set to False.
Returns:

An open PyTables file object ready to be used to read data. Afterwards, the file has to be closed by calling the tables.File.close() method. If no appropriate file exists, None is returned.

Return type:

tables.File

save(name, selections, params=None, save_guiparams=True)[source]

Return a HDF5 file object with parameters already stored. Save analysis results to this file.

Parameters:
  • name (str) – The name of the results to save. A folder with this name will be used (and created if necessary) to store the analysis result files.
  • selections (sequence) – A list of DataProvider objects that are relevant for the analysis results.
  • params (dict) – A dictionary, indexed by strings (which should be valid as python identifiers), with parameters apart from GUI configuration used to obtain the results. All keys have to be integers, floats, strings or lists of these types.
  • save_guiparams (bool) – Determines if the guidata parameters of the class should be saved in the file.
Returns:

An open PyTables file object ready to be used to store data. Afterwards, the file has to be closed by calling the tables.File.close() method.

Return type:

tables.File

set_parameters(parameters)[source]

Load configuration from a dictionary that has been created by serialize_parameters(). Override both if non-guidata attributes need to be serialized or if some guidata parameterss hould not be serialized (e.g. they only affect the visual presentation).

Parameters:parameters (dict) – A dictionary of all configuration parameters.
start(current, selections)[source]

Entry point for processing. Override with analysis code.

Parameters:
  • current (spykeviewer.plugin_framework.data_provider.DataProvider) – This data provider is used if the analysis should be performed on the data currently selected in the GUI.
  • selections (list) – This parameter contains all saved selections. It is used if an analysis needs multiple data sets.

data_provider Module

class DataProvider(name, progress)[source]

Bases: object

Defines all methods that should be implemented by a selection/data provider class.

A DataProvider encapsulates access to a selection of data. It can be used by plugins to acesss data currently selected in the GUI or in saved selections. It also contains an attribute progress, a spykeutils.progress_indicator.ProgressIndicator that can be used to report the progress of an operation (and is used by methods of this class if they can lead to processing times of half a second or more).

This class serves as an abstract base class and should not be instantiated.

analog_signal_arrays()[source]

Return a list of neo.core.AnalogSignalArray objects.

analog_signal_arrays_by_channelgroup()[source]

Return a dictionary (indexed by RecordingChannelGroup) of lists of neo.core.AnalogSignalArray objects.

If analog signals arrays not attached to a RecordingChannel are selected, their dictionary key will be DataProvider.no_channelgroup.

analog_signal_arrays_by_channelgroup_and_segment()[source]

Return a dictionary (indexed by RecordingChannelGroup) of dictionaries (indexed by Segment) of neo.core.AnalogSignalArray objects.

If there are multiple analog signals in one RecordingChannel for the same Segment, only the first will be contained in the returned dictionary. If analog signal arrays not attached to a Segment or RecordingChannelGroup are selected, their dictionary key will be DataProvider.no_segment or DataProvider.no_channelgroup, respectively.

analog_signal_arrays_by_segment()[source]

Return a dictionary (indexed by Segment) of lists of neo.core.AnalogSignalArray objects.

If analog signals arrays not attached to a Segment are selected, their dictionary key will be DataProvider.no_segment.

analog_signal_arrays_by_segment_and_channelgroup()[source]

Return a dictionary (indexed by RecordingChannelGroup) of dictionaries (indexed by Segment) of neo.core.AnalogSignalArray objects.

If there are multiple analog signals in one RecordingChannel for the same Segment, only the first will be contained in the returned dictionary. If analog signal arrays not attached to a Segment or RecordingChannelGroup are selected, their dictionary key will be DataProvider.no_segment or DataProvider.no_channelgroup, respectively.

analog_signals(conversion_mode=1)[source]

Return a list of neo.core.AnalogSignal objects.

Parameters:conversion_mode (int) –

Determines what signals are returned:

  1. AnalogSignal objects only
  2. AnalogSignal objects extracted from AnalogSignalArrays only
  3. Both AnalogSignal objects and extracted AnalogSignalArrays
analog_signals_by_channel(conversion_mode=1)[source]

Return a dictionary (indexed by RecordingChannel) of lists of neo.core.AnalogSignal objects.

If analog signals not attached to a RecordingChannel are selected, their dictionary key will be DataProvider.no_channel.

Parameters:conversion_mode (int) –

Determines what signals are returned:

  1. AnalogSignal objects only
  2. AnalogSignal objects extracted from AnalogSignalArrays only
  3. Both AnalogSignal objects and extracted AnalogSignalArrays
analog_signals_by_channel_and_segment(conversion_mode=1)[source]

Return a dictionary (indexed by RecordingChannel) of dictionaries (indexed by Segment) of neo.core.AnalogSignal lists.

If analog signals not attached to a Segment or RecordingChannel are selected, their dictionary key will be DataProvider.no_segment or DataProvider.no_channel, respectively.

Parameters:conversion_mode (int) –

Determines what signals are returned:

  1. AnalogSignal objects only
  2. AnalogSignal objects extracted from AnalogSignalArrays only
  3. Both AnalogSignal objects and extracted AnalogSignalArrays
analog_signals_by_segment(conversion_mode=1)[source]

Return a dictionary (indexed by Segment) of lists of neo.core.AnalogSignal objects.

If analog signals not attached to a Segment are selected, their dictionary key will be DataProvider.no_segment.

Parameters:conversion_mode (int) –

Determines what signals are returned:

  1. AnalogSignal objects only
  2. AnalogSignal objects extracted from AnalogSignalArrays only
  3. Both AnalogSignal objects and extracted AnalogSignalArrays
analog_signals_by_segment_and_channel(conversion_mode=1)[source]

Return a dictionary (indexed by Segment) of dictionaries (indexed by RecordingChannel) of neo.core.AnalogSignal lists.

If analog signals not attached to a Segment or RecordingChannel are selected, their dictionary key will be DataProvider.no_segment or DataProvider.no_channel, respectively.

Parameters:conversion_mode (int) –

Determines what signals are returned:

  1. AnalogSignal objects only
  2. AnalogSignal objects extracted from AnalogSignalArrays only
  3. Both AnalogSignal objects and extracted AnalogSignalArrays
blocks()[source]

Return a list of selected Block objects.

The returned objects will contain all regular references, not just to selected objects.

data_dict()[source]

Return a dictionary with all information to serialize the object.

epoch_arrays()[source]

Return a dictionary (indexed by Segment) of lists of EpochArray objects.

epochs(include_array_epochs=True)[source]

Return a dictionary (indexed by Segment) of lists of Epoch objects.

Parameters:include_array_epochs (bool) – Determines if EpochArray objects should be converted to Epoch objects and included in the returned list.
event_arrays()[source]

Return a dictionary (indexed by Segment) of lists of EventArray objects.

events(include_array_events=True)[source]

Return a dictionary (indexed by Segment) of lists of Event objects.

Parameters:include_array_events (bool) – Determines if EventArray objects should be converted to Event objects and included in the returned list.
classmethod from_data(data, progress=None)[source]

Create a new DataProvider object from a dictionary. This method is mostly for internal use.

The respective type of DataProvider (e.g. spykeviewer.plugin_framework.data_provider_neo.DataProviderNeo has to be imported in the environment where this function is called.

Parameters:
  • data (dict) – A dictionary containing data from a DataProvider object, as returned by data_dict().
  • progress (ProgressIndicator) – The object where loading progress will be indicated.
labeled_epochs(label, include_array_epochs=True)[source]

Return a dictionary (indexed by Segment) of lists of Epoch objects with the given label.

Parameters:
  • label (str) – The name of the Epoch objects to be returnded
  • include_array_epochs (bool) – Determines if EpochArray objects should be converted to Epoch objects and included in the returned list.
labeled_events(label, include_array_events=True)[source]

Return a dictionary (indexed by Segment) of lists of Event objects with the given label.

Parameters:
  • label (str) – The name of the Event objects to be returnded
  • include_array_events (bool) – Determines if EventArray objects should be converted to Event objects and included in the returned list.
num_analog_signal_arrays()[source]

Return the number of neo.core.AnalogSignalArray objects.

num_analog_signals(conversion_mode=1)[source]

Return the number of neo.core.AnalogSignal objects.

Parameters:conversion_mode (int) –

Determines what signals are included:

  1. AnalogSignal objects only
  2. AnalogSignal objects extracted from AnalogSignalArrays only
  3. Both AnalogSignal objects and extracted AnalogSignalArrays
recording_channel_groups()[source]

Return a list of selected RecordingChannelGroup objects.

The returned objects will contain all regular references, not just to selected objects.

recording_channels()[source]

Return a list of selected RecordingChannel objects.

The returned objects will contain all regular references, not just to selected objects.

refresh_view()[source]

Refresh associated views of the data.

Use this method if when you change the neo hierarchy on which the selection is based (e.g. adding or removing objects). It will ensure that all current views on the data are updated, for example in Spyke Viewer.

segments()[source]

Return a list of selected Segment objects.

The returned objects will contain all regular references, not just to selected objects.

selection_blocks()[source]

Return a list of selected blocks.

The returned blocks will contain references to all other selected elements further down in the object hierarchy, but no references to elements which are not selected. The returned hierarchy is a copy, so changes made to it will not persist. The main purpose of this function is to provide an object hierarchy that can be saved to a neo file. It is not recommended to use it for data processing, the respective functions that return objects lower in the hierarchy are better suited for that purpose.

spike_trains()[source]

Return a list of neo.core.SpikeTrain objects.

spike_trains_by_segment()[source]

Return a dictionary (indexed by Segment) of lists of neo.core.SpikeTrain objects.

If spike trains not attached to a Segment are selected, their dictionary key will be DataProvider.no_segment.

spike_trains_by_segment_and_unit()[source]

Return a dictionary (indexed by Unit) of dictionaries (indexed by Segment) of neo.core.SpikeTrain objects.

If there are multiple spike trains in one Segment for the same Unit, only the first will be contained in the returned dictionary. If spike trains not attached to a Unit or Segment are selected, their dictionary key will be DataProvider.no_unit or DataProvider.no_segment, respectively.

spike_trains_by_unit()[source]

Return a dictionary (indexed by Unit) of lists of neo.core.SpikeTrain objects.

If spike trains not attached to a Unit are selected, their dicionary key will be DataProvider.no_unit.

spike_trains_by_unit_and_segment()[source]

Return a dictionary (indexed by Unit) of dictionaries (indexed by Segment) of neo.core.SpikeTrain objects.

If there are multiple spike trains in one Segment for the same Unit, only the first will be contained in the returned dictionary. If spike trains not attached to a Unit or Segment are selected, their dictionary key will be DataProvider.no_unit or DataProvider.no_segment, respectively.

spikes()[source]

Return a list of neo.core.Spike objects.

spikes_by_segment()[source]

Return a dictionary (indexed by Segment) of lists of neo.core.Spike objects.

If spikes not attached to a Segment are selected, their dictionary key will be DataProvider.no_segment.

spikes_by_segment_and_unit()[source]

Return a dictionary (indexed by Segment) of dictionaries (indexed by Unit) of lists of neo.core.Spike lists.

If spikes not attached to a Unit or Segment are selected, their dictionary key will be DataProvider.no_unit or DataProvider.no_segment, respectively.

spikes_by_unit()[source]

Return a dictionary (indexed by Unit) of lists of neo.core.Spike objects.

If spikes not attached to a Unit are selected, their dicionary key will be DataProvider.no_unit.

spikes_by_unit_and_segment()[source]

Return a dictionary (indexed by Unit) of dictionaries (indexed by Segment) of neo.core.Spike lists.

If there are multiple spikes in one Segment for the same Unit, only the first will be contained in the returned dictionary. If spikes not attached to a Unit or Segment are selected, their dictionary key will be DataProvider.no_unit or DataProvider.no_segment, respectively.

units()[source]

Return a list of selected Unit objects.

The returned objects will contain all regular references, not just to selected objects.

gui_data Module

This module gives access to all members of guidata.dataset.dataitems and guidata.dataset.datatypes. If guidata cannot be imported, the module offers suitable dummy objects instead (e.g. for use on a server).

Project Versions

Table Of Contents

Previous topic

spykeutils.plot package

Next topic

Changelog

This Page