|
@@ -1,7 +1,7 @@
|
|
|
#!/usr/bin/env python
|
|
|
# coding: utf-8
|
|
|
|
|
|
-database_path = '/media/andrey/My Passport/GIN/backup_Anesthesia_CA1/meta_data/meta_recordings - anesthesia.xlsx'
|
|
|
+database_path = '/media/andrey/My Passport/GIN_new/Anesthesia_CA1/meta_data/meta_recordings - anesthesia.xlsx'
|
|
|
|
|
|
|
|
|
# ### Select the range of recordings for the analysis (see "Number" row in the meta data file)
|
|
@@ -54,6 +54,8 @@ start_quiet_period = np.zeros((len(rec),number_of_quiet_periods),dtype='int')
|
|
|
|
|
|
stop_quiet_period = np.zeros((len(rec),number_of_quiet_periods),dtype='int')
|
|
|
|
|
|
+n_quiet_periods_in_recording = np.zeros((len(rec)),dtype='int')
|
|
|
+
|
|
|
|
|
|
for i, r in enumerate(rec):
|
|
|
|
|
@@ -74,17 +76,23 @@ for i, r in enumerate(rec):
|
|
|
#plt.plot(stat.item(0)['yoff'],alpha=0.5)
|
|
|
#plt.plot(stat.item(0)['xoff'],alpha=0.5)
|
|
|
|
|
|
- motion_index[i,:len(stat.item(0)['yoff'])] = stat.item(0)['yoff']
|
|
|
+ motion_index[i,:len(stat.item(0)['yoff'])] = np.sqrt(stat.item(0)['yoff']**2 + stat.item(0)['xoff']**2)
|
|
|
|
|
|
print("Min motion index:", min(motion_index[i,:]))
|
|
|
print("Max motion index:", max(motion_index[i,:]))
|
|
|
|
|
|
recording_length[i] = len(stat.item(0)['yoff'])
|
|
|
+
|
|
|
print("Recording length:", recording_length[i])
|
|
|
- print("Quiet periods: ", type(meta_data['Quiet periods'][r]),type('str'))
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
if (type(meta_data['Quiet periods'][r]) == type('str')):
|
|
|
print("Quiet periods: ", meta_data['Quiet periods'][r].split(','))
|
|
|
- for k in range(int(len(meta_data['Quiet periods'][r].split(','))/2)):
|
|
|
+
|
|
|
+ n_quiet_periods_in_recording[i] = int(len(meta_data['Quiet periods'][r].split(','))/2)
|
|
|
+
|
|
|
+ for k in range(n_quiet_periods_in_recording[i]):
|
|
|
start_quiet_period[i,k] = int(meta_data['Quiet periods'][r].split(',')[k*2])
|
|
|
stop_quiet_period[i,k] = int(meta_data['Quiet periods'][r].split(',')[k*2+1])
|
|
|
print(start_quiet_period[i,k])
|
|
@@ -92,53 +100,55 @@ for i, r in enumerate(rec):
|
|
|
else:
|
|
|
print("Nan for recording:", r)
|
|
|
start_quiet_period[i,0] = 0
|
|
|
- stop_quiet_period[i,0] = recording_length[i]
|
|
|
-
|
|
|
+ stop_quiet_period[i,0] = recording_length[i]
|
|
|
|
|
|
-# np.save("./xy-motion.npy",motion_index)
|
|
|
+#np.save("./xy-motion.npy",motion_index)
|
|
|
|
|
|
-mi = motion_index
|
|
|
+#mi = motion_index
|
|
|
|
|
|
-#mi = np.load("./xy-motion.npy")
|
|
|
+mi = np.load("./xy-motion.npy")
|
|
|
|
|
|
print(np.max(mi))
|
|
|
|
|
|
print(np.min(mi))
|
|
|
|
|
|
-mi_av = np.mean(mi[:,:9000].reshape(mi.shape[0],100,90), axis=2)
|
|
|
+mi_av = np.mean(mi[:,:18000].reshape(mi.shape[0],60,300), axis=2)
|
|
|
plt.rcParams["axes.grid"] = False
|
|
|
|
|
|
-plt.figure(figsize = (15,10))
|
|
|
+plt.figure(figsize = (10,15))
|
|
|
+
|
|
|
+pos = plt.imshow(mi_av,cmap='Purples',vmin = 0, vmax = 10) #,aspect='equal'
|
|
|
|
|
|
-plt.imshow(mi_av,cmap='RdBu',vmin = -10, vmax = 10,aspect='equal')
|
|
|
+plt.colorbar(pos)
|
|
|
|
|
|
|
|
|
-for k in range(int(number_of_quiet_periods/2)):
|
|
|
- plt.scatter(start_quiet_period[0:len(rec),k]/90,np.arange(len(rec)),marker=9,color='k',label='start of quite period')
|
|
|
- plt.scatter(stop_quiet_period[0:len(rec),k]/90,np.arange(len(rec)),marker=8,color='k',label='end of quite period')
|
|
|
+for i in range(len(rec)):
|
|
|
+ for k in range(int(n_quiet_periods_in_recording[i])):
|
|
|
+ line = plt.scatter(start_quiet_period[i,k]/300,i,marker='>',color='k',s = 10,label='start of quiet period')
|
|
|
+ line.set_clip_on(False)
|
|
|
+ line = plt.scatter(stop_quiet_period[i,k]/300,i,marker='<',color='k',s = 10, label='end of quiet period')
|
|
|
+ line.set_clip_on(False)
|
|
|
|
|
|
+line = plt.scatter(recording_length[0:len(rec)]/300, np.arange(len(rec)) ,marker='|',color='k', s = 10, label='end of the recording')
|
|
|
+line.set_clip_on(False)
|
|
|
|
|
|
-plt.scatter(recording_length[0:len(rec)]/90, np.arange(len(rec)) ,marker='|',color='k',label='end of the recording')
|
|
|
|
|
|
-plt.legend(loc='upper right')
|
|
|
+#plt.legend(loc='upper right')
|
|
|
|
|
|
-plt.xlabel('x 90 frames')
|
|
|
+plt.xlabel('x 300 frames')
|
|
|
plt.ylabel('recording')
|
|
|
|
|
|
-plt.title('Transition state dataset motion validation')
|
|
|
+plt.title('Anesthesia dataset motion validation')
|
|
|
|
|
|
#plt.gcf().set_facecolor("white")
|
|
|
|
|
|
-plt.xlim([0,100])
|
|
|
+plt.xlim([0,60])
|
|
|
+
|
|
|
+line.set_clip_on(False)
|
|
|
|
|
|
plt.savefig("Validation_motion.png")
|
|
|
plt.savefig("Validation_motion.svg")
|
|
|
|
|
|
-#import plotly.express as px
|
|
|
-#import numpy as np
|
|
|
-
|
|
|
-#fig = px.imshow(mi, color_continuous_scale='RdBu_r',zmin = -10, zmax = 10)
|
|
|
-#fig.show()
|
|
|
|
|
|
|
|
|
plt.show()
|