-
Notifications
You must be signed in to change notification settings - Fork 26
Expand file tree
/
Copy pathmulticolourMeta.py
More file actions
143 lines (123 loc) · 4.16 KB
/
Copy pathmulticolourMeta.py
File metadata and controls
143 lines (123 loc) · 4.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
#!/usr/bin/python
##################
# multicolourMeta.py
#
# Copyright David Baddeley, 2010
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##################
"""
Extract dye infomation / statistics from sample database
"""
from PYME.misc.djangoRecarray import qsToRecarray
from SampleDB2 import populateStats
from SampleDB2.samples import models
import numpy as np
import matplotlib.pyplot as plt
#from pylab import *
CHANNELS = [ 'A680', 'A647','A750',]
PAIRS = [('A750', 'A647'),('A750', 'A680'), ]
def getChannel(chan):
return qsToRecarray(models.EventStats.objects.filter(label=chan))
def getChannelPair(chan1, chan2):
files = models.File.objects.filter(event_stats__label=chan1).filter(event_stats__label=chan2)
r1 = qsToRecarray(models.EventStats.objects.filter(fileID__in=files, label=chan1))
r2 = qsToRecarray(models.EventStats.objects.filter(fileID__in=files, label=chan2))
return r1, r2
def drawChannelGraphs(chan):
r = getChannel(chan)
plt.figure(1)
n, b = np.histogram(r['nEvents'], np.linspace(0, 4e5,50))
plt.errorbar((b[:-1] + b[1:])/2., n/float(len(r)), np.sqrt(n)/float(len(r)), lw=2, label=chan)#, where='post')
#print n.max()
plt.xlabel('# Events')
plt.ylabel('Frequency')
plt.legend()
plt.figure(2)
n, b = np.histogram(r['meanPhotons'], np.linspace(0, 6e3, 30))
#errorbar((b[:-1] + b[1:])/2., n/float(len(r)), sqrt(n)/float(len(r)), lw=2, label=chan)#, where='pre')
plt.plot((b[:-1] + b[1:])/2., n/float(len(r)), lw=2, label=chan)
plt.xlabel('Mean Photon #')
plt.ylabel('Frequency')
plt.legend()
plt.figure(5)
plt.plot(r['meanPhotons'], r['nEvents'], '.', ms=3, label=chan)
#print n.max()
plt.ylabel('Num Events')
plt.xlabel('Mean Photon #')
plt.xlim(0, 4e3)
plt.ylim(0, 4e5)
#axis('equal')
#ylim(0, 4e5)
#xlim(0, (7./6)*4e5)
#gca().set_aspect('equal')
#title('Number of Events')
plt.legend()
plt.figure(6)
n, b = np.histogram(r['tMedian'], np.linspace(0, 1e3, 20))
plt.step((b[:-1] + b[1:])/2., n/float(len(r)), lw=2, label=chan, where='mid')#, where='pre')
plt.xlabel('Median decay time')
plt.ylabel('Frequency')
plt.legend()
plt.figure(7)
plt.plot(r['tMedian'], r['nEvents'], '.', ms=3, label=chan)
#print n.max()
plt.ylabel('Num Events')
plt.xlabel('Median decay time')
#xlim(0, 4e3)
#ylim(0, 4e5)
#axis('equal')
#ylim(0, 4e5)
#xlim(0, (7./6)*4e5)
#gca().set_aspect('equal')
#title('Number of Events')
plt.legend()
def drawPairwiseGraphs(chan1, chan2):
r1, r2 = getChannelPair(chan1, chan2)
print((len(r1), len(r2)))
plt.figure(3)
plt.plot(r1['nEvents'], r2['nEvents'], '.', ms=3, label=chan2)
#print n.max()
plt.ylabel('A647 / A680')
plt.xlabel(chan1)
#axis('equal')
plt.ylim(0, 4e5)
plt.xlim(0, (7./6)*4e5)
plt.gca().set_aspect('equal')
plt.title('Number of Events')
plt.legend()
plt.figure(4)
plt.plot(r1['meanPhotons'], r2['meanPhotons'], '.', ms=3, label=chan2)
#print n.max()
plt.xlabel(chan1)
plt.ylabel('A647 / A680')
plt.ylim(0, 4e3)
plt.xlim(0, (7./6)*4e3)
plt.gca().set_aspect('equal')
plt.title('Mean Photon Number')
plt.legend()
def drawGraphs():
plt.close('all')
#for c in CHANNELS:
# drawChannelGraphs(c)
#for cp in PAIRS:
# drawPairwiseGraphs(*cp)
plt.figure(8)
N = [getChannel(c)['meanPhotons'] for c in CHANNELS]
plt.hist(N, np.linspace(0, 6e3, 30), normed=1)
plt.xlabel('Mean Photon #')
plt.ylabel('Frequency')
#legend()