forked from chema2001/EEG-Situ_VS_EEG-fMRI
-
Notifications
You must be signed in to change notification settings - Fork 0
/
write_condition_sheet.py
47 lines (36 loc) · 1.23 KB
/
write_condition_sheet.py
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
35
36
37
38
39
40
41
42
43
44
45
46
47
import os
import numpy as np
def run_fast_scandir(dir, ext): # dir: str, ext: list
subfolders, datafiles = [], []
for f in os.scandir(dir):
if f.is_dir():
subfolders.append(f.path)
if f.is_file():
if os.path.splitext(f.name)[1].lower() in ext:
datafiles.append(f.path)
for dir in list(subfolders):
sf, f = run_fast_scandir(dir, ext)
subfolders.extend(sf)
datafiles.extend(f)
return subfolders, datafiles
_, imgs = run_fast_scandir('C:/Users/migue/OneDrive/Ambiente de Trabalho/EEG stuff/IEEE project/EEG-Situ_VS_EEG-fMRI/Celebs', [".jpg"])
target_img = 'Daniel_Radcliffe'
from pandas import DataFrame
images = []
stim = []
for i, img in enumerate(imgs):
aux = img.split('\\')[:]
conc_string = ''.join(["Celebs"+"/", aux[1]])
images.append(conc_string)
print(conc_string)
if target_img in conc_string:
aux_stim = 'target'
else:
aux_stim = 'non_target'
stim.append(aux_stim)
df = DataFrame({'image': images, 'stimulus': stim})
'''
permutation = np.random.permutation(df.index)
shuffled_df = df.loc[permutation] # .loc -> Select rows
shuffled_df.to_excel('stims.xlsx', sheet_name='sheet1', index=False)
'''