我正在使用 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 声望。