-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplot_ev_frames.py
More file actions
34 lines (26 loc) · 1.11 KB
/
plot_ev_frames.py
File metadata and controls
34 lines (26 loc) · 1.11 KB
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
import os
import numpy as np
import matplotlib.pyplot as plt
root_dir_in = f'{os.path.dirname(os.path.abspath(__file__))}/DATA/EventFrames2/TEST_FULL_SEQUENCE'
root_dir_out = f'{os.path.dirname(os.path.abspath(__file__))}/DATA/trials'
subjects = [2]
configs = [1, 2, 3, 4, 5]
for subject in subjects:
for config in configs:
f_name_frames_ev = f'{root_dir_in}/subject{subject:02}_seq{config:02}.npy'
f_output_dir = f'{root_dir_out}/subject{subject:02}_seq{config:02}/frames'
if not os.path.exists(f_output_dir):
os.makedirs(f_output_dir)
frames = np.load(f_name_frames_ev)
for i, frame in enumerate(frames):
fig, axs = plt.subplots(1, 1)
mpos = frame[:,:,0,0]
mpos[mpos == 0] = np.nan
mpos = mpos.astype(np.float32)
axs.imshow(mpos, alpha=0.5, cmap='Reds')
mneg = frame[:,:,0,1]
mneg[mneg == 0] = np.nan
mneg = mneg.astype(np.float32)
axs.imshow(mneg, alpha=0.5, cmap='Greens')
fig.savefig(f'{f_output_dir}/frame_{i:05d}.png')
plt.close(fig)