Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Data-preprocessing #4

Open
howard9199 opened this issue Nov 5, 2023 · 0 comments
Open

Data-preprocessing #4

howard9199 opened this issue Nov 5, 2023 · 0 comments
Assignees

Comments

@howard9199
Copy link

  1. 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)
  1. Autoreject:
    In Progress
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant