pynapple.io.EphysReader#

class pynapple.io.EphysReader(path: str | Path, lazy: bool = True, format: str | type | None = None)[source]#

Bases: UserDict

Read Neo-compatible electrophysiology files into pynapple objects (i.e. Neurosuite, OpenEphys, Plexon, etc).

Neo is a Python package for working with electrophysiology data, supporting many file formats through a unified API.

This class provides a dictionary-like interface to Neo files, with lazy-loading support. It automatically detects the appropriate IO based on the file extension.

Neo to Pynapple Object Conversion#

The following Neo objects are converted to their pynapple equivalents:

Neo Object

Pynapple Object

Notes

AnalogSignal

Tsd, TsdFrame, or TsdTensor

Depends on shape; lazy-loaded

IrregularlySampledSignal

Tsd, TsdFrame, or TsdTensor

Depends on shape; lazy-loaded

SpikeTrain

Ts

Single unit

SpikeTrain (list)

TsGroup

Multiple units

Epoch

IntervalSet

Event

Ts

Note: All data types support lazy loading. Data is only loaded when accessed via __getitem__ (e.g., data["TsGroup"]).

param path:

Path to the file to load or directory containing the files.

type path:

str or Path

param lazy:

Whether to use lazy loading

type lazy:

bool, default True

param format:

Specify the Neo IO format to use. Can be:

  • None: Automatically detect the format using neo.io.get_io

  • str: Name of the IO class (e.g., "PlexonIO", "Plexon", "plexon")

  • type: A class from neo.io.iolist (e.g., neo.io.PlexonIO)

When a string is provided, it is matched case-insensitively against IO class names. The “IO” suffix is optional.

type format:

str, type, or None, default None

Examples

>>> import pynapple as nap
>>> data = nap.EphysReader("my_file.plx")
>>> print(data)
my_file
┍━━━━━━━━━━━━━━━━━━━━━┯━━━━━━━━━━┑
│ Key                 │ Type     │
┝━━━━━━━━━━━━━━━━━━━━━┿━━━━━━━━━━┥
│ TsGroup             │ TsGroup  │
│ Tsd 0: LFP          │ Tsd      │
┕━━━━━━━━━━━━━━━━━━━━━┷━━━━━━━━━━┙
>>> spikes = data["TsGroup"]
>>> lfp = data["Tsd 0: LFP"]

To explicitly specify the file format:

>>> data = nap.EphysReader("my_file.plx", format="PlexonIO")
__init__(path: str | Path, lazy: bool = True, format: str | type | None = None)[source]#

Methods

__init__(path[, lazy, format])

clear()

close()

Close the underlying Neo reader if it supports closing.

copy()

fromkeys(iterable[, value])

get(k[,d])

items()

Return key-value pairs (loads data on access).

keys()

Return available data keys.

pop(k[,d])

If key is not found, d is returned if given, otherwise KeyError is raised.

popitem()

as a 2-tuple; but raise KeyError if D is empty.

setdefault(k[,d])

update([E, ]**F)

If E present and has a .keys() method, does: for k in E: D[k] = E[k] If E present and lacks .keys() method, does: for (k, v) in E: D[k] = v In either case, this is followed by: for k, v in F.items(): D[k] = v

values()

Return all values (loads all data).

clear() None.  Remove all items from D.#
close()[source]#

Close the underlying Neo reader if it supports closing.

copy()#
classmethod fromkeys(iterable, value=None)#
get(k[, d]) D[k] if k in D, else d.  d defaults to None.#
items()[source]#

Return key-value pairs (loads data on access).

keys()[source]#

Return available data keys.

pop(k[, d]) v, remove specified key and return the corresponding value.#

If key is not found, d is returned if given, otherwise KeyError is raised.

popitem() (k, v), remove and return some (key, value) pair#

as a 2-tuple; but raise KeyError if D is empty.

setdefault(k[, d]) D.get(k,d), also set D[k]=d if k not in D#
update([E, ]**F) None.  Update D from mapping/iterable E and F.#

If E present and has a .keys() method, does: for k in E: D[k] = E[k] If E present and lacks .keys() method, does: for (k, v) in E: D[k] = v In either case, this is followed by: for k, v in F.items(): D[k] = v

values()[source]#

Return all values (loads all data).