Skip to main content

Python package for parsing Open Ephys data.

Project description

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

pyopenephys

Python reader for Open Ephys (www.open-ephys.org).

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/py-open-ephys
cd py-open-ephys
python setup.py install (or develop)

Basic Usage

Pyopenephys allows the user to load data recorded with the 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 = experiment1.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 nodeIds in the signal chain
  • experiment.settings is a dictionary woth 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: ', recoridng.duration)
print('Sampling Rate: ', recoridng.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()

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyopenephys-1.0.5.tar.gz (11.9 kB view details)

Uploaded Source

Built Distribution

pyopenephys-1.0.5-py3-none-any.whl (12.9 kB view details)

Uploaded Python 3

File details

Details for the file pyopenephys-1.0.5.tar.gz.

File metadata

  • Download URL: pyopenephys-1.0.5.tar.gz
  • Upload date:
  • Size: 11.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.4.2 requests/2.21.0 setuptools/40.6.3 requests-toolbelt/0.9.1 tqdm/4.28.1 CPython/3.7.1

File hashes

Hashes for pyopenephys-1.0.5.tar.gz
Algorithm Hash digest
SHA256 a28bde9377cf52b9a37f3ea0598d8dfc97b555ed6d282f21fa20a83d693ee97d
MD5 0d9fa16c36855308927c7d4aed3b7140
BLAKE2b-256 33c0c301767a4ad07e8f22c264deb877f15be01f0416d6f4105e25fd5aaa1e05

See more details on using hashes here.

File details

Details for the file pyopenephys-1.0.5-py3-none-any.whl.

File metadata

  • Download URL: pyopenephys-1.0.5-py3-none-any.whl
  • Upload date:
  • Size: 12.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.4.2 requests/2.21.0 setuptools/40.6.3 requests-toolbelt/0.9.1 tqdm/4.28.1 CPython/3.7.1

File hashes

Hashes for pyopenephys-1.0.5-py3-none-any.whl
Algorithm Hash digest
SHA256 4d228a8143539759dcf6875e80e22ebdf4180a3f802069f9caba0c505aca3f8c
MD5 dfd50e5980b2b41958119831c1f26e32
BLAKE2b-256 f7ff511b181ea17a690c85847fa2914cb1ba288a0c16acbbb658a3b4dab191c1

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page