跳转到主要内容

解析Open Ephys数据的Python包。

项目描述

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

pyopenephys

Open Ephys的Python读取器。

安装

为了安装pyopenephys包,打开终端并运行

pip install pyopenephys

如果您想从源代码安装并获取最新更新,克隆仓库并在本地安装

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

基本用法

Pyopenephys允许用户加载使用Open Ephys记录的数据。目前,仅支持二进制(推荐)和openephys(未来版本将不再支持此格式)。

第一步是创建一个File对象。只需传递记录文件夹的路径即可。

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

文件对象包含不同的实验(对应不同的设置文件),每个实验包含一组记录。

# 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]

实验存储了一些有用的信息

  • experiment.datetime包含实验创建的起始日期和时间
  • experiment.sig_chain是一个包含信号链中的处理器和节点的字典
  • experiment.settings是一个包含解析后的setting.xml文件的字典
  • experiment.acquisition_system包含用于输入连续数据(例如'Rhythm FPGA')的系统

记录包含实际数据

  • recording.duration是记录的持续时间(以秒为单位)
  • recording.sample_rate是采样频率(以Hz为单位)
  • recording.analog_signalsAnalogSignal对象的列表,这些对象又具有signaltimes(以s为单位)和channel_id字段。
  • recording.eventsEventData对象的列表,这些对象又具有times(以s为单位)、channelschannel_statesfull_wordsprocessornode_idmetadata字段。
  • recording.tracking 是一个 TrackingData 对象的列表,每个对象都有 times(以秒为单位),xywidthheightchannelsmetadata 字段。跟踪数据使用 Tracking 插件(https://github.com/CINPLA/tracking-plugin)记录,并以 二进制 格式保存(不是 openephys 格式)。
  • recording.spiketrains 是一个 SpikeTrain 对象的列表,每个对象都有 timeswaveformselectrode_indicesclustersmetadata 字段。Spiketrains 由 Open Ephys GUI 中的 Spike Viewer 源保存,与 Spike DetectorSpike Viewer 结合使用。

只需几行代码,就可以轻松解析和访问数据和相关信息

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()

项目详情


下载文件

下载适用于您平台的文件。如果您不确定该选择哪个,请了解更多关于 安装包 的信息。

源分发

pyopenephys-1.2.0.tar.gz (30.4 kB 查看哈希值)

上传时间

构建分发

pyopenephys-1.2.0-py3-none-any.whl (28.8 kB 查看哈希值)

上传时间 Python 3

由以下组织支持

AWS AWS 云计算和安全赞助商 Datadog Datadog 监控 Fastly Fastly CDN Google Google 下载分析 Microsoft Microsoft PSF赞助商 Pingdom Pingdom 监控 Sentry Sentry 错误日志 StatusPage StatusPage 状态页面