def load_file(file_name, standardize, demean): bbci_set = BBCIDataset(file_name, load_sensor_names=get_EEG_sensors_sorted()) log.info("Loading...") cnt = bbci_set.load() log.info("Set cz to zero and remove high absolute value trials") marker_def = dict([(str(i_class), [i_class]) for i_class in xrange(1,5)]) clean_result = MaxAbsCleaner(threshold=800, marker_def=marker_def, segment_ival=[0,4000]).clean(cnt) cnt = restrict_cnt(cnt, marker_def.values(), clean_result.clean_trials, clean_result.rejected_chan_names, copy_data=False) cnt = set_channel_to_zero(cnt, 'Cz') log.info("Resampling...") cnt = resample_cnt(cnt, newfs=250.0) log.info("Car filtering...") cnt = common_average_reference_cnt(cnt) if standardize: log.info("Standardizing...") cnt = exponential_standardize_cnt(cnt) if demean: log.info("Demeaning...") cnt = exponential_demean_cnt(cnt) return cnt
def load_file(file_name, standardize, demean): bbci_set = BBCIDataset(file_name, load_sensor_names=get_EEG_sensors_sorted()) log.info("Loading...") cnt = bbci_set.load() log.info("Set cz to zero and remove high absolute value trials") marker_def = dict([(str(i_class), [i_class]) for i_class in xrange(1, 5)]) clean_result = MaxAbsCleaner(threshold=800, marker_def=marker_def, segment_ival=[0, 4000]).clean(cnt) cnt = restrict_cnt(cnt, marker_def.values(), clean_result.clean_trials, clean_result.rejected_chan_names, copy_data=False) cnt = set_channel_to_zero(cnt, 'Cz') log.info("Resampling...") cnt = resample_cnt(cnt, newfs=250.0) log.info("Car filtering...") cnt = common_average_reference_cnt(cnt) if standardize: log.info("Standardizing...") cnt = exponential_standardize_cnt(cnt) if demean: log.info("Demeaning...") cnt = exponential_demean_cnt(cnt) return cnt
def preprocess_test_set(self): if self.sensor_names is not None: self.sensor_names = sort_topologically(self.sensor_names) self.test_cnt = select_channels(self.test_cnt, self.sensor_names) if self.set_cz_to_zero is True: self.test_cnt = set_channel_to_zero(self.test_cnt, 'Cz') if self.resample_fs is not None: self.test_cnt = resample_cnt(self.test_cnt, newfs=self.resample_fs) if self.common_average_reference is True: self.test_cnt = common_average_reference_cnt(self.test_cnt) if self.standardize_cnt is True: self.test_cnt = exponential_standardize_cnt(self.test_cnt)
def preprocess_set(self): # only remove rejected channels now so that clean function can # be called multiple times without changing cleaning results self.cnt = select_channels(self.cnt, self.rejected_chan_names, invert=True) if self.sensor_names is not None: # Note this does not respect order of sensor names, # it selects chans form given sensor names # but keeps original order self.cnt = select_channels(self.cnt, self.sensor_names) if self.set_cz_to_zero is True: self.cnt = set_channel_to_zero(self.cnt, 'Cz') if self.resample_fs is not None: self.cnt = resample_cnt(self.cnt, newfs=self.resample_fs) if self.common_average_reference is True: self.cnt = common_average_reference_cnt(self.cnt) if self.standardize_cnt is True: self.cnt = exponential_standardize_cnt(self.cnt)