<jupyter_start><jupyter_text>Old Development; record keeping.<jupyter_code># path to tracking data
datPath = '/Users/alexgonzalez/Google Drive/PostDoc/Data/T3g/Li/Li_T3g_060418/VT1.nvt'
t,x,y,ha = load_nvt2(datPath)
plt.scatter(x,y,1,alpha=0.05)
xs,ys = ScaleRotateSmoothTrackDat(x,y)
f,a=plt.subplots(1,1, figsize=(6,6))
a.scatter(xs,ys,1,alpha=0.05)
PosZones = getMazeZones(xs,ys)
def plotPoly(poly,ax,alpha=0.3,color='g'):    
    p1x,p1y = poly.exterior.xy
    ax.plot(p1x, p1y, color='k', alpha=alpha,
        linewidth=3,)
    ring_patch = PolygonPatch(poly, fc=color, ec='none', alpha=alpha)
    ax.add_patch(ring_patch)
f,a1=plt.subplots(1,1, figsize=(10,10))
for zo in MazeZonesGeom.keys():
    plotPoly(MazeZonesGeom[zo],a1)
    
a1.plot(xs,ys,alpha=0.1,color='k',linewidth=0.1)
a1.scatter(xs,ys,20, alpha=0.005,color='k')
a1.grid() 

def transition_matrix(transitions):
    n = 1+ max(transitions) #number of states

    M = [[0]*n for _ in range(n)]

    for (i,j) in zip(transitions,transitions[1:]):
        M[i][j] += 1

    return M
def getPosSequence(t,PosZones):
    nPos = len(PosZones)
    out = []
    out.append((t[0],PosZones[0]))
    for p in np.arange(1,nPos-1):
        p0 = PosZones[p]
        p1 = PosZones[p+1]
        if p0!=p1:
            out.append((t[p1],p1))
    return out
M = pd.DataFrame(transition_matrix(PosZones),columns=Zones.values(),index=Zones.values())
M
f,a1=plt.subplots(1,1, figsize=(16,6))
a=Counter(PosZones)
counts,_ = np.histogram(PosZones,np.arange(nZones+1))
zoneIDs = np.arange(nZones)
a1.bar(np.arange(nZones), counts)
a1.set_yscale('log')
#a1.set_yticks([100,200, 500, 1000])
a1.set_xticks(np.arange(nZones))
a1.set_xticklabels(Zones.values())
a1.get_yaxis().set_major_formatter(ticker.ScalarFormatter())
a1.grid()

for tick in a1.get_xticklabels():
    tick.set_rotation(45)

counts, ids=np.histogram(PosZones,np.arange(nZones+1))
print(len(counts),counts,ids)
prob = counts/np.sum(counts)
cnt = 0
f,a1=plt.subplots(1,1, figsize=(10,10))
a1.grid() 

for zo in Zones.values():
    plotPoly(MazeZonesGeom[zo],a1,alpha=prob[cnt])
    cnt+=1
f,a1=plt.subplots(1,1, figsize=(12,6))
window = np.arange(5000)+5000*5
a1.plot(t[window]-t[0],PosZones[window])
a1.set_yticks(np.arange(nZones))
a1.set_yticklabels(Zones.values())
a1.grid()
M = PosZones2Mat(PosZones)  
window = np.arange(5000)+5000*5
f,a1=plt.subplots(1,1, figsize=(12,8))

sns.heatmap(M[window,:].T,ax=a1,yticklabels=ZonesNames,cbar=0,cmap='Greys_r',vmax=1.3)
a1.hlines(np.arange(21), *a1.get_xlim(),color='red')
#a1.xaxis.set_major_formatter(FormatStrFormatter('%.2f'))
x=a1.get_xticks().astype(int)
_=a1.set_xticklabels(np.round(t[window[x]]).astype(int))<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.18985936343449297, 'fraction_numerical': 0.057364914877868246, 'mean_word_length': 5.791457286432161, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '133865', 'license': 'MIT', 'n_tokens_mistral': 1301, 'n_tokens_neox': 1227, 'n_words': 148, 'path': 'Notebooks/define_TreeMaze_Zones_Test_Imports.ipynb', 'repo_name': 'alexgonzl/TreeMazeAnalyses', 'size': '2702'}