def run(self): self.init_results() # TODELAY: split apart collecting of features and training lda? # however then you would not get progress output during training # only at very end for bp_nr, filt_band in enumerate(self.filterbands): self.print_filter(bp_nr) bandpassed_cnt = bandpass_cnt(self.cnt, filt_band[0], filt_band[1], filt_order=self.filt_order) if self.standardize_filt_cnt: bandpassed_cnt = exponential_standardize_cnt(bandpassed_cnt) epo = segment_dat_fast(bandpassed_cnt, marker_def=self.marker_def, ival=self.segment_ival) for fold_nr in xrange(len(self.folds)): self.run_fold(epo, bp_nr, fold_nr)
def fill_filterbank_data(self, full_epo_data): for filterband_i in xrange(len(self.filterbands)): low_freq, high_freq= self.filterbands[filterband_i] log.info("Filterband {:d} of {:d}, from {:5.2f} to {:5.2f}".format( filterband_i + 1, len(self.filterbands), low_freq, high_freq)) bandpassed_cnt = bandpass_cnt(self.signal_processor.cnt, low_freq, high_freq, filt_order=3) epo = segment_dat_fast(bandpassed_cnt, marker_def={'1 - Right Hand': [1], '2 - Left Hand': [2], '3 - Rest': [3], '4 - Feet': [4]}, ival=self.signal_processor.segment_ival) epo.data = np.float32(epo.data) epo = select_epochs(epo, self.rejected_trials, invert=True) full_epo_data[:,:,:,filterband_i] = epo.data del epo.data del bandpassed_cnt self.filterband_axes = epo.axes + [self.filterbands.tolist()] self.filterband_names = epo.names + ['filterband'] self.filterband_units = epo.units + ['Hz']
def load_and_preprocess_data(self): # First create eog set for blink rejection self.eog_set.load_signal_and_markers() self.eog_set.segment_into_trials() self.eog_set.remove_continuous_signal() # Then create bandpassed set for variance rejection # in case low or high cut hz is given if self.low_cut_hz is not None and self.high_cut_hz is not None: self.cnt = bandpass_cnt(self.cnt, self.low_cut_hz, self.high_cut_hz, self.filt_order) elif self.low_cut_hz is not None: self.cnt = highpass_cnt(self.cnt, self.low_cut_hz, self.filt_order) elif self.high_cut_hz is not None: self.cnt = lowpass_cnt(self.cnt, self.high_cut_hz, self.filt_order) else: assert self.low_cut_hz is None and self.high_cut_hz is None # Finally create trials self.epo = segment_dat_fast(self.cnt, marker_def=self.marker_def, ival=self.rejection_var_ival) del self.cnt # No longer needed