用于计算神经科学的时间序列同步工具包
项目描述
理论
Theonerig(读作“the one rig”)是一个包,用于对齐和过滤以不同时间获取的数据流,以促进进一步的处理管道。
安装
到目前为止还没有简单的安装,只需从 github 克隆文件夹并在文件夹中使用 pip 安装它。我们还建议您使用 conda 创建环境:
conda create -n torpython=3.6
activate tor适用于 windows 或source activate torlinux/mac
pip install packaging
pip install -e .
稍后我们会将其放在 pip 上,以便您可以使用pip install theonerig
如何使用
一些示例数据位于“文件”文件夹中。我们将使用来自 Asari Lab @ EMBL Rome 的子文件夹“vivo_2p”中的数据。
这个库背后的主要思想是使用主时间序列来同步来自不同来源的其他数据流。完成后,它可以轻松地对数据进行切片并将其应用于任何处理。
切片变得简单
实验存储在 Record_Master 对象(这里称为 reM)中:每一行显示与“main_tp”对齐的数据流。
数据可以是稀疏的,这意味着您不必在记录的总持续时间内拥有每一行的数据,并且可以在多个块中。
reM.plot()
现在我们有了这样的数据集,我们将使用这个包的第二个主要特性,Data_Pipe。有了它,我们在它的创建时选择我们想要获得的行。在这种情况下,我们采用“棋盘”,这是一个刺激值矩阵,“S_matrix”是从钙成像中提取的神经元的响应,“eye_tracking”考虑到鼠标眼睛的位置来计算响应。
pipe = Data_Pipe(reM, ["checkerboard", "S_matrix", "eye_tracking"])
现在已经定义了管道,我们可以使用算术和逻辑操作来选择我们想要从记录的哪一部分获取数据:
pipe += "checkerboard" #Add part of the data where checkerboard is present
reM.plot()
pipe.plot()
pipe[0]["S_matrix"].shape
(36000, 2)
#Select all cell responses where there is no stimulus
pipe += "S_matrix"
pipe -= "stim" #use the fact that data are within a class [sync, data, stim, cell] to filter them all at the same time
reM.plot()
pipe.plot()
#Select all cell responses where there is a stimulus. Note the darkness stimulus longer
#than the corresponding S_matrix
pipe += "S_matrix" #Add all the chuncks of data where there is an S_matrix
pipe &= "stim" #use the fact that data are within a class [sync, data, stim, cell] to filter them all at the same time
reM.plot()
pipe.plot()
然后,可以迭代管道并将每个分离的数据块作为包含每个选定数据的字典返回
print(pipe[0].keys())
for data_dict in pipe:
print(data_dict["checkerboard"].shape, data_dict["S_matrix"].shape, data_dict["eye_tracking"].shape)
dict_keys(['checkerboard', 'S_matrix', 'eye_tracking'])
(23303, 15, 20) (23303, 2) (23303, 5)
(36000, 15, 20) (36000, 2) (36000, 5)
(36000, 15, 20) (36000, 2) (36000, 5)
(40800, 15, 20) (40800, 2) (40800, 5)
(10200, 15, 20) (10200, 2) (10200, 5)
(8680, 15, 20) (8680, 2) (8680, 5)
(18000, 15, 20) (18000, 2) (18000, 5)
注意这里的棋盘。我们只拥有一个块的实际数据,但是因为为每个数据集设置了默认值,所以管道能够为记录的每个部分返回一个数据集。这允许轻松解决缺少数据的记录而不会崩溃。
导出您的同步记录或导入您朋友的记录
一旦 reM 处于最终状态,就这样导出它
export_record("path/for/my/record/reM_coolname.h5", reM)
如您所见,记录采用 .h5 格式,因此可以使用任何其他 H5 解决方案对其进行探索和导入。
但最好的方法还是用 theonerig 打开它!
import_record("path/for/my/record/reM_coolname.h5")
项目详情
下载文件
下载适用于您平台的文件。如果您不确定要选择哪个,请了解有关安装包的更多信息。