In [1]:
%pylab nbagg
import pandas as pd
In [2]:
print('Rg1 = {:.2f}'.format((np.sqrt(3/2) * np.sqrt(2 * 4 * 0.5**2 / 5)).round(2)))
print('Rg2 = {:.2f}'.format((np.sqrt(3/2) * np.sqrt((4 + 4 * 2**2) / 5)).round(2)))
In [24]:
Mcov = np.cov(np.array([[-0.5,-0.5], [-0.5, 0.5], [0.5, -0.5], [0.5, 0.5], [0,0]]), rowvar = 0, bias = 1)
eigs = np.linalg.eigvals(Mcov)
ecc1 = np.max(eigs) / np.min(eigs)
print('ecc1 = {:.2f}'.format(ecc1))
Mcov = np.cov(np.array([[8, 1], [8, 3], [12, 1], [12, 3], [10,2]]), rowvar = 0, bias = 1)
eigs = np.linalg.eigvals(Mcov)
ecc2 = np.max(eigs) / np.min(eigs)
print('ecc2 = {:.2f}'.format(ecc2))
In [6]:
numPoints = 10 # 2 clusters, 5 points each
# Creates two ground truth clusters, one at (0,0) and another at (10,2)
locs = pd.DataFrame(np.vstack((np.array([[-0.5,-0.5], [-0.5, 0.5], [0.5, -0.5], [0.5, 0.5], [0,0]]),
np.array([[8, 1], [8, 3], [12, 1], [12, 3], [10,2]]))),
index = np.arange(0, numPoints),
columns = ['x [nm]', 'y [nm]'])
locs = pd.concat([locs, pd.DataFrame(np.zeros(numPoints),
index = np.arange(0, numPoints),
columns = ['frame'])], axis = 1)
locs = pd.concat([locs, pd.DataFrame(columns = ['z [nm]',
'uncertainty [nm]',
'intensity [photon]',
'offset [photon]',
'loglikelihood',
'sigma [nm]',
'cluster_id'],
index = np.arange(0,numPoints))], axis = 1)
locs['z [nm]'] = np.zeros(numPoints)
locs['uncertainty [nm]'] = 10 * np.ones(numPoints) + np.random.randn(numPoints)
locs['intensity [photon]'] = 1000 * np.ones(numPoints) + 100 * np.random.randn(numPoints)
locs['offset [photon]'] = 100 * np.ones(numPoints) + 10 * np.random.randn(numPoints)
locs['loglikelihood'] = 180 * np.ones(numPoints) + 30 * np.random.randn(numPoints)
locs['sigma [nm]'] = 140 * np.ones(numPoints) + 20 * np.random.randn(numPoints)
locs['cluster_id'] = np.vstack((np.zeros((5,1), dtype = np.int16), np.ones((5,1), dtype = np.int16)))
locs.sort_values('frame', inplace = True)
locs.index = np.arange(0, locs.shape[0])
In [8]:
locs
Out[8]:
In [9]:
locs.describe()
Out[9]:
In [15]:
plt.scatter(locs['x [nm]'], locs['y [nm]'])
plt.grid(True)
plt.axis('equal')
plt.show()
In [16]:
locs.to_csv('test_cluster_stats.csv', index = False)
In [ ]: