- Rename the data:
# rename all the files in the folder
# all the file will in outside0\*\analysis\*.mat
# if file name contain "close"(case insensitive), rename it to "EyeClose.mat"
# if file name contain "open"(case insensitive), rename it to "EyeOpen.mat"
import os
import re
# get all the file path
def get_file_path(root_path):
file_path_list = []
for root, dirs, files in os.walk(root_path):
for file in files:
file_path_list.append(os.path.join(root, file))
return file_path_list
# rename the file
def rename_file(file_path_list):
for file_path in file_path_list:
file_name = os.path.basename(file_path)
if re.search(r'close', file_name, re.IGNORECASE):
new_file_name = 'EyeClose.mat'
elif re.search(r'open', file_name, re.IGNORECASE):
new_file_name = 'EyeOpen.mat'
else:
new_file_name = file_name
new_file_path = os.path.join(os.path.dirname(file_path), new_file_name)
os.rename(file_path, new_file_path)
if __name__ == '__main__':
root_path = r'D:\\BCG\\outside0'
file_path_list = get_file_path(root_path)
rename_file(file_path_list)
- Autoreject:
In Progress
In Progress