preprocessing.py 文件源码

python
阅读 24 收藏 0 点赞 0 评论 0

项目:Epileptic-Seizure-Prediction 作者: cedricsimar 项目源码 文件源码
def split_data_in_epochs(self, data, epoch_length_sec, stride_sec):

        """
        Split the signal in no-dropout-epochs of fixed length
        """

        sig = np.array(data, dtype=np.float32)  # [240000 x 16]

        sig_epochs = []
        samples_in_epoch = epoch_length_sec * SAMPLING_FREQUENCY
        stride_shift = stride_sec * SAMPLING_FREQUENCY

        # compute dropout indices (dropouts are at the same position across all channels)
        drop_indices_c0 = np.where(sig[:,0]==0)[0]
        drop_indices_c1 = np.where(sig[:,1]==0)[0]
        drop_indices = np.intersect1d(drop_indices_c0, drop_indices_c1)
        drop_indices = np.append(drop_indices, len(sig)) # add the index of the last element

        window_start = 0
        for window_end in drop_indices:

            epoch_start = window_start
            epoch_end = epoch_start + samples_in_epoch

            while(epoch_end < window_end):
                sig_epochs.append(sig[epoch_start:epoch_end, :])
                epoch_start += stride_shift
                epoch_end += stride_shift

            window_start = window_end + 1

        return(sig_epochs)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号