analyze_GW_2D.py 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. import pandas as pd
  2. import matplotlib.pyplot as plt
  3. from scipy import signal
  4. import numpy as np
  5. import math
  6. import easygui
  7. from master_funcs import *
  8. import dill
  9. import dataframe_image as dfi
  10. patients=['PB_T2_3_1', 'PB_T2_3_2', 'PB_T2_3_3', 'PB_T2_4_2', 'PB_T2_5_1', 'PB_T2_6_1', 'PB_T2_6_2', 'PB_T3_23_1', 'PB_T3_23_2', 'PB_T3_23_3', 'PB_T3_24_1', 'PB_T3_24_2', 'PB_T3_24_3']
  11. for z in patients:
  12. print(z)
  13. pathway='/home/user/owncloud/3D_videos/GW_2D/'+z+'_P3_GW_camera-1DLC_resnet50_GridWalk_camera-1Jun15shuffle1_250000.csv'
  14. data=prep_dlc(pathway, 0.9, 1080)
  15. names=[i[0] for i in data.columns[::3]]
  16. for j in names:
  17. data[j, 'x']=data[j, 'x'].interpolate(method='polynomial', order=1)
  18. data[j, 'y']=data[j, 'y'].interpolate(method='polynomial', order=1)
  19. dill.load_session('/home/user/Documents/Master/GW_2D_'+z+'_data_save.pkl')
  20. ff=[math.nan]
  21. length=[len(data), len(df_vel_acc1)]
  22. for i in range(0, np.min(length)):
  23. if (df_vel_acc1['angle_acceleration_shoulder_right_forepaw_right_shoulder_left'][i]>30) and (df_vel_acc1['angle_shoulder_right_forepaw_right_shoulder_left'][i]>140):
  24. ff.append(i)
  25. print('footfault at ', i)
  26. if z=='PB_T2_3_1':
  27. footfault_2d=pd.DataFrame([ff], index=[z])
  28. else:
  29. footfault_2d_temp=pd.DataFrame([ff], index=[z])
  30. footfault_2d=footfault_2d.append(footfault_2d_temp)
  31. pred_rfc_footfault_2d = best_model.predict(X_test)
  32. det_footfault_2d=np.where(pred_rfc_footfault_2d)
  33. if z=='PB_T2_3_1':
  34. footfault_FI_2d=pd.DataFrame(det_footfault_2d, index=[z])
  35. else:
  36. footfault_FI_temp_2d=pd.DataFrame(det_footfault_2d, index=[z])
  37. footfault_FI_2d=footfault_FI_2d.append(footfault_FI_temp_2d)
  38. footfault_2d.columns=['Non Footfault']+['Footfault']*(footfault_2d.shape[1]-1)
  39. dfi.export(footfault_2d, '/home/user/owncloud/thesis_figures/DLC_GW_2d.png')