neo_tools - Utility functions to manipulate Neo objects

Tools to manipulate Neo objects.

elephant.neo_tools.extract_neo_attrs(obj, parents=True, child_first=True, skip_array=False, skip_none=False)[source]

Given a neo object, return a dictionary of attributes and annotations.

Parameters:
obj : neo object
parents : bool, optional

Also include attributes and annotations from parent neo objects (if any).

child_first : bool, optional

If True (default True), values of child attributes are used over parent attributes in the event of a name conflict. If False, parent attributes are used. This parameter does nothing if parents is False.

skip_array : bool, optional

If True (default False), skip attributes that store non-scalar array values.

skip_none : bool, optional

If True (default False), skip annotations and attributes that have a value of None.

Returns:
dict

A dictionary where the keys are annotations or attribute names and the values are the corresponding annotation or attribute value.

elephant.neo_tools.get_all_epochs(container)[source]

Get all neo.Epoch objects from a container.

The objects can be any list, dict, or other iterable or mapping containing epochs, as well as any neo object that can hold epochs: neo.Block and neo.Segment.

Containers are searched recursively, so the objects can be nested (such as a list of blocks).

Parameters:
container : list, tuple, iterable, dict, neo Block, neo Segment

The container for the epochs.

Returns:
list

A list of the unique neo.Epoch objects in container.

elephant.neo_tools.get_all_events(container)[source]

Get all neo.Event objects from a container.

The objects can be any list, dict, or other iterable or mapping containing events, as well as any neo object that can hold events: neo.Block and neo.Segment.

Containers are searched recursively, so the objects can be nested (such as a list of blocks).

Parameters:
container : list, tuple, iterable, dict, neo Block, neo Segment

The container for the events.

Returns:
list

A list of the unique neo.Event objects in container.

elephant.neo_tools.get_all_spiketrains(container)[source]

Get all neo.Spiketrain objects from a container.

The objects can be any list, dict, or other iterable or mapping containing spiketrains, as well as any neo object that can hold spiketrains: neo.Block, neo.ChannelIndex, neo.Unit, and neo.Segment.

Containers are searched recursively, so the objects can be nested (such as a list of blocks).

Parameters:
container : list, tuple, iterable, dict,

neo Block, neo Segment, neo Unit, neo ChannelIndex The container for the spiketrains.

Returns:
list

A list of the unique neo.SpikeTrain objects in container.