forked from ant-trullo/SegmentTrack_v4.0
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBurstStatisticWriter.py
109 lines (88 loc) · 5.44 KB
/
BurstStatisticWriter.py
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
"""This function writes an .xls file with all statistical info on bursts."""
import numpy as np
# import xlwt
import xlsxwriter
class BurstStatisticWriter:
"""Main class, does all the job"""
def __init__(self, fwritename, features_3D):
id = features_3D.statistics_info[:, 0].size
step_info = int((features_3D.statistics_info.shape[1] - 3) / 5.0)
# book = xlwt.Workbook(encoding='utf-8')
# sheet1 = book.add_sheet("Sheet 1")
# sheet2 = book.add_sheet("Sheet
book = xlsxwriter.Workbook(str(fwritename) + '/Bursts_Statistics.xlsx') # write results
sheet1 = book.add_worksheet("Sheet1")
sheet2 = book.add_worksheet("Sheet2")
sheet1.write(0, 0, "Nuclei ID")
sheet1.write(0, 1, "Numb of Bursts")
sheet1.write(0, 2, "Busts av ampl")
sheet1.write(0, 2 + step_info, "Bursts integ ampl")
if 2 + step_info < 256:
sheet1.write(0, 2 + step_info * 2, "Bursts durations")
else:
sheet2.write(0, 2 + step_info * 2 - 256, "Bursts durations")
if 2 + step_info * 3 < 256:
sheet1.write(0, 2 + step_info * 3, "Number of Off")
else:
sheet2.write(0, 2 + step_info * 3 - 256, "Number of Off")
if 3 + step_info * 3 < 256:
sheet1.write(0, 3 + step_info * 3, "Off durations")
else:
sheet2.write(0, 3 + step_info * 3 - 256, "Off durations")
for k in range(id):
sheet1.write(k + 1, 0, "Nuc_" + str(np.int(features_3D.statistics_info[k, 0])))
sheet1.write(k + 1, 1, np.int(features_3D.statistics_info[k, 1]))
if 2 + step_info * 3 < 256:
sheet1.write(k + 1, 2 + step_info * 3, features_3D.statistics_info[k, 2 + 4 * step_info])
else:
sheet2.write(k + 1, 2 + step_info * 3 - 256, features_3D.statistics_info[k, 2 + 4 * step_info])
for j in range(step_info):
if features_3D.statistics_info[k, 2 + 3 * step_info + j] != 0:
if 2 + j < 256:
sheet1.write(k + 1, 2 + j, features_3D.statistics_info[k, 2 + 3 * step_info + j])
else:
sheet2.write(k + 1, 2 + j - 256, features_3D.statistics_info[k, 2 + 3 * step_info + j])
if features_3D.statistics_info[k, 2 + 2 * step_info + j] != 0:
if 2 + step_info + j < 256:
sheet1.write(k + 1, 2 + step_info + j, features_3D.statistics_info[k, 2 + 2 * step_info + j])
else:
sheet2.write(k + 1, 2 + step_info + j - 256, features_3D.statistics_info[k, 2 + 2 * step_info + j])
if features_3D.statistics_info[k, 2 + j] != 0:
if 2 + 2 * step_info + j < 256:
sheet1.write(k + 1, 2 + 2 * step_info + j, features_3D.statistics_info[k, 2 + j])
else:
sheet2.write(k + 1, 2 + 2 * step_info + j - 256, features_3D.statistics_info[k, 2 + j])
if features_3D.statistics_info[k, 3 + 4 * step_info + j] != 0:
if 3 + 3 * step_info + j < 256:
sheet1.write(k + 1, 3 + 3 * step_info + j, features_3D.statistics_info[k, 3 + 4 * step_info + j])
else:
sheet2.write(k + 1, 3 + 3 * step_info + j - 256, features_3D.statistics_info[k, 3 + 4 * step_info + j])
# book.save(str(fwritename) + '/Bursts_Statistics.xls')
book.close()
# class BurstStatisticWriter:
# def __init__(self, fwritename, features_3D):
# id = features_3D.statistics_info[:, 0].size
# step_info = int((features_3D.statistics_info.shape[1] - 3) / 5.0)
# book = xlwt.Workbook(encoding='utf-8')
# sheet1 = book.add_sheet("Sheet 1")
# sheet1.write(0, 0, "Nuclei ID")
# sheet1.write(0, 1, "Numb of Bursts")
# sheet1.write(0, 2, "Busts av ampl")
# sheet1.write(0, 2 + step_info, "Bursts integ ampl")
# sheet1.write(0, 2 + step_info * 2, "Bursts durations")
# sheet1.write(0, 2 + step_info * 3, "Number of Off")
# sheet1.write(0, 3 + step_info * 3, "Off durations")
# for k in range(id):
# sheet1.write(k + 1, 0, "Nuc_" + str(np.int(features_3D.statistics_info[k, 0])))
# sheet1.write(k + 1, 1, np.int(features_3D.statistics_info[k, 1]))
# sheet1.write(k + 1, 2 + step_info * 3, features_3D.statistics_info[k, 2 + 4 * step_info])
# for j in range(step_info):
# if features_3D.statistics_info[k, 2 + 3 * step_info + j] != 0:
# sheet1.write(k + 1, 2 + j, features_3D.statistics_info[k, 2 + 3 * step_info + j])
# if features_3D.statistics_info[k, 2 + 2 * step_info + j] != 0:
# sheet1.write(k + 1, 2 + step_info + j, features_3D.statistics_info[k, 2 + 2 * step_info + j])
# if features_3D.statistics_info[k, 2 + j] != 0:
# sheet1.write(k + 1, 2 + 2 * step_info + j, features_3D.statistics_info[k, 2 + j])
# if features_3D.statistics_info[k, 3 + 4 * step_info + j] != 0:
# sheet1.write(k + 1, 3 + 3 * step_info + j, features_3D.statistics_info[k, 3 + 4 * step_info + j])
# book.save(str(fwritename) + '/Bursts_Statistics.xls')