-
Notifications
You must be signed in to change notification settings - Fork 0
/
uncut_file_renaming.py
54 lines (45 loc) · 1.25 KB
/
uncut_file_renaming.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
48
49
50
51
52
53
"""
Renaming function
Run in python to standardise the medstim-state
coding of the acc files.
Perform before cutting so the cutted blocks
have the correct M0S0 naming
"""
if __name__ == 'main':
# import necessary functions
import os
from retap_utils import utils_dataManagement
uncut_path = utils_dataManagement.find_stored_data_path('uncut')
state_strings = {
'M0S0': [
'MedOffStimOff',
'MOffSOff',
'medOff_stimOff'
],
'M0S1': [
'MedOffStimOn',
'MOffSOn',
'medOff_stimOn'
],
'M1S0': [
'MedOnStimOff',
'MOnSOff',
'medOn_stimOff'
],
'M1S1': [
'MedOnStimOn',
'MOnSOn',
'medOn_stimOn'
]
}
for f in os.listdir(uncut_path):
for state in state_strings:
for string in state_strings[state]:
if string in f:
f_new = f.replace(string, state)
print('rename', f)
os.rename(
os.path.join(uncut_path, f),
os.path.join(uncut_path, f_new)
)
print('\tinto', f_new)