def extract_epochs(full_data, config): """Extract epochs from full subjects data. """ fps = config['fps'] start_at_frame = int(config['epoch_start'] * fps) duration_of_frames = int( (config['epoch_end'] - config['epoch_start']) * fps) assert (len(list(list(full_data.values())[0].keys())) == 1) info = list(full_data.values())[0]['run_0'].info inst_data = np.empty((60, 33, duration_of_frames)) inst_events = np.empty((3, 20, 3), dtype=np.int) inst_durations = np.empty((3, ), dtype=np.int) # store the length of sessions args = list( map(lambda x: [x, start_at_frame, duration_of_frames], full_data.values())) results = list(starmap(session_mapper, args)) for i, result in enumerate(results): data, events, duration = result inst_data[i * 20:(i + 1) * 20, :, :] = data inst_events[i] = events inst_durations[i] = duration inst_events[1, :, 0] += inst_durations[0] inst_events[2, :, 0] += np.sum(inst_durations[0:2]) inst_events = inst_events.reshape((60, 3)) this_sub_data = EpochsArray(inst_data, info, tmin=config['epoch_start'], events=inst_events, baseline=config['baseline']) this_sub_data.pick_channels(FRONTAL_CHANNEL + PARIENTAL_CHANNEL) filter_params, filter_dict = get_filter_params(config) this_sub_data.filter(*filter_params, **filter_dict) return this_sub_data