I am using the Allen Brain Observatory's notebook at: http://alleninstitute.github.io/AllenSDK/_static/examples/nb/brain_observatory.html
When I run cells 16 and 17, after running cell 17 I get this error:
AttributeError: 'DataFrame' object has no attribute 'orientation'
Here is the code of both cells:
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()
The line pointed to in the Traceback is:
vis_cells = (dg.peak.ptest_dg < 0.05) & (dg.peak.peak_dff_dg > 3)
Any help is appreciated. I wanted to use the 'allensdk' tag but I don't have 1500 reputation.