figures.py 44 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605
  1. import matplotlib.pyplot as plt
  2. import numpy as np
  3. import pandas as pd
  4. from master_funcs import *
  5. from collections import Counter
  6. from imblearn.over_sampling import SMOTE
  7. from imblearn.under_sampling import RandomUnderSampler
  8. from imblearn.pipeline import Pipeline
  9. import dill
  10. #%matplotlib qt
  11. import scipy
  12. import seaborn as sn
  13. import pingouin as pg
  14. import warnings
  15. import dataframe_image as dfi
  16. warnings.filterwarnings("ignore")
  17. ## Manual Rater Results Table
  18. # ============================================================================================================================================
  19. mr_cyl_1=pd.read_csv("/home/user/owncloud/3D_videos/manual_raters/Manual_Cylinder_Analyse_Jan_figure.csv", index_col=0, delimiter=',', header=0)
  20. mr_cyl_2=pd.read_csv("/home/user/owncloud/3D_videos/manual_raters/Manual_Cylinder_Analyse_Nicole_figure.csv", index_col=0, delimiter=',', header=0)
  21. mr_cyl_3=pd.read_csv("/home/user/owncloud/3D_videos/manual_raters/Manual_Cylinder_Analyse_Jule_figure.csv", index_col=0, delimiter=',', header=0)
  22. mr_gw_1=pd.read_csv("/home/user/owncloud/3D_videos/manual_raters/Manual_GridWalk_Analyse_Jan_figure.csv", index_col=0, delimiter=',', header=0)
  23. mr_gw_2=pd.read_csv("/home/user/owncloud/3D_videos/manual_raters/Manual_GridWalk_Analyse_Nicole_figure.csv", index_col=0, delimiter=',', header=0)
  24. mr_gw_3=pd.read_csv("/home/user/owncloud/3D_videos/manual_raters/Manual_GridWalk_Analyse_Jule_figure.csv", index_col=0, delimiter=',', header=0)
  25. dfi.export(mr_cyl_1, '/home/user/owncloud/thesis_figures/MR_CY_1.png', max_cols=51)
  26. dfi.export(mr_cyl_2, '/home/user/owncloud/thesis_figures/MR_CY_2.png', max_cols=51)
  27. dfi.export(mr_cyl_3, '/home/user/owncloud/thesis_figures/MR_CY_3.png', max_cols=51)
  28. dfi.export(mr_gw_1, '/home/user/owncloud/thesis_figures/MR_GW_1.png')
  29. dfi.export(mr_gw_2, '/home/user/owncloud/thesis_figures/MR_GW_2.png')
  30. dfi.export(mr_gw_3, '/home/user/owncloud/thesis_figures/MR_GW_3.png')
  31. # ============================================================================================================================================
  32. ## Correlation Feature Footfault within MR and between MR and DLC plus FI 2D and 3D
  33. # ============================================================================================================================================
  34. mr_cyl_1=pd.read_csv("/home/user/owncloud/3D_videos/manual_raters/Manual_GridWalk_Analyse_Jan.csv", index_col=0, delimiter=',', header=None)
  35. mr_cyl_2=pd.read_csv("/home/user/owncloud/3D_videos/manual_raters/Manual_GridWalk_Analyse_Nicole.csv", index_col=0, delimiter=',', header=None)
  36. mr_cyl_3=pd.read_csv("/home/user/owncloud/3D_videos/manual_raters/Manual_GridWalk_Analyse_Jule.csv", index_col=0, delimiter=',', header=None)
  37. 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_3', 'PB_T3_24_1', 'PB_T3_24_2', 'PB_T3_24_3']
  38. max_i=np.array([np.nanmax(mr_cyl_1.loc['PB_T2_3_1']), np.nanmax(mr_cyl_2.loc['PB_T2_3_1']), np.nanmax(mr_cyl_3.loc['PB_T2_3_1']), np.nanmax(footfault_2d.loc['PB_T2_3_1']), np.nanmax(footfault_FI_2d.loc['PB_T2_3_1']), np.nanmax(footfault_3d.loc['PB_T2_3_1']), np.nanmax(footfault_FI_3d.loc['PB_T2_3_1'])])
  39. mr_cyl_1_corr=np.zeros(shape=(int(np.nanmax(max_i)+11),))
  40. mr_cyl_2_corr=np.zeros(shape=(int(np.nanmax(max_i)+11),))
  41. mr_cyl_3_corr=np.zeros(shape=(int(np.nanmax(max_i)+11),))
  42. footfault_2d_corr=np.zeros(shape=(int(np.nanmax(max_i)+11),))
  43. footfault_FI_2d_corr=np.zeros(shape=(int(np.nanmax(max_i)+11),))
  44. footfault_3d_corr=np.zeros(shape=(int(np.nanmax(max_i)+11),))
  45. footfault_FI_3d_corr=np.zeros(shape=(int(np.nanmax(max_i)+11),))
  46. for i in mr_cyl_1.loc['PB_T2_3_1']:
  47. if i>0:
  48. mr_cyl_1_corr[int(i-15):int(i+16)]=1
  49. for i in mr_cyl_2.loc['PB_T2_3_1']:
  50. if i>0:
  51. mr_cyl_2_corr[int(i-15):int(i+16)]=1
  52. for i in mr_cyl_3.loc['PB_T2_3_1']:
  53. if i>0:
  54. mr_cyl_3_corr[int(i-15):int(i+16)]=1
  55. for i in footfault_2d.loc['PB_T2_3_1']:
  56. if i>0:
  57. footfault_2d_corr[int(i-15):int(i+16)]=1
  58. for i in footfault_FI_2d.loc['PB_T2_3_1']:
  59. if i>0:
  60. footfault_FI_2d_corr[int(i-15):int(i+16)]=1
  61. for i in footfault_3d.loc['PB_T2_3_1']:
  62. if i>0:
  63. footfault_3d_corr[int(i-15):int(i+16)]=1
  64. for i in footfault_FI_3d.loc['PB_T2_3_1']:
  65. if i>0:
  66. footfault_FI_3d_corr[int(i-15):int(i+16)]=1
  67. for z in patients[1:]:
  68. max_i=np.array([np.nanmax(mr_cyl_1.loc[z]), np.nanmax(mr_cyl_2.loc[z]), np.nanmax(mr_cyl_3.loc[z]), np.nanmax(footfault_2d.loc[z]), np.nanmax(footfault_FI_2d.loc[z]), np.nanmax(footfault_3d.loc[z]), np.nanmax(footfault_FI_3d.loc[z])])
  69. if all(max_i==max_i):
  70. mr_cyl_1_corr_temp=np.zeros(shape=(int(np.nanmax(max_i)+11),))
  71. mr_cyl_2_corr_temp=np.zeros(shape=(int(np.nanmax(max_i)+11),))
  72. mr_cyl_3_corr_temp=np.zeros(shape=(int(np.nanmax(max_i)+11),))
  73. footfault_2d_corr_temp=np.zeros(shape=(int(np.nanmax(max_i)+11),))
  74. footfault_FI_2d_corr_temp=np.zeros(shape=(int(np.nanmax(max_i)+11),))
  75. footfault_3d_corr_temp=np.zeros(shape=(int(np.nanmax(max_i)+11),))
  76. footfault_FI_3d_corr_temp=np.zeros(shape=(int(np.nanmax(max_i)+11),))
  77. for i in mr_cyl_1.loc[z]:
  78. if i>0:
  79. mr_cyl_1_corr[int(i-15):int(i+16)]=1
  80. for i in mr_cyl_2.loc[z]:
  81. if i>0:
  82. mr_cyl_2_corr[int(i-15):int(i+16)]=1
  83. for i in mr_cyl_3.loc[z]:
  84. if i>0:
  85. mr_cyl_3_corr[int(i-15):int(i+16)]=1
  86. for i in footfault_2d.loc[z]:
  87. if i>0:
  88. footfault_2d_corr[int(i-15):int(i+16)]=1
  89. for i in footfault_FI_2d.loc[z]:
  90. if i>0:
  91. footfault_FI_2d_corr[int(i-15):int(i+16)]=1
  92. for i in footfault_3d.loc[z]:
  93. if i>0:
  94. footfault_3d_corr[int(i-15):int(i+16)]=1
  95. for i in footfault_FI_3d.loc[z]:
  96. if i>0:
  97. footfault_FI_3d_corr[int(i-15):int(i+16)]=1
  98. mr_cyl_1_corr=np.r_[mr_cyl_1_corr, mr_cyl_1_corr_temp]
  99. mr_cyl_2_corr=np.r_[mr_cyl_2_corr, mr_cyl_2_corr_temp]
  100. mr_cyl_3_corr=np.r_[mr_cyl_3_corr, mr_cyl_3_corr_temp]
  101. footfault_2d_corr=np.r_[footfault_2d_corr, footfault_2d_corr_temp]
  102. footfault_FI_2d_corr=np.r_[footfault_FI_2d_corr, footfault_FI_2d_corr_temp]
  103. footfault_3d_corr=np.r_[footfault_3d_corr, footfault_3d_corr_temp]
  104. footfault_FI_3d_corr=np.r_[footfault_FI_3d_corr, footfault_FI_3d_corr_temp]
  105. sn.set_theme(style="white")
  106. d = pd.DataFrame(data=np.array([[1,jaccard(mr_cyl_1_corr, mr_cyl_2_corr), jaccard(mr_cyl_1_corr, mr_cyl_3_corr)],
  107. [jaccard(mr_cyl_1_corr, mr_cyl_2_corr), 1, jaccard(mr_cyl_2_corr, mr_cyl_3_corr)],
  108. [jaccard(mr_cyl_1_corr, mr_cyl_3_corr), jaccard(mr_cyl_2_corr, mr_cyl_3_corr), 1]])
  109. , columns=['Manual Rater 1', 'Manual Rater 2', 'Manual Rater 3'], index=['Manual Rater 1', 'Manual Rater 2', 'Manual Rater 3'])
  110. mask = np.tril(np.ones_like(d, dtype=bool), k=-1)
  111. f, ax = plt.subplots(figsize=(3, 3))
  112. cmap = sn.diverging_palette(10, 250, s=90, l=40, as_cmap=True)
  113. sn.set(font_scale=3)
  114. hmap=sn.heatmap(d, mask=mask.T, cmap=cmap, vmax=1, vmin=0, center=0, annot=True, square=True, linewidths=1, cbar_kws={"shrink": .6}, fmt=".3g")
  115. hmap.set_xticklabels(hmap.get_xmajorticklabels(), fontsize = 40, rotation=45)
  116. hmap.set_yticklabels(hmap.get_ymajorticklabels(), fontsize = 40)
  117. hmap.figure.set_size_inches(22, 18)
  118. plt.tight_layout()
  119. hmap.figure.savefig("/home/user/owncloud/thesis_figures/Correlation_MR_GW.png", format='png', dpi=200)
  120. sn.set_theme(style="white")
  121. d = pd.DataFrame(data=np.array([[1,jaccard(mr_cyl_1_corr, mr_cyl_2_corr), jaccard(mr_cyl_1_corr, mr_cyl_3_corr), jaccard(mr_cyl_1_corr, footfault_2d_corr)],
  122. [jaccard(mr_cyl_1_corr, mr_cyl_2_corr), 1, jaccard(mr_cyl_2_corr, mr_cyl_3_corr), jaccard(mr_cyl_2_corr, footfault_2d_corr)],
  123. [jaccard(mr_cyl_1_corr, mr_cyl_3_corr), jaccard(mr_cyl_2_corr, mr_cyl_3_corr), 1, jaccard(mr_cyl_3_corr, footfault_2d_corr)],
  124. [jaccard(mr_cyl_1_corr, footfault_2d_corr), jaccard(mr_cyl_2_corr, footfault_2d_corr), jaccard(mr_cyl_3_corr, footfault_2d_corr), 1]])
  125. , columns=['Manual Rater 1', 'Manual Rater 2', 'Manual Rater 3', 'DLC'], index=['Manual Rater 1', 'Manual Rater 2', 'Manual Rater 3', 'DLC'])
  126. mask = np.tril(np.ones_like(d, dtype=bool), k=-1)
  127. f, ax = plt.subplots(figsize=(4, 4))
  128. cmap = sn.diverging_palette(10, 250, s=90, l=40, as_cmap=True)
  129. sn.set(font_scale=3)
  130. hmap=sn.heatmap(d, mask=mask.T, cmap=cmap, vmax=1, vmin=0, center=0, annot=True, square=True, linewidths=1, cbar_kws={"shrink": .6}, fmt=".3g")
  131. hmap.set_xticklabels(hmap.get_xmajorticklabels(), fontsize = 40, rotation=45)
  132. hmap.set_yticklabels(hmap.get_ymajorticklabels(), fontsize = 40)
  133. hmap.figure.set_size_inches(22, 18)
  134. plt.tight_layout()
  135. hmap.figure.savefig("/home/user/owncloud/thesis_figures/Correlation_DLC_GW_2d.png", format='png', dpi=200)
  136. sn.set_theme(style="white")
  137. d = pd.DataFrame(data=np.array([[1,jaccard(mr_cyl_1_corr, mr_cyl_2_corr), jaccard(mr_cyl_1_corr, mr_cyl_3_corr), jaccard(mr_cyl_1_corr, footfault_FI_2d_corr)],
  138. [jaccard(mr_cyl_1_corr, mr_cyl_2_corr), 1, jaccard(mr_cyl_2_corr, mr_cyl_3_corr), jaccard(mr_cyl_2_corr, footfault_FI_2d_corr)],
  139. [jaccard(mr_cyl_1_corr, mr_cyl_3_corr), jaccard(mr_cyl_2_corr, mr_cyl_3_corr), 1, jaccard(mr_cyl_3_corr, footfault_FI_2d_corr)],
  140. [jaccard(mr_cyl_1_corr, footfault_FI_2d_corr), jaccard(mr_cyl_2_corr, footfault_FI_2d_corr), jaccard(mr_cyl_3_corr, footfault_FI_2d_corr), 1]])
  141. , columns=['Manual Rater 1', 'Manual Rater 2', 'Manual Rater 3', 'DLC'], index=['Manual Rater 1', 'Manual Rater 2', 'Manual Rater 3', 'DLC'])
  142. mask = np.tril(np.ones_like(d, dtype=bool), k=-1)
  143. f, ax = plt.subplots(figsize=(4, 4))
  144. cmap = sn.diverging_palette(10, 250, s=90, l=40, as_cmap=True)
  145. sn.set(font_scale=3)
  146. hmap=sn.heatmap(d, mask=mask.T, cmap=cmap, vmax=1, vmin=0, center=0, annot=True, square=True, linewidths=1, cbar_kws={"shrink": .6}, fmt=".3g")
  147. hmap.set_xticklabels(hmap.get_xmajorticklabels(), fontsize = 40, rotation=45)
  148. hmap.set_yticklabels(hmap.get_ymajorticklabels(), fontsize = 40)
  149. hmap.figure.set_size_inches(22, 18)
  150. plt.tight_layout()
  151. hmap.figure.savefig("/home/user/owncloud/thesis_figures/Correlation_DLC_GW_FI_2d.png", format='png', dpi=200)
  152. sn.set_theme(style="white")
  153. d = pd.DataFrame(data=np.array([[1,jaccard(mr_cyl_1_corr, mr_cyl_2_corr), jaccard(mr_cyl_1_corr, mr_cyl_3_corr), jaccard(mr_cyl_1_corr, footfault_3d_corr)],
  154. [jaccard(mr_cyl_1_corr, mr_cyl_2_corr), 1, jaccard(mr_cyl_2_corr, mr_cyl_3_corr), jaccard(mr_cyl_2_corr, footfault_3d_corr)],
  155. [jaccard(mr_cyl_1_corr, mr_cyl_3_corr), jaccard(mr_cyl_2_corr, mr_cyl_3_corr), 1, jaccard(mr_cyl_3_corr, footfault_3d_corr)],
  156. [jaccard(mr_cyl_1_corr, footfault_3d_corr), jaccard(mr_cyl_2_corr, footfault_3d_corr), jaccard(mr_cyl_3_corr, footfault_3d_corr), 1]])
  157. , columns=['Manual Rater 1', 'Manual Rater 2', 'Manual Rater 3', 'DLC'], index=['Manual Rater 1', 'Manual Rater 2', 'Manual Rater 3', 'DLC'])
  158. mask = np.tril(np.ones_like(d, dtype=bool), k=-1)
  159. f, ax = plt.subplots(figsize=(4, 4))
  160. cmap = sn.diverging_palette(10, 250, s=90, l=40, as_cmap=True)
  161. sn.set(font_scale=3)
  162. hmap=sn.heatmap(d, mask=mask.T, cmap=cmap, vmax=1, vmin=0, center=0, annot=True, square=True, linewidths=1, cbar_kws={"shrink": .6}, fmt=".3g")
  163. hmap.set_xticklabels(hmap.get_xmajorticklabels(), fontsize = 40, rotation=45)
  164. hmap.set_yticklabels(hmap.get_ymajorticklabels(), fontsize = 40)
  165. hmap.figure.set_size_inches(22, 18)
  166. plt.tight_layout()
  167. hmap.figure.savefig("/home/user/owncloud/thesis_figures/Correlation_DLC_GW_3d.png", format='png', dpi=200)
  168. sn.set_theme(style="white")
  169. d = pd.DataFrame(data=np.array([[1,jaccard(mr_cyl_1_corr, mr_cyl_2_corr), jaccard(mr_cyl_1_corr, mr_cyl_3_corr), jaccard(mr_cyl_1_corr, footfault_FI_3d_corr)],
  170. [jaccard(mr_cyl_1_corr, mr_cyl_2_corr), 1, jaccard(mr_cyl_2_corr, mr_cyl_3_corr), jaccard(mr_cyl_2_corr, footfault_FI_3d_corr)],
  171. [jaccard(mr_cyl_1_corr, mr_cyl_3_corr), jaccard(mr_cyl_2_corr, mr_cyl_3_corr), 1, jaccard(mr_cyl_3_corr, footfault_FI_3d_corr)],
  172. [jaccard(mr_cyl_1_corr, footfault_FI_3d_corr), jaccard(mr_cyl_2_corr, footfault_FI_3d_corr), jaccard(mr_cyl_3_corr, footfault_FI_3d_corr), 1]])
  173. , columns=['Manual Rater 1', 'Manual Rater 2', 'Manual Rater 3', 'DLC'], index=['Manual Rater 1', 'Manual Rater 2', 'Manual Rater 3', 'DLC'])
  174. mask = np.tril(np.ones_like(d, dtype=bool), k=-1)
  175. f, ax = plt.subplots(figsize=(4, 4))
  176. cmap = sn.diverging_palette(10, 250, s=90, l=40, as_cmap=True)
  177. sn.set(font_scale=3)
  178. hmap=sn.heatmap(d, mask=mask.T, cmap=cmap, vmax=1, vmin=0, center=0, annot=True, square=True, linewidths=1, cbar_kws={"shrink": .6}, fmt=".3g")
  179. hmap.set_xticklabels(hmap.get_xmajorticklabels(), fontsize = 40, rotation=45)
  180. hmap.set_yticklabels(hmap.get_ymajorticklabels(), fontsize = 40)
  181. hmap.figure.set_size_inches(22, 18)
  182. plt.tight_layout()
  183. hmap.figure.savefig("/home/user/owncloud/thesis_figures/Correlation_DLC_GW_FI_3d.png", format='png', dpi=200)
  184. print('GW 3D')
  185. df=pd.DataFrame({'index':[i for i in range(len(mr_cyl_1_corr))]+[i for i in range(len(mr_cyl_2_corr))]+[i for i in range(len(mr_cyl_3_corr))], 'rater':['1']*len(mr_cyl_1_corr)+['2']*len(mr_cyl_2_corr)+['3']*len(mr_cyl_3_corr), 'rating':np.concatenate((mr_cyl_1_corr, mr_cyl_2_corr, mr_cyl_3_corr))})
  186. icc = pg.intraclass_corr(data=df, targets='index', raters='rater', ratings='rating', nan_policy='omit')
  187. print(icc.loc[2])
  188. df=pd.DataFrame({'index':[i for i in range(len(mr_cyl_1_corr))]+[i for i in range(len(mr_cyl_2_corr))]+[i for i in range(len(mr_cyl_3_corr))]+[i for i in range(len(footfault_2d_corr))], 'rater':['1']*len(mr_cyl_1_corr)+['2']*len(mr_cyl_2_corr)+['3']*len(mr_cyl_3_corr)+['DLC']*len(footfault_2d_corr), 'rating':np.concatenate((mr_cyl_1_corr, mr_cyl_2_corr, mr_cyl_3_corr, footfault_2d_corr))})
  189. icc = pg.intraclass_corr(data=df, targets='index', raters='rater', ratings='rating', nan_policy='omit')
  190. print(icc.loc[2])
  191. df=pd.DataFrame({'index':[i for i in range(len(mr_cyl_1_corr))]+[i for i in range(len(mr_cyl_2_corr))]+[i for i in range(len(mr_cyl_3_corr))]+[i for i in range(len(footfault_FI_2d_corr))], 'rater':['1']*len(mr_cyl_1_corr)+['2']*len(mr_cyl_2_corr)+['3']*len(mr_cyl_3_corr)+['DLC']*len(footfault_FI_2d_corr), 'rating':np.concatenate((mr_cyl_1_corr, mr_cyl_2_corr, mr_cyl_3_corr, footfault_FI_2d_corr))})
  192. icc = pg.intraclass_corr(data=df, targets='index', raters='rater', ratings='rating', nan_policy='omit')
  193. print(icc.loc[2])
  194. df=pd.DataFrame({'index':[i for i in range(len(mr_cyl_1_corr))]+[i for i in range(len(mr_cyl_2_corr))]+[i for i in range(len(mr_cyl_3_corr))]+[i for i in range(len(footfault_3d_corr))], 'rater':['1']*len(mr_cyl_1_corr)+['2']*len(mr_cyl_2_corr)+['3']*len(mr_cyl_3_corr)+['DLC']*len(footfault_3d_corr), 'rating':np.concatenate((mr_cyl_1_corr, mr_cyl_2_corr, mr_cyl_3_corr, footfault_3d_corr))})
  195. icc = pg.intraclass_corr(data=df, targets='index', raters='rater', ratings='rating', nan_policy='omit')
  196. print(icc.loc[2])
  197. df=pd.DataFrame({'index':[i for i in range(len(mr_cyl_1_corr))]+[i for i in range(len(mr_cyl_2_corr))]+[i for i in range(len(mr_cyl_3_corr))]+[i for i in range(len(footfault_FI_3d_corr))], 'rater':['1']*len(mr_cyl_1_corr)+['2']*len(mr_cyl_2_corr)+['3']*len(mr_cyl_3_corr)+['DLC']*len(footfault_FI_3d_corr), 'rating':np.concatenate((mr_cyl_1_corr, mr_cyl_2_corr, mr_cyl_3_corr, footfault_FI_3d_corr))})
  198. icc = pg.intraclass_corr(data=df, targets='index', raters='rater', ratings='rating', nan_policy='omit')
  199. print(icc.loc[2])
  200. # ============================================================================================================================================
  201. ## Correlation Feature Cylinder Touch within MR and between MR and DLC plus FI 2D and 3D
  202. # ============================================================================================================================================
  203. mr_cyl_touch_1=pd.read_csv("/home/user/owncloud/3D_videos/manual_raters/Manual_Cylinder_Analyse_Jan_touch.csv", index_col=0, delimiter=',', header=None)
  204. mr_cyl_touch_2=pd.read_csv("/home/user/owncloud/3D_videos/manual_raters/Manual_Cylinder_Analyse_Nicole_touch.csv", index_col=0, delimiter=',', header=None)
  205. mr_cyl_touch_3=pd.read_csv("/home/user/owncloud/3D_videos/manual_raters/Manual_Cylinder_Analyse_Jule_touch.csv", index_col=0, delimiter=',', header=None)
  206. 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']
  207. max_i=np.array([np.nanmax(mr_cyl_touch_1.loc['PB_T2_3_1']), np.nanmax(mr_cyl_touch_2.loc['PB_T2_3_1']), np.nanmax(mr_cyl_touch_3.loc['PB_T2_3_1']), np.nanmax(touch_2d.loc['PB_T2_3_1']), np.nanmax(touch_FI_2d.loc['PB_T2_3_1']), np.nanmax(touch_3d.loc['PB_T2_3_1']), np.nanmax(touch_FI_3d.loc['PB_T2_3_1'])])
  208. mr_cyl_touch_1_corr=np.zeros(shape=(int(np.nanmax(max_i)+11),))
  209. mr_cyl_touch_2_corr=np.zeros(shape=(int(np.nanmax(max_i)+11),))
  210. mr_cyl_touch_3_corr=np.zeros(shape=(int(np.nanmax(max_i)+11),))
  211. touch_2d_corr=np.zeros(shape=(int(np.nanmax(max_i)+11),))
  212. touch_FI_2d_corr=np.zeros(shape=(int(np.nanmax(max_i)+11),))
  213. touch_3d_corr=np.zeros(shape=(int(np.nanmax(max_i)+11),))
  214. touch_FI_3d_corr=np.zeros(shape=(int(np.nanmax(max_i)+11),))
  215. for i in mr_cyl_touch_1.loc['PB_T2_3_1']:
  216. if i>0:
  217. mr_cyl_touch_1_corr[int(i-15):int(i+16)]=1
  218. for i in mr_cyl_touch_2.loc['PB_T2_3_1']:
  219. if i>0:
  220. mr_cyl_touch_2_corr[int(i-15):int(i+16)]=1
  221. for i in mr_cyl_touch_3.loc['PB_T2_3_1']:
  222. if i>0:
  223. mr_cyl_touch_3_corr[int(i-15):int(i+16)]=1
  224. for i in touch_2d.loc['PB_T2_3_1']:
  225. if i>0:
  226. touch_2d_corr[int(i-15):int(i+16)]=1
  227. for i in touch_FI_2d.loc['PB_T2_3_1']:
  228. if i>0:
  229. touch_FI_2d_corr[int(i-15):int(i+16)]=1
  230. for i in touch_3d.loc['PB_T2_3_1']:
  231. if i>0:
  232. touch_3d_corr[int(i-15):int(i+16)]=1
  233. for i in touch_FI_3d.loc['PB_T2_3_1']:
  234. if i>0:
  235. touch_FI_3d_corr[int(i-15):int(i+16)]=1
  236. for z in patients[1:]:
  237. max_i=np.array([np.nanmax(mr_cyl_touch_1.loc[z]), np.nanmax(mr_cyl_touch_2.loc[z]), np.nanmax(mr_cyl_touch_3.loc[z]), np.nanmax(touch_2d.loc[z]), np.nanmax(touch_FI_2d.loc[z]), np.nanmax(touch_3d.loc[z]), np.nanmax(touch_FI_3d.loc[z])])
  238. if all(max_i==max_i):
  239. mr_cyl_touch_1_corr_temp=np.zeros(shape=(int(np.nanmax(max_i)+11),))
  240. mr_cyl_touch_2_corr_temp=np.zeros(shape=(int(np.nanmax(max_i)+11),))
  241. mr_cyl_touch_3_corr_temp=np.zeros(shape=(int(np.nanmax(max_i)+11),))
  242. touch_2d_corr_temp=np.zeros(shape=(int(np.nanmax(max_i)+11),))
  243. touch_FI_2d_corr_temp=np.zeros(shape=(int(np.nanmax(max_i)+11),))
  244. touch_3d_corr_temp=np.zeros(shape=(int(np.nanmax(max_i)+11),))
  245. touch_FI_3d_corr_temp=np.zeros(shape=(int(np.nanmax(max_i)+11),))
  246. for i in mr_cyl_touch_1.loc[z]:
  247. if i>0:
  248. mr_cyl_touch_1_corr[int(i-15):int(i+16)]=1
  249. for i in mr_cyl_touch_2.loc[z]:
  250. if i>0:
  251. mr_cyl_touch_2_corr[int(i-15):int(i+16)]=1
  252. for i in mr_cyl_touch_3.loc[z]:
  253. if i>0:
  254. mr_cyl_touch_3_corr[int(i-15):int(i+16)]=1
  255. for i in touch_2d.loc[z]:
  256. if i>0:
  257. touch_2d_corr[int(i-15):int(i+16)]=1
  258. for i in touch_FI_2d.loc[z]:
  259. if i>0:
  260. touch_FI_2d_corr[int(i-15):int(i+16)]=1
  261. for i in touch_3d.loc[z]:
  262. if i>0:
  263. touch_3d_corr[int(i-15):int(i+16)]=1
  264. for i in touch_FI_3d.loc[z]:
  265. if i>0:
  266. touch_FI_3d_corr[int(i-15):int(i+16)]=1
  267. mr_cyl_touch_1_corr=np.r_[mr_cyl_touch_1_corr, mr_cyl_touch_1_corr_temp]
  268. mr_cyl_touch_2_corr=np.r_[mr_cyl_touch_2_corr, mr_cyl_touch_2_corr_temp]
  269. mr_cyl_touch_3_corr=np.r_[mr_cyl_touch_3_corr, mr_cyl_touch_3_corr_temp]
  270. touch_2d_corr=np.r_[touch_2d_corr, touch_2d_corr_temp]
  271. touch_FI_2d_corr=np.r_[touch_FI_2d_corr, touch_FI_2d_corr_temp]
  272. touch_3d_corr=np.r_[touch_3d_corr, touch_3d_corr_temp]
  273. touch_FI_3d_corr=np.r_[touch_FI_3d_corr, touch_FI_3d_corr_temp]
  274. sn.set_theme(style="white")
  275. d = pd.DataFrame(data=np.array([[1,jaccard(mr_cyl_touch_1_corr, mr_cyl_touch_2_corr), jaccard(mr_cyl_touch_1_corr, mr_cyl_touch_3_corr)],
  276. [jaccard(mr_cyl_touch_1_corr, mr_cyl_touch_2_corr), 1, jaccard(mr_cyl_touch_2_corr, mr_cyl_touch_3_corr)],
  277. [jaccard(mr_cyl_touch_1_corr, mr_cyl_touch_3_corr), jaccard(mr_cyl_touch_2_corr, mr_cyl_touch_3_corr), 1]])
  278. , columns=['Manual Rater 1', 'Manual Rater 2', 'Manual Rater 3'], index=['Manual Rater 1', 'Manual Rater 2', 'Manual Rater 3'])
  279. mask = np.tril(np.ones_like(d, dtype=bool), k=-1)
  280. f, ax = plt.subplots(figsize=(3, 3))
  281. cmap = sn.diverging_palette(10, 250, s=90, l=40, as_cmap=True)
  282. sn.set(font_scale=3)
  283. hmap=sn.heatmap(d, mask=mask.T, cmap=cmap, vmax=1, vmin=0, center=0, annot=True, square=True, linewidths=1, cbar_kws={"shrink": .6}, fmt=".3g")
  284. hmap.set_xticklabels(hmap.get_xmajorticklabels(), fontsize = 40, rotation=45)
  285. hmap.set_yticklabels(hmap.get_ymajorticklabels(), fontsize = 40)
  286. hmap.figure.set_size_inches(22, 18)
  287. plt.tight_layout()
  288. hmap.figure.savefig("/home/user/owncloud/thesis_figures/Correlation_MR_CY_touch.png", format='png', dpi=200)
  289. sn.set_theme(style="white")
  290. d = pd.DataFrame(data=np.array([[1,jaccard(mr_cyl_touch_1_corr, mr_cyl_touch_2_corr), jaccard(mr_cyl_touch_1_corr, mr_cyl_touch_3_corr), jaccard(mr_cyl_touch_1_corr, touch_2d_corr)],
  291. [jaccard(mr_cyl_touch_1_corr, mr_cyl_touch_2_corr), 1, jaccard(mr_cyl_touch_2_corr, mr_cyl_touch_3_corr), jaccard(mr_cyl_touch_2_corr, touch_2d_corr)],
  292. [jaccard(mr_cyl_touch_1_corr, mr_cyl_touch_3_corr), jaccard(mr_cyl_touch_2_corr, mr_cyl_touch_3_corr), 1, jaccard(mr_cyl_touch_3_corr, touch_2d_corr)],
  293. [jaccard(mr_cyl_touch_1_corr, touch_2d_corr), jaccard(mr_cyl_touch_2_corr, touch_2d_corr), jaccard(mr_cyl_touch_3_corr, touch_2d_corr), 1]])
  294. , columns=['Manual Rater 1', 'Manual Rater 2', 'Manual Rater 3', 'DLC'], index=['Manual Rater 1', 'Manual Rater 2', 'Manual Rater 3', 'DLC'])
  295. mask = np.tril(np.ones_like(d, dtype=bool), k=-1)
  296. f, ax = plt.subplots(figsize=(4, 4))
  297. cmap = sn.diverging_palette(10, 250, s=90, l=40, as_cmap=True)
  298. sn.set(font_scale=3)
  299. hmap=sn.heatmap(d, mask=mask.T, cmap=cmap, vmax=1, vmin=0, center=0, annot=True, square=True, linewidths=1, cbar_kws={"shrink": .6}, fmt=".3g")
  300. hmap.set_xticklabels(hmap.get_xmajorticklabels(), fontsize = 40, rotation=45)
  301. hmap.set_yticklabels(hmap.get_ymajorticklabels(), fontsize = 40)
  302. hmap.figure.set_size_inches(22, 18)
  303. plt.tight_layout()
  304. hmap.figure.savefig("/home/user/owncloud/thesis_figures/Correlation_DLC_CY_touch_2d.png", format='png', dpi=200)
  305. sn.set_theme(style="white")
  306. d = pd.DataFrame(data=np.array([[1,jaccard(mr_cyl_touch_1_corr, mr_cyl_touch_2_corr), jaccard(mr_cyl_touch_1_corr, mr_cyl_touch_3_corr), jaccard(mr_cyl_touch_1_corr, touch_FI_2d_corr)],
  307. [jaccard(mr_cyl_touch_1_corr, mr_cyl_touch_2_corr), 1, jaccard(mr_cyl_touch_2_corr, mr_cyl_touch_3_corr), jaccard(mr_cyl_touch_2_corr, touch_FI_2d_corr)],
  308. [jaccard(mr_cyl_touch_1_corr, mr_cyl_touch_3_corr), jaccard(mr_cyl_touch_2_corr, mr_cyl_touch_3_corr), 1, jaccard(mr_cyl_touch_3_corr, touch_FI_2d_corr)],
  309. [jaccard(mr_cyl_touch_1_corr, touch_FI_2d_corr), jaccard(mr_cyl_touch_2_corr, touch_FI_2d_corr), jaccard(mr_cyl_touch_3_corr, touch_FI_2d_corr), 1]])
  310. , columns=['Manual Rater 1', 'Manual Rater 2', 'Manual Rater 3', 'DLC'], index=['Manual Rater 1', 'Manual Rater 2', 'Manual Rater 3', 'DLC'])
  311. mask = np.tril(np.ones_like(d, dtype=bool), k=-1)
  312. f, ax = plt.subplots(figsize=(4, 4))
  313. cmap = sn.diverging_palette(10, 250, s=90, l=40, as_cmap=True)
  314. sn.set(font_scale=3)
  315. hmap=sn.heatmap(d, mask=mask.T, cmap=cmap, vmax=1, vmin=0, center=0, annot=True, square=True, linewidths=1, cbar_kws={"shrink": .6}, fmt=".3g")
  316. hmap.set_xticklabels(hmap.get_xmajorticklabels(), fontsize = 40, rotation=45)
  317. hmap.set_yticklabels(hmap.get_ymajorticklabels(), fontsize = 40)
  318. hmap.figure.set_size_inches(22, 18)
  319. plt.tight_layout()
  320. hmap.figure.savefig("/home/user/owncloud/thesis_figures/Correlation_DLC_CY_touch_FI_2d.png", format='png', dpi=200)
  321. sn.set_theme(style="white")
  322. d = pd.DataFrame(data=np.array([[1,jaccard(mr_cyl_touch_1_corr, mr_cyl_touch_2_corr), jaccard(mr_cyl_touch_1_corr, mr_cyl_touch_3_corr), jaccard(mr_cyl_touch_1_corr, touch_3d_corr)],
  323. [jaccard(mr_cyl_touch_1_corr, mr_cyl_touch_2_corr), 1, jaccard(mr_cyl_touch_2_corr, mr_cyl_touch_3_corr), jaccard(mr_cyl_touch_2_corr, touch_3d_corr)],
  324. [jaccard(mr_cyl_touch_1_corr, mr_cyl_touch_3_corr), jaccard(mr_cyl_touch_2_corr, mr_cyl_touch_3_corr), 1, jaccard(mr_cyl_touch_3_corr, touch_3d_corr)],
  325. [jaccard(mr_cyl_touch_1_corr, touch_3d_corr), jaccard(mr_cyl_touch_2_corr, touch_3d_corr), jaccard(mr_cyl_touch_3_corr, touch_3d_corr), 1]])
  326. , columns=['Manual Rater 1', 'Manual Rater 2', 'Manual Rater 3', 'DLC'], index=['Manual Rater 1', 'Manual Rater 2', 'Manual Rater 3', 'DLC'])
  327. mask = np.tril(np.ones_like(d, dtype=bool), k=-1)
  328. f, ax = plt.subplots(figsize=(4, 4))
  329. cmap = sn.diverging_palette(10, 250, s=90, l=40, as_cmap=True)
  330. sn.set(font_scale=3)
  331. hmap=sn.heatmap(d, mask=mask.T, cmap=cmap, vmax=1, vmin=0, center=0, annot=True, square=True, linewidths=1, cbar_kws={"shrink": .6}, fmt=".3g")
  332. hmap.set_xticklabels(hmap.get_xmajorticklabels(), fontsize = 40, rotation=45)
  333. hmap.set_yticklabels(hmap.get_ymajorticklabels(), fontsize = 40)
  334. hmap.figure.set_size_inches(22, 18)
  335. plt.tight_layout()
  336. hmap.figure.savefig("/home/user/owncloud/thesis_figures/Correlation_DLC_CY_touch_3d.png", format='png', dpi=200)
  337. sn.set_theme(style="white")
  338. d = pd.DataFrame(data=np.array([[1,jaccard(mr_cyl_touch_1_corr, mr_cyl_touch_2_corr), jaccard(mr_cyl_touch_1_corr, mr_cyl_touch_3_corr), jaccard(mr_cyl_touch_1_corr, touch_FI_3d_corr)],
  339. [jaccard(mr_cyl_touch_1_corr, mr_cyl_touch_2_corr), 1, jaccard(mr_cyl_touch_2_corr, mr_cyl_touch_3_corr), jaccard(mr_cyl_touch_2_corr, touch_FI_3d_corr)],
  340. [jaccard(mr_cyl_touch_1_corr, mr_cyl_touch_3_corr), jaccard(mr_cyl_touch_2_corr, mr_cyl_touch_3_corr), 1, jaccard(mr_cyl_touch_3_corr, touch_FI_3d_corr)],
  341. [jaccard(mr_cyl_touch_1_corr, touch_FI_3d_corr), jaccard(mr_cyl_touch_2_corr, touch_FI_3d_corr), jaccard(mr_cyl_touch_3_corr, touch_FI_3d_corr), 1]])
  342. , columns=['Manual Rater 1', 'Manual Rater 2', 'Manual Rater 3', 'DLC'], index=['Manual Rater 1', 'Manual Rater 2', 'Manual Rater 3', 'DLC'])
  343. mask = np.tril(np.ones_like(d, dtype=bool), k=-1)
  344. f, ax = plt.subplots(figsize=(4, 4))
  345. cmap = sn.diverging_palette(10, 250, s=90, l=40, as_cmap=True)
  346. sn.set(font_scale=3)
  347. hmap=sn.heatmap(d, mask=mask.T, cmap=cmap, vmax=1, vmin=0, center=0, annot=True, square=True, linewidths=1, cbar_kws={"shrink": .6}, fmt=".3g")
  348. hmap.set_xticklabels(hmap.get_xmajorticklabels(), fontsize = 40, rotation=45)
  349. hmap.set_yticklabels(hmap.get_ymajorticklabels(), fontsize = 40)
  350. hmap.figure.set_size_inches(22, 18)
  351. plt.tight_layout()
  352. hmap.figure.savefig("/home/user/owncloud/thesis_figures/Correlation_DLC_CY_touch_FI_3d.png", format='png', dpi=200)
  353. print('CY touch 3D')
  354. df=pd.DataFrame({'index':[i for i in range(len(mr_cyl_touch_1_corr))]+[i for i in range(len(mr_cyl_touch_2_corr))]+[i for i in range(len(mr_cyl_touch_3_corr))], 'rater':['1']*len(mr_cyl_touch_1_corr)+['2']*len(mr_cyl_touch_2_corr)+['3']*len(mr_cyl_touch_3_corr), 'rating':np.concatenate((mr_cyl_touch_1_corr, mr_cyl_touch_2_corr, mr_cyl_touch_3_corr))})
  355. icc = pg.intraclass_corr(data=df, targets='index', raters='rater', ratings='rating', nan_policy='omit')
  356. print(icc.loc[2])
  357. df=pd.DataFrame({'index':[i for i in range(len(mr_cyl_touch_1_corr))]+[i for i in range(len(mr_cyl_touch_2_corr))]+[i for i in range(len(mr_cyl_touch_3_corr))]+[i for i in range(len(touch_2d_corr))], 'rater':['1']*len(mr_cyl_touch_1_corr)+['2']*len(mr_cyl_touch_2_corr)+['3']*len(mr_cyl_touch_3_corr)+['DLC']*len(touch_2d_corr), 'rating':np.concatenate((mr_cyl_touch_1_corr, mr_cyl_touch_2_corr, mr_cyl_touch_3_corr, touch_2d_corr))})
  358. icc = pg.intraclass_corr(data=df, targets='index', raters='rater', ratings='rating', nan_policy='omit')
  359. print(icc.loc[2])
  360. df=pd.DataFrame({'index':[i for i in range(len(mr_cyl_touch_1_corr))]+[i for i in range(len(mr_cyl_touch_2_corr))]+[i for i in range(len(mr_cyl_touch_3_corr))]+[i for i in range(len(touch_FI_2d_corr))], 'rater':['1']*len(mr_cyl_touch_1_corr)+['2']*len(mr_cyl_touch_2_corr)+['3']*len(mr_cyl_touch_3_corr)+['DLC']*len(touch_FI_2d_corr), 'rating':np.concatenate((mr_cyl_touch_1_corr, mr_cyl_touch_2_corr, mr_cyl_touch_3_corr, touch_FI_2d_corr))})
  361. icc = pg.intraclass_corr(data=df, targets='index', raters='rater', ratings='rating', nan_policy='omit')
  362. print(icc.loc[2])
  363. df=pd.DataFrame({'index':[i for i in range(len(mr_cyl_touch_1_corr))]+[i for i in range(len(mr_cyl_touch_2_corr))]+[i for i in range(len(mr_cyl_touch_3_corr))]+[i for i in range(len(touch_3d_corr))], 'rater':['1']*len(mr_cyl_touch_1_corr)+['2']*len(mr_cyl_touch_2_corr)+['3']*len(mr_cyl_touch_3_corr)+['DLC']*len(touch_3d_corr), 'rating':np.concatenate((mr_cyl_touch_1_corr, mr_cyl_touch_2_corr, mr_cyl_touch_3_corr, touch_3d_corr))})
  364. icc = pg.intraclass_corr(data=df, targets='index', raters='rater', ratings='rating', nan_policy='omit')
  365. print(icc.loc[2])
  366. df=pd.DataFrame({'index':[i for i in range(len(mr_cyl_touch_1_corr))]+[i for i in range(len(mr_cyl_touch_2_corr))]+[i for i in range(len(mr_cyl_touch_3_corr))]+[i for i in range(len(touch_FI_3d_corr))], 'rater':['1']*len(mr_cyl_touch_1_corr)+['2']*len(mr_cyl_touch_2_corr)+['3']*len(mr_cyl_touch_3_corr)+['DLC']*len(touch_FI_3d_corr), 'rating':np.concatenate((mr_cyl_touch_1_corr, mr_cyl_touch_2_corr, mr_cyl_touch_3_corr, touch_FI_3d_corr))})
  367. icc = pg.intraclass_corr(data=df, targets='index', raters='rater', ratings='rating', nan_policy='omit')
  368. print(icc.loc[2])
  369. # ============================================================================================================================================
  370. ## Correlation Feature Cylinder Drag within MR and between MR and DLC plus FI 2D and 3D
  371. # ============================================================================================================================================
  372. mr_cyl_drag_1=pd.read_csv("/home/user/owncloud/3D_videos/manual_raters/Manual_Cylinder_Analyse_Jan_drag.csv", index_col=0, delimiter=',', header=None)
  373. mr_cyl_drag_2=pd.read_csv("/home/user/owncloud/3D_videos/manual_raters/Manual_Cylinder_Analyse_Nicole_drag.csv", index_col=0, delimiter=',', header=None)
  374. mr_cyl_drag_3=pd.read_csv("/home/user/owncloud/3D_videos/manual_raters/Manual_Cylinder_Analyse_Jule_drag.csv", index_col=0, delimiter=',', header=None)
  375. 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']
  376. max_i=np.array([np.nanmax(mr_cyl_drag_1.loc['PB_T2_3_1']), np.nanmax(mr_cyl_drag_2.loc['PB_T2_3_1']), np.nanmax(mr_cyl_drag_3.loc['PB_T2_3_1']), np.nanmax(drag_2d.loc['PB_T2_3_1']), np.nanmax(drag_FI_2d.loc['PB_T2_3_1']), np.nanmax(drag_3d.loc['PB_T2_3_1']), np.nanmax(drag_FI_3d.loc['PB_T2_3_1'])])
  377. mr_cyl_drag_1_corr=np.zeros(shape=(int(np.nanmax(max_i)+11),))
  378. mr_cyl_drag_2_corr=np.zeros(shape=(int(np.nanmax(max_i)+11),))
  379. mr_cyl_drag_3_corr=np.zeros(shape=(int(np.nanmax(max_i)+11),))
  380. drag_2d_corr=np.zeros(shape=(int(np.nanmax(max_i)+11),))
  381. drag_FI_2d_corr=np.zeros(shape=(int(np.nanmax(max_i)+11),))
  382. drag_3d_corr=np.zeros(shape=(int(np.nanmax(max_i)+11),))
  383. drag_FI_3d_corr=np.zeros(shape=(int(np.nanmax(max_i)+11),))
  384. for i in mr_cyl_drag_1.loc['PB_T2_3_1']:
  385. if i>0:
  386. mr_cyl_drag_1_corr[int(i-15):int(i+16)]=1
  387. for i in mr_cyl_drag_2.loc['PB_T2_3_1']:
  388. if i>0:
  389. mr_cyl_drag_2_corr[int(i-15):int(i+16)]=1
  390. for i in mr_cyl_drag_3.loc['PB_T2_3_1']:
  391. if i>0:
  392. mr_cyl_drag_3_corr[int(i-15):int(i+16)]=1
  393. for i in drag_2d.loc['PB_T2_3_1']:
  394. if i>0:
  395. drag_2d_corr[int(i-15):int(i+16)]=1
  396. for i in drag_FI_2d.loc['PB_T2_3_1']:
  397. if i>0:
  398. drag_FI_2d_corr[int(i-15):int(i+16)]=1
  399. for i in drag_3d.loc['PB_T2_3_1']:
  400. if i>0:
  401. drag_3d_corr[int(i-15):int(i+16)]=1
  402. for i in drag_FI_3d.loc['PB_T2_3_1']:
  403. if i>0:
  404. drag_FI_3d_corr[int(i-15):int(i+16)]=1
  405. for z in patients[1:]:
  406. max_i=np.array([np.nanmax(mr_cyl_drag_1.loc[z]), np.nanmax(mr_cyl_drag_2.loc[z]), np.nanmax(mr_cyl_drag_3.loc[z]), np.nanmax(drag_2d.loc[z]), np.nanmax(drag_FI_2d.loc[z]), np.nanmax(drag_3d.loc[z]), np.nanmax(drag_FI_3d.loc[z])])
  407. if all(max_i==max_i):
  408. mr_cyl_drag_1_corr_temp=np.zeros(shape=(int(np.nanmax(max_i)+11),))
  409. mr_cyl_drag_2_corr_temp=np.zeros(shape=(int(np.nanmax(max_i)+11),))
  410. mr_cyl_drag_3_corr_temp=np.zeros(shape=(int(np.nanmax(max_i)+11),))
  411. drag_2d_corr_temp=np.zeros(shape=(int(np.nanmax(max_i)+11),))
  412. drag_FI_2d_corr_temp=np.zeros(shape=(int(np.nanmax(max_i)+11),))
  413. drag_3d_corr_temp=np.zeros(shape=(int(np.nanmax(max_i)+11),))
  414. drag_FI_3d_corr_temp=np.zeros(shape=(int(np.nanmax(max_i)+11),))
  415. for i in mr_cyl_drag_1.loc[z]:
  416. if i>0:
  417. mr_cyl_drag_1_corr[int(i-15):int(i+16)]=1
  418. for i in mr_cyl_drag_2.loc[z]:
  419. if i>0:
  420. mr_cyl_drag_2_corr[int(i-15):int(i+16)]=1
  421. for i in mr_cyl_drag_3.loc[z]:
  422. if i>0:
  423. mr_cyl_drag_3_corr[int(i-15):int(i+16)]=1
  424. for i in drag_2d.loc[z]:
  425. if i>0:
  426. drag_2d_corr[int(i-15):int(i+16)]=1
  427. for i in drag_FI_2d.loc[z]:
  428. if i>0:
  429. drag_FI_2d_corr[int(i-15):int(i+16)]=1
  430. for i in drag_3d.loc[z]:
  431. if i>0:
  432. drag_3d_corr[int(i-15):int(i+16)]=1
  433. for i in drag_FI_3d.loc[z]:
  434. if i>0:
  435. drag_FI_3d_corr[int(i-15):int(i+16)]=1
  436. mr_cyl_drag_1_corr=np.r_[mr_cyl_drag_1_corr, mr_cyl_drag_1_corr_temp]
  437. mr_cyl_drag_2_corr=np.r_[mr_cyl_drag_2_corr, mr_cyl_drag_2_corr_temp]
  438. mr_cyl_drag_3_corr=np.r_[mr_cyl_drag_3_corr, mr_cyl_drag_3_corr_temp]
  439. drag_2d_corr=np.r_[drag_2d_corr, drag_2d_corr_temp]
  440. drag_FI_2d_corr=np.r_[drag_FI_2d_corr, drag_FI_2d_corr_temp]
  441. drag_3d_corr=np.r_[drag_3d_corr, drag_3d_corr_temp]
  442. drag_FI_3d_corr=np.r_[drag_FI_3d_corr, drag_FI_3d_corr_temp]
  443. sn.set_theme(style="white")
  444. d = pd.DataFrame(data=np.array([[1,jaccard(mr_cyl_drag_1_corr, mr_cyl_drag_2_corr), jaccard(mr_cyl_drag_1_corr, mr_cyl_drag_3_corr)],
  445. [jaccard(mr_cyl_drag_1_corr, mr_cyl_drag_2_corr), 1, jaccard(mr_cyl_drag_2_corr, mr_cyl_drag_3_corr)],
  446. [jaccard(mr_cyl_drag_1_corr, mr_cyl_drag_3_corr), jaccard(mr_cyl_drag_2_corr, mr_cyl_drag_3_corr), 1]])
  447. , columns=['Manual Rater 1', 'Manual Rater 2', 'Manual Rater 3'], index=['Manual Rater 1', 'Manual Rater 2', 'Manual Rater 3'])
  448. mask = np.tril(np.ones_like(d, dtype=bool), k=-1)
  449. f, ax = plt.subplots(figsize=(3, 3))
  450. cmap = sn.diverging_palette(10, 250, s=90, l=40, as_cmap=True)
  451. sn.set(font_scale=3)
  452. hmap=sn.heatmap(d, mask=mask.T, cmap=cmap, vmax=1, vmin=0, center=0, annot=True, square=True, linewidths=1, cbar_kws={"shrink": .6}, fmt=".3g")
  453. hmap.set_xticklabels(hmap.get_xmajorticklabels(), fontsize = 40, rotation=45)
  454. hmap.set_yticklabels(hmap.get_ymajorticklabels(), fontsize = 40)
  455. hmap.figure.set_size_inches(22, 18)
  456. plt.tight_layout()
  457. hmap.figure.savefig("/home/user/owncloud/thesis_figures/Correlation_MR_CY_drag.png", format='png', dpi=200)
  458. sn.set_theme(style="white")
  459. d = pd.DataFrame(data=np.array([[1,jaccard(mr_cyl_drag_1_corr, mr_cyl_drag_2_corr), jaccard(mr_cyl_drag_1_corr, mr_cyl_drag_3_corr), jaccard(mr_cyl_drag_1_corr, drag_2d_corr)],
  460. [jaccard(mr_cyl_drag_1_corr, mr_cyl_drag_2_corr), 1, jaccard(mr_cyl_drag_2_corr, mr_cyl_drag_3_corr), jaccard(mr_cyl_drag_2_corr, drag_2d_corr)],
  461. [jaccard(mr_cyl_drag_1_corr, mr_cyl_drag_3_corr), jaccard(mr_cyl_drag_2_corr, mr_cyl_drag_3_corr), 1, jaccard(mr_cyl_drag_3_corr, drag_2d_corr)],
  462. [jaccard(mr_cyl_drag_1_corr, drag_2d_corr), jaccard(mr_cyl_drag_2_corr, drag_2d_corr), jaccard(mr_cyl_drag_3_corr, drag_2d_corr), 1]])
  463. , columns=['Manual Rater 1', 'Manual Rater 2', 'Manual Rater 3', 'DLC'], index=['Manual Rater 1', 'Manual Rater 2', 'Manual Rater 3', 'DLC'])
  464. mask = np.tril(np.ones_like(d, dtype=bool), k=-1)
  465. f, ax = plt.subplots(figsize=(4, 4))
  466. cmap = sn.diverging_palette(10, 250, s=90, l=40, as_cmap=True)
  467. sn.set(font_scale=3)
  468. hmap=sn.heatmap(d, mask=mask.T, cmap=cmap, vmax=1, vmin=0, center=0, annot=True, square=True, linewidths=1, cbar_kws={"shrink": .6}, fmt=".3g")
  469. hmap.set_xticklabels(hmap.get_xmajorticklabels(), fontsize = 40, rotation=45)
  470. hmap.set_yticklabels(hmap.get_ymajorticklabels(), fontsize = 40)
  471. hmap.figure.set_size_inches(22, 18)
  472. plt.tight_layout()
  473. hmap.figure.savefig("/home/user/owncloud/thesis_figures/Correlation_DLC_CY_drag_2d.png", format='png', dpi=200)
  474. sn.set_theme(style="white")
  475. d = pd.DataFrame(data=np.array([[1,jaccard(mr_cyl_drag_1_corr, mr_cyl_drag_2_corr), jaccard(mr_cyl_drag_1_corr, mr_cyl_drag_3_corr), jaccard(mr_cyl_drag_1_corr, drag_FI_2d_corr)],
  476. [jaccard(mr_cyl_drag_1_corr, mr_cyl_drag_2_corr), 1, jaccard(mr_cyl_drag_2_corr, mr_cyl_drag_3_corr), jaccard(mr_cyl_drag_2_corr, drag_FI_2d_corr)],
  477. [jaccard(mr_cyl_drag_1_corr, mr_cyl_drag_3_corr), jaccard(mr_cyl_drag_2_corr, mr_cyl_drag_3_corr), 1, jaccard(mr_cyl_drag_3_corr, drag_FI_2d_corr)],
  478. [jaccard(mr_cyl_drag_1_corr, drag_FI_2d_corr), jaccard(mr_cyl_drag_2_corr, drag_FI_2d_corr), jaccard(mr_cyl_drag_3_corr, drag_FI_2d_corr), 1]])
  479. , columns=['Manual Rater 1', 'Manual Rater 2', 'Manual Rater 3', 'DLC'], index=['Manual Rater 1', 'Manual Rater 2', 'Manual Rater 3', 'DLC'])
  480. mask = np.tril(np.ones_like(d, dtype=bool), k=-1)
  481. f, ax = plt.subplots(figsize=(4, 4))
  482. cmap = sn.diverging_palette(10, 250, s=90, l=40, as_cmap=True)
  483. sn.set(font_scale=3)
  484. hmap=sn.heatmap(d, mask=mask.T, cmap=cmap, vmax=1, vmin=0, center=0, annot=True, square=True, linewidths=1, cbar_kws={"shrink": .6}, fmt=".3g")
  485. hmap.set_xticklabels(hmap.get_xmajorticklabels(), fontsize = 40, rotation=45)
  486. hmap.set_yticklabels(hmap.get_ymajorticklabels(), fontsize = 40)
  487. hmap.figure.set_size_inches(22, 18)
  488. plt.tight_layout()
  489. hmap.figure.savefig("/home/user/owncloud/thesis_figures/Correlation_DLC_CY_drag_FI_2d.png", format='png', dpi=200)
  490. sn.set_theme(style="white")
  491. d = pd.DataFrame(data=np.array([[1,jaccard(mr_cyl_drag_1_corr, mr_cyl_drag_2_corr), jaccard(mr_cyl_drag_1_corr, mr_cyl_drag_3_corr), jaccard(mr_cyl_drag_1_corr, drag_3d_corr)],
  492. [jaccard(mr_cyl_drag_1_corr, mr_cyl_drag_2_corr), 1, jaccard(mr_cyl_drag_2_corr, mr_cyl_drag_3_corr), jaccard(mr_cyl_drag_2_corr, drag_3d_corr)],
  493. [jaccard(mr_cyl_drag_1_corr, mr_cyl_drag_3_corr), jaccard(mr_cyl_drag_2_corr, mr_cyl_drag_3_corr), 1, jaccard(mr_cyl_drag_3_corr, drag_3d_corr)],
  494. [jaccard(mr_cyl_drag_1_corr, drag_3d_corr), jaccard(mr_cyl_drag_2_corr, drag_3d_corr), jaccard(mr_cyl_drag_3_corr, drag_3d_corr), 1]])
  495. , columns=['Manual Rater 1', 'Manual Rater 2', 'Manual Rater 3', 'DLC'], index=['Manual Rater 1', 'Manual Rater 2', 'Manual Rater 3', 'DLC'])
  496. mask = np.tril(np.ones_like(d, dtype=bool), k=-1)
  497. f, ax = plt.subplots(figsize=(4, 4))
  498. cmap = sn.diverging_palette(10, 250, s=90, l=40, as_cmap=True)
  499. sn.set(font_scale=3)
  500. hmap=sn.heatmap(d, mask=mask.T, cmap=cmap, vmax=1, vmin=0, center=0, annot=True, square=True, linewidths=1, cbar_kws={"shrink": .6}, fmt=".3g")
  501. hmap.set_xticklabels(hmap.get_xmajorticklabels(), fontsize = 40, rotation=45)
  502. hmap.set_yticklabels(hmap.get_ymajorticklabels(), fontsize = 40)
  503. hmap.figure.set_size_inches(22, 18)
  504. plt.tight_layout()
  505. hmap.figure.savefig("/home/user/owncloud/thesis_figures/Correlation_DLC_CY_drag_3d.png", format='png', dpi=200)
  506. sn.set_theme(style="white")
  507. d = pd.DataFrame(data=np.array([[1,jaccard(mr_cyl_drag_1_corr, mr_cyl_drag_2_corr), jaccard(mr_cyl_drag_1_corr, mr_cyl_drag_3_corr), jaccard(mr_cyl_drag_1_corr, drag_FI_3d_corr)],
  508. [jaccard(mr_cyl_drag_1_corr, mr_cyl_drag_2_corr), 1, jaccard(mr_cyl_drag_2_corr, mr_cyl_drag_3_corr), jaccard(mr_cyl_drag_2_corr, drag_FI_3d_corr)],
  509. [jaccard(mr_cyl_drag_1_corr, mr_cyl_drag_3_corr), jaccard(mr_cyl_drag_2_corr, mr_cyl_drag_3_corr), 1, jaccard(mr_cyl_drag_3_corr, drag_FI_3d_corr)],
  510. [jaccard(mr_cyl_drag_1_corr, drag_FI_3d_corr), jaccard(mr_cyl_drag_2_corr, drag_FI_3d_corr), jaccard(mr_cyl_drag_3_corr, drag_FI_3d_corr), 1]])
  511. , columns=['Manual Rater 1', 'Manual Rater 2', 'Manual Rater 3', 'DLC'], index=['Manual Rater 1', 'Manual Rater 2', 'Manual Rater 3', 'DLC'])
  512. mask = np.tril(np.ones_like(d, dtype=bool), k=-1)
  513. f, ax = plt.subplots(figsize=(4, 4))
  514. cmap = sn.diverging_palette(10, 250, s=90, l=40, as_cmap=True)
  515. sn.set(font_scale=3)
  516. hmap=sn.heatmap(d, mask=mask.T, cmap=cmap, vmax=1, vmin=0, center=0, annot=True, square=True, linewidths=1, cbar_kws={"shrink": .6}, fmt=".3g")
  517. hmap.set_xticklabels(hmap.get_xmajorticklabels(), fontsize = 40, rotation=45)
  518. hmap.set_yticklabels(hmap.get_ymajorticklabels(), fontsize = 40)
  519. hmap.figure.set_size_inches(22, 18)
  520. plt.tight_layout()
  521. hmap.figure.savefig("/home/user/owncloud/thesis_figures/Correlation_DLC_CY_drag_FI_3d.png", format='png', dpi=200)
  522. print('CY drag 3D')
  523. df=pd.DataFrame({'index':[i for i in range(len(mr_cyl_drag_1_corr))]+[i for i in range(len(mr_cyl_drag_2_corr))]+[i for i in range(len(mr_cyl_drag_3_corr))], 'rater':['1']*len(mr_cyl_drag_1_corr)+['2']*len(mr_cyl_drag_2_corr)+['3']*len(mr_cyl_drag_3_corr), 'rating':np.concatenate((mr_cyl_drag_1_corr, mr_cyl_drag_2_corr, mr_cyl_drag_3_corr))})
  524. icc = pg.intraclass_corr(data=df, targets='index', raters='rater', ratings='rating', nan_policy='omit')
  525. print(icc.loc[2])
  526. df=pd.DataFrame({'index':[i for i in range(len(mr_cyl_drag_1_corr))]+[i for i in range(len(mr_cyl_drag_2_corr))]+[i for i in range(len(mr_cyl_drag_3_corr))]+[i for i in range(len(drag_2d_corr))], 'rater':['1']*len(mr_cyl_drag_1_corr)+['2']*len(mr_cyl_drag_2_corr)+['3']*len(mr_cyl_drag_3_corr)+['DLC']*len(drag_2d_corr), 'rating':np.concatenate((mr_cyl_drag_1_corr, mr_cyl_drag_2_corr, mr_cyl_drag_3_corr, drag_2d_corr))})
  527. icc = pg.intraclass_corr(data=df, targets='index', raters='rater', ratings='rating', nan_policy='omit')
  528. print(icc.loc[2])
  529. df=pd.DataFrame({'index':[i for i in range(len(mr_cyl_drag_1_corr))]+[i for i in range(len(mr_cyl_drag_2_corr))]+[i for i in range(len(mr_cyl_drag_3_corr))]+[i for i in range(len(drag_FI_2d_corr))], 'rater':['1']*len(mr_cyl_drag_1_corr)+['2']*len(mr_cyl_drag_2_corr)+['3']*len(mr_cyl_drag_3_corr)+['DLC']*len(drag_FI_2d_corr), 'rating':np.concatenate((mr_cyl_drag_1_corr, mr_cyl_drag_2_corr, mr_cyl_drag_3_corr, drag_FI_2d_corr))})
  530. icc = pg.intraclass_corr(data=df, targets='index', raters='rater', ratings='rating', nan_policy='omit')
  531. print(icc.loc[2])
  532. df=pd.DataFrame({'index':[i for i in range(len(mr_cyl_drag_1_corr))]+[i for i in range(len(mr_cyl_drag_2_corr))]+[i for i in range(len(mr_cyl_drag_3_corr))]+[i for i in range(len(drag_3d_corr))], 'rater':['1']*len(mr_cyl_drag_1_corr)+['2']*len(mr_cyl_drag_2_corr)+['3']*len(mr_cyl_drag_3_corr)+['DLC']*len(drag_3d_corr), 'rating':np.concatenate((mr_cyl_drag_1_corr, mr_cyl_drag_2_corr, mr_cyl_drag_3_corr, drag_3d_corr))})
  533. icc = pg.intraclass_corr(data=df, targets='index', raters='rater', ratings='rating', nan_policy='omit')
  534. print(icc.loc[2])
  535. df=pd.DataFrame({'index':[i for i in range(len(mr_cyl_drag_1_corr))]+[i for i in range(len(mr_cyl_drag_2_corr))]+[i for i in range(len(mr_cyl_drag_3_corr))]+[i for i in range(len(drag_FI_3d_corr))], 'rater':['1']*len(mr_cyl_drag_1_corr)+['2']*len(mr_cyl_drag_2_corr)+['3']*len(mr_cyl_drag_3_corr)+['DLC']*len(drag_FI_3d_corr), 'rating':np.concatenate((mr_cyl_drag_1_corr, mr_cyl_drag_2_corr, mr_cyl_drag_3_corr, drag_FI_3d_corr))})
  536. icc = pg.intraclass_corr(data=df, targets='index', raters='rater', ratings='rating', nan_policy='omit')
  537. print(icc.loc[2])
  538. # ============================================================================================================================================