Browse Source

display2d center_cut_screenshot

vogdb 5 years ago
parent
commit
d814c317a6
1 changed files with 33 additions and 9 deletions
  1. 33 9
      epileptor/display_2d.py

+ 33 - 9
epileptor/display_2d.py

@@ -190,6 +190,29 @@ def display_state_at_points(dt, state, data_filename, point_index_list, line_lis
     plt.savefig(os.path.join(media_fpath, fig_fname))
 
 
+def center_cut_screenshot(dt, t_dt, state, data_filename):
+    fig = plt.gcf()
+    ax = plt.gca()
+    ax.axis('off')
+    ax.imshow(state.values[t_dt, :, :], cmap='jet')
+    rect = patches.Rectangle((40, 0), 5, 79, linewidth=2, edgecolor='#CD5C5C', clip_on=False, fill=False)
+    ax.add_patch(rect)
+
+    rect = patches.Rectangle((-5, 63), 2, 16, clip_on=False, facecolor='000')
+    ax.add_patch(rect)
+    ax.text(-10, 69, '1mm', color='000', fontsize=14, rotation=90)
+
+    rect = patches.Rectangle((0, 81), 16, 2, clip_on=False, facecolor='000')
+    ax.add_patch(rect)
+    ax.text(3, 87, '1mm', color='000', fontsize=14)
+
+    title = 'cut_H_{}_at{}s_{}'.format(state.name, util.dt_to_sec(t_dt, dt), data_filename)
+    fig_fname = '{}.{}'.format(title, img_ext)
+    plt.savefig(os.path.join(media_fpath, fig_fname))
+    ax.clear()
+    fig.clear()
+
+
 def center_cut_t_evolution(dt, state, data_filename):
     values = state.values
     # Those values should be set manually. Now they are set for 2019-04-04_19.16
@@ -207,28 +230,29 @@ def center_cut_t_evolution(dt, state, data_filename):
     ax = fig.add_subplot(111, xticks=[], yticks=[])
     img = ax.imshow(center_cut.T, cmap='jet', aspect=4.0)
 
-    rect = patches.Rectangle((0, 90), 500, 5, clip_on=False, linewidth=.5, edgecolor='000', facecolor='000')
+    rect = patches.Rectangle((0, 90), 500, 5, clip_on=False, facecolor='000')
     ax.add_patch(rect)
-    ax.text(50, 115, '0.1s', color='000', weight='bold', fontsize=14)
+    ax.text(160, 115, '0.1s', color='000', fontsize=10)
 
-    rect = patches.Rectangle((-35, 65), 15, 15, clip_on=False, linewidth=.5, edgecolor='000', facecolor='000')
+    rect = patches.Rectangle((-35, 65), 15, 15, clip_on=False, facecolor='000')
     ax.add_patch(rect)
-    ax.text(-80, 65, '0.1mm', color='000', weight='bold', fontsize=8, rotation=90)
+    ax.text(-100, 65, '1mm', color='000', fontsize=10, rotation=90)
 
     cbar_ax = fig.add_axes([0.5, 0.25, .4, .1], xticks=[], yticks=[], frameon=False)
     cbar = plt.colorbar(
         mappable=img, ax=cbar_ax, orientation='horizontal',
         fraction=1.0, pad=0.01
     )
-    tick_locator = ticker.MaxNLocator(nbins=3)
-    cbar.locator = tick_locator
-    cbar.update_ticks()
-
+    ticks = [int(np.min(center_cut)), int(np.max(center_cut))]
+    cbar.set_ticks(ticks)
+    cbar.set_ticklabels([str(tick) + 'mV' for tick in ticks])
 
     title = 'cut_{}_at{}s_{}'.format(state.name, int(dt_begin / 1000), data_filename)
     fig_fname = '{}.{}'.format(title, img_ext)
     plt.savefig(os.path.join(media_fpath, fig_fname))
-    ax.clear()
+    fig.clear()
+
+    center_cut_screenshot(dt, dt_begin, state, data_filename)
 
 
 media_fpath = 'media'