File size: 1,384 Bytes
44aae25
 
 
145a95e
44aae25
 
 
 
 
 
 
 
 
145a95e
44aae25
 
 
 
 
 
 
 
 
 
dd35a1d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import sys
import pandas as pd


# CSVファイルから信号データを読み込む
def load_signal(file_path, column_name):
    try:
        with open(file_path, 'r') as file:
            # データ部分が始まる行を見つける
            for i, line in enumerate(file):
                if 'Timestamp' in line:
                    header_line = i
                    break

        # 見つけたヘッダー行からデータを読み込む
        df = pd.read_csv(file_path, skiprows=header_line)
        signal = df[column_name].values
        return signal
    except FileNotFoundError as e:
        print(f"Error: {e}", file=sys.stderr)
        return []
    except KeyError as e:
        print(f"Column '{column_name}' not found in the file. ({e})", file=sys.stderr)
        return []


def band_intensity_setting_to_band(input: str):
    if "GAMMA" in input:
        return (30, 36)
    elif "BETA" in input:
        return (15, 30)
    elif "ALPHA" in input:
        return (8, 12)
    elif "THETA" in input:
        return (4, 8)
    elif "DELTA" in input:
        return (0, 4)
    else:
        print("Unknown band")
        return (None, None)


def integration_method_to_method(input: str):
    if "Trapezoid" in input:
        return "trapz"
    elif "Simpson" in input:
        return "simps"
    else:
        print("Unknown method")
        return None