Skip to main content

Build Status Project Status: Active - The project has reached a stable, usable state and is being actively developed.

pyopenephys

Python reader for Open Ephys.

Installation

In order to install the pyopenephys package, open a terminal and run:

pip install pyopenephys

If you want to install from sources and get the latest updates, clone the repo and install locally:

git clone https://github.com/CINPLA/pyopenephys
cd pyopenephys
python setup.py install 
# use 'python setup.py develop' to install fixed bugs 

Basic Usage

Pyopenephys allows the user to load data recorded with Open Ephys. Currently, only the binary (recommended) and openephys (support for this format will be dropped in future releases) are supported.

The first step is creating a File object. It only requires to pass the paht to the recording folder.

import pyopenephys
file = pyopenephys.File("path-to-recording-folder") 

The file object contains the different experiments (corresponding to different settings files) and each experiment contains a set of recordings.

# all experiments
experiments = file.experiments
print(len(experiments))

# recordings of first experiment
experiment = experiments[0]
recordings = experiment.recordings
print(len(experiments))

# access first recording
recording = recordings[0]

Experiments store some useful information:

  • experiment.datetime contains the starting date and time of the experiment creation
  • experiment.sig_chain is a dictionary containing the processors and nodes in the signal chain
  • experiment.settings is a dictionary with the parsed setting.xml file
  • experiment.acquisition_system contains the system used to input continuous data (e.g. 'Rhythm FPGA')

Recordings contain the actual data:

  • recording.duration is the duration of the recording (in seconds)
  • recording.sample_rate is the sampling frequency (in Hz)
  • recording.analog_signals is list of AnalogSignal objects, which in turn have a signal, times (in s), and channel_id fields.
  • recording.events is list of EventData objects, which in turn have a times (in s), channels, channel_states, full_words, processor, node_id, and metadata fields.
  • recording.tracking is list of TrackingData objects , which in turn have a times (in s), x, y, width, height, channels, and metadata fields. Tracking data are recorded with the Tracking plugin (https://github.com/CINPLA/tracking-plugin) and are save in binary format only (not in openephys format).
  • recording.spiketrains is list of SpikeTrain objects, which in turn have a times, waveforms, electrode_indices, clusters and metadata fields. Spiketrains are saved by the Spike Viewer sink in the Open Ephys GUI, in combination with either the Spike Detector and Spike Viewer.

With a few lines of code, the data and relevant information can be easily parsed and accessed:

import pyopenephys
import matplotlib.pylab as plt

file = pyopenephys.File("path-to-recording-folder") 
# experiment 1 (0 in Python)
experiment = file.experiments[0]
# recording 1 
recording = experiment.recordings[0]

print('Duration: ', recording.duration)
print('Sampling Rate: ', recording.sample_rate)

analog_signals = recording.analog_signals
events_data = recording.events
spiketrains = recording.spiketrains
# tracking_data are accessible only using binary format
tracking_data = recording.tracking

# plot analog signal of channel 4
signals = analog_signals[0]
fig_an, ax_an = plt.subplots()
ax_an.plot(signals.times, signals.signal[3])

# plot raster for spike trains
fig_sp, ax_sp = plt.subplots()
for i_s, sp in enumerate(spiketrains):
    ax_sp.plot(sp.times, i_s*np.ones(len(sp.times)), '|')

plt.show()

Metadata

Release files for pyopenephys 1.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pyopenephys 1.2.0
File Size Uploaded
pyopenephys-1.2.0.tar.gz 30.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pyopenephys 1.2.0
File Interpreter ABI Platform
pyopenephys-1.2.0-py3-none-any.whl Python 3 none any Details

Total release size: 59.2 kB

Release files / pyopenephys-1.2.0.tar.gz

Download URL pyopenephys-1.2.0.tar.gz
Size 30.4 kB
Tags Source
SHA-256 checksum
How to use checksums
788b4c8dc8c27cfd71a9253b16eda89e3b0451511bc6d9ab467b05dfcbb1f305
BLAKE2b-256 checksum
How to use checksums
131f71c5ace82332c1c16880911f46438bff51df8c20f7a2373a5df6ad760300
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.5

Release files / pyopenephys-1.2.0-py3-none-any.whl

Download URL pyopenephys-1.2.0-py3-none-any.whl
Size 28.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
0c0c5c6080441f2dee738c091796dbee7eb83a9a121331b2b49c75e624f0ca8e
BLAKE2b-256 checksum
How to use checksums
157333e4b0399afe11e1962066509907501fbfe6a6a129009bd161681d2c285d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.5

Release history Release notifications | RSS feed

This release

1.2.0 This release

2 release files

1.1.6

2 release files

1.1.5

2 release files

1.1.4

2 release files

1.1.3

2 release files

1.1.2

2 release files

1.1.1

2 release files

1.1.0

2 release files

1.0.7

1 release file

1.0.6

2 release files

1.0.5

2 release files

1.0.4

1 release file

1.0.3

1 release file

1.0.2

1 release file

1.0.0

1 release file

0.1.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page