-
Notifications
You must be signed in to change notification settings - Fork 0
/
0-analysis.py
155 lines (69 loc) · 2.28 KB
/
0-analysis.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
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
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
# %%
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import data_import as di
import epoch_times as et
import deltaF_cal as dfc
import session_plot as sp # Import the session plot module.
from scipy.interpolate import interp1d
# %%
#specify numpy file F.npy
F_file_path = r''
F_file_path = r'F.npy'
xml_filepath = r'TSeries-08212023-1221-989-1-003.xml'
#%%
path_pycontrol_txt = r'989-2023-08-21-132131.txt'
pyc_session = di.session_dataframe(path_pycontrol_txt)
F = np.load(F_file_path)
#import voltage data as npy array
# V_file_path = r'E:\June\June\998-4-1TSeries-06142023-2113-187\TSeries-06142023-2113-187_Cycle00001_VoltageRecording_001.csv'
# V = np.genfromtxt(V_file_path, delimiter=',')
# V = V[1:,1:]
# x_old = np.arange(V.shape[0])
# x_new = np.linspace(0, V.shape[0]-1, 2750)
# f_new = interp1d(x_old, V, axis=0)
# interpolated_array = f_new(x_new)
# #convert to dataframe
# interpolated_pyc_session = pd.DataFrame(interpolated_array)
# interpolated_pyc_session.plot()
# %%
f_df = pd.DataFrame(F)
#convert the rows to columns
f_df = f_df.transpose()
F = f_df.to_numpy()
F.shape
# %%
frame_details = et.get_frame_details(xml_filepath)
events_as_columns = et.py_control_df_conversion(path_pycontrol_txt)
# %%
print(frame_details)
# %%
sp.session_plot('pycontrol/989-2023-08-21-132015.txt')
# %%
events_as_columns['photodetector'].plot()
# %%
events_as_columns.to_csv('events_as_columns.csv')
# %%
#correct jitter of the photodetector
events_as_columns_corrected = et.correct_gaps_photodetector(events_as_columns)
# %%
timepoints = et.get_orientation_indices_v2(events_as_columns_corrected)
# %%
#get the keyframes
keyframes = et.get_closest_frame_s2p(timepoints, frame_details)
events_as_columns_corrected = et.add_orientation_columns(events_as_columns_corrected, keyframes)
events_as_columns_corrected['photodetector'].plot()
# %%
deltaF = dfc.delta_fify(F).transpose()
events_as_columns_corrected.to_csv('test.csv')
# %%
deltaF
# %%
deltaF[20].plot()
# %%
delta_F = et.add_orientation_columns(deltaF, keyframes)
# %%
keyframes
# %%
delta_F.to_csv('test.csv')