DataPrepare/utils/split_method.py

28 lines
952 B
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

def resp_split(dataset_config, event_mask, event_list):
# 提取体动区间和呼吸低幅值区间
enable_list = event_list["EnableSegment"]
# 读取数据集配置
window_sec = dataset_config["window_sec"]
stride_sec = dataset_config["stride_sec"]
segment_list = []
# 遍历每个enable区间, 如果最后一个窗口不足stride的1/2则舍弃否则以enable_end为结尾截取一个窗口
for enable_start, enable_end in enable_list:
current_start = enable_start
while current_start + window_sec <= enable_end:
segment_list.append((current_start, current_start + window_sec))
current_start += stride_sec
# 检查最后一个窗口是否需要添加
if (enable_end - current_start >= stride_sec / 2) and (enable_end - current_start >= window_sec):
segment_list.append((enable_end - window_sec, enable_end))
return segment_list