1

我正在使用 Allen Brain Observatory 的笔记本:http ://alleninstitute.github.io/AllenSDK/_static/examples/nb/brain_observatory.html

当我运行单元格 16 和 17 时,运行单元格 17 后出现此错误:

AttributeError:“DataFrame”对象没有属性“orientation”

这是两个单元格的代码:

from allensdk.brain_observatory.drifting_gratings import DriftingGratings

# example loading drifing grating data
#data_set = boc.get_ophys_experiment_data(512326618)
dg = DriftingGratings(data_set)
print("done analyzing drifting gratings")

import numpy as np
from matplotlib import pyplot as plt
%matplotlib inline

# filter for visually responding, selective cells
vis_cells = (dg.peak.ptest_dg < 0.05) &  (dg.peak.peak_dff_dg > 3)
osi_cells = vis_cells & (dg.peak.osi_dg > 0.5) & (dg.peak.osi_dg <= 1.5)
dsi_cells = vis_cells & (dg.peak.dsi_dg > 0.5) & (dg.peak.dsi_dg <= 1.5)

# 2-d tf vs. ori histogram
# tfval = 0 is used for the blank sweep, so we are ignoring it here
os = np.zeros((len(dg.orivals), len(dg.tfvals)-1))
ds = np.zeros((len(dg.orivals), len(dg.tfvals)-1))

for i,trial in dg.peak[osi_cells].iterrows():
    os[trial.ori_dg, trial.tf_dg-1] += 1

for i,trial in dg.peak[dsi_cells].iterrows():
    ds[trial.ori_dg, trial.tf_dg-1] += 1

max_count = max(os.max(), ds.max())

fig, (ax1, ax2) = plt.subplots(1,2)

# plot direction selectivity
im = ax1.imshow(ds, clim=[0,max_count], cmap='hot', interpolation='nearest')
ax1.set_xlabel('temporal frequency')
ax1.set_ylabel('direction')
ax1.set_xticks(np.arange(len(dg.tfvals)-1))
ax1.set_xticklabels(dg.tfvals[1:])
ax1.set_yticks(np.arange(len(dg.orivals)))
ax1.set_yticklabels(dg.orivals)
ax1.set_title('direction selective cells')

# plot orientation selectivity
im = ax2.imshow(os, clim=[0,max_count], cmap='hot', interpolation='nearest')
ax2.set_xlabel('temporal frequency')
ax2.set_ylabel('orientation')
ax2.set_xticks(np.arange(len(dg.tfvals)-1))
ax2.set_xticklabels(dg.tfvals[1:])
ax2.set_yticks(np.arange(len(dg.orivals)))
ax2.set_yticklabels(dg.orivals)
ax2.set_title('orientation selective cells')

# plot a colorbar
fig.subplots_adjust(right=0.9)
cbar_ax = fig.add_axes([0.95, 0.05, 0.05, 0.85])
cbar = fig.colorbar(im, cax=cbar_ax)
cbar.set_ticks(np.arange(0, max_count, 2)+0.5)
cbar.set_ticklabels(np.arange(0, max_count, 2, dtype=int))

plt.show()

Traceback 中指向的行是:

vis_cells = (dg.peak.ptest_dg < 0.05) &  (dg.peak.peak_dff_dg > 3)

任何帮助表示赞赏。我想使用“allensdk”标签,但我没有 1500 声望。

4

1 回答 1

0

你能帮我确认你正在使用python3吗?我们正在尝试解决与 py3 相关的许多问题(主要是 h5py 和 PyTables)——事实上,我昨天遇到了这个问题。

问题是刺激表列名是从 NWB 文件中读取的,python 3 中的字节('b')字符串与 pandas 列索引不兼容。

解决方法是修补这一行:

https://github.com/AllenInstitute/AllenSDK/blob/master/allensdk/core/brain_observatory_nwb_data_set.py#L834

将字符串解码为 utf-8。它看起来像这样:

features = [ f.decode('UTF-8') for f in features ]

如果你现在喜欢,我可以将它滚动到 master 分支。否则,6 月将发布另一个包含此修复程序的版本。我认为那时我们还没有完全支持 python3,但我们正在努力。

于 2017-04-18T07:09:38.983 回答