In [2]:
%matplotlib inline
import pandas as pd
import matplotlib
import matplotlib.pyplot as plt
import matplotlib.dates as md
from matplotlib.patches import Rectangle
import numpy as np
import datetime
In [3]:
# load a database for a stack
filepath = './a5n/stackdb/a5n_s0_db2.txt'
df = pd.read_csv(
filepath,
header=1)
# look at rows 35 to 45
df[35:45]
Out[3]:
In [4]:
# plot x/y position of all points
plt.scatter(df['x'], df['y'])
Out[4]:
In [5]:
#grab a datframe of just spines
spines = df[df['roiType'] == 'spineROI']
plt.figure(figsize=(8,4))
# plot x/y posiiton of just spines
fig1 = plt.subplot(1,2,1)
fig1.scatter(spines['x'], spines['y'])
# plot and colorize by segment
fig2 = plt.subplot(1,2,2)
fig2.scatter(spines['x'], spines['y'], c=spines['parentID'])
# set the proper scale of the plot
# read the first line from the file (the header)
with open(filepath, 'U') as f:
header = f.readline()
#THIS ALMOST WORKS
#print header
#keys = k, v = [i.split('=') for i in header.split(';')]
xVoxel, yVoxel = 0.2, 0.2 # um
pixelsPerLine, linesPerFrame = 1024, 1024
xWidth, yWidth = pixelsPerLine * xVoxel, linesPerFrame * yVoxel
plt.xlim([0,xWidth])
plt.ylim([0,yWidth])
Out[5]:
In [6]:
# plot just one segment
thisParentID = 11
oneSegment = df[(df['roiType'] == 'spineROI') & (df['parentID'] == thisParentID)]
plt.scatter(oneSegment['x'], oneSegment['y'])
plt.xlim([0,xWidth])
plt.ylim([0,yWidth])
Out[6]:
In [7]:
# plot position on dendrite line for each segment
# don't really need sort to make this plot but will use in future
sortedSpines = spines.sort(['parentID','pDist'])
c = sortedSpines['parentID']
plt.scatter(sortedSpines['parentID'], sortedSpines['pDist'], c=c)
Out[7]:
In [ ]: