def _load_test_data_from_file(self, patient, filename, preprocess=True):
        """
        Loading single file test data
        :param patient:
        :param filename:
        :return:
        """
        assert ( filename.find('test'))
        print "\nLoading test data for " + patient + filename
        eeg_data_tmp = EEGData(filename)
        eeg_data = eeg_data_tmp.get_instances()
        assert len(eeg_data) == 1
        eeg_data = eeg_data[0]

        fs = eeg_data.sample_rate
        # preprocessing
        data = eeg_data.eeg_data

        params = self.params
        params['fs']=fs

        ### comment if no preprocessing
        if preprocess==True:
            eeg_data.eeg_data = preprocessing.preprocess_multichannel_data(data,params)
        x = self.feature_extractor.extract(eeg_data)
        self.features_test.append(np.hstack(x))
    def load_train_data_from_file(patient_name, filename, params=None):
        """
        Loading single file training data
        filename: full path to .mat file 
        return: (EEG data Instance, y_seizure, y_early)
        """
        #print "\nLoading train data for " + patient_name + filename
        eeg_data_tmp = EEGData(filename)
        # a list of Instance's
        eeg_data = eeg_data_tmp.get_instances()
        assert len(eeg_data) == 1

        eeg_data = eeg_data[0]
        # eeg_data is now an Instance
        # determine labels based on filename
        if filename.find('interictal') > -1:
            y_seizure = 0
            y_early = 0
        elif eeg_data.latency < 15:
            y_seizure = 1
            y_early = 1
        else:
            y_seizure = 1
            y_early = 0

        fs = eeg_data.sample_rate

        # preprocessing
        data = eeg_data.eeg_data
        params['fs'] = fs

        eeg_data.eeg_data = preprocessing.preprocess_multichannel_data(
            data, params)
        return (eeg_data, y_seizure, y_early)
Ejemplo n.º 3
0
    def _load_test_data_from_file(self, patient, filename, preprocess=True):
        """
        Loading single file test data
        :param patient:
        :param filename:
        :return:
        """
        assert (filename.find('test'))
        print("\nLoading test data for " + patient + filename)
        eeg_data_tmp = EEGData(filename)
        eeg_data = eeg_data_tmp.get_instances()
        assert len(eeg_data) == 1
        eeg_data = eeg_data[0]

        fs = eeg_data.sample_rate
        # preprocessing
        data = eeg_data.eeg_data

        params = self.params
        params['fs'] = fs

        ### comment if no preprocessing
        if preprocess == True:
            eeg_data.eeg_data = preprocessing.preprocess_multichannel_data(
                data, params)
        x = self.feature_extractor.extract(eeg_data)
        self.features_test.append(np.hstack(x))
    def _load_data_from_file(self, filename):
        eeg = EEGData(filename)
        instances = eeg.get_instances()
        filename2 = filename.replace('interictal', 'ictal')
        eeg2 = EEGData(filename2)
        instances2 = eeg2.get_instances()

        feature_vectors = []

        for instance in instances:
            new_features = self._get_feature_vector_from_instance(instance)
            feature_vectors.append(new_features)
        for instance in instances2:
            new_features = self._get_feature_vector_from_instance(instance)
            feature_vectors.append(new_features)

        self.episode_matrices.append(self._merge_vectors_into_matrix(feature_vectors))
#        self.type_labels.append(np.ones(len(feature_vectors), dtype=np.int8) * eeg.label)
        eeg_labels = np.ones(len(instances), dtype=np.int8) * eeg.label
        eeg2_labels = np.ones(len(instances2), dtype=np.int8) * eeg2.label
        self.type_labels.append(np.concatenate((eeg_labels, eeg2_labels)))

        # Only have 1 if there is a seizure and it is early
#        self.early_labels.append(np.array(map(self._is_early, instances), dtype=np.int8) * eeg.label)
        early_labels = np.array(map(self._is_early, instances), dtype=np.int8) * eeg.label
        early2_labels = np.array(map(self._is_early, instances2), dtype=np.int8) * eeg2.label
        self.early_labels.append(np.concatenate((early_labels, early2_labels)))
Ejemplo n.º 5
0
    def _load_training_data_from_file(self,
                                      patient,
                                      filename,
                                      preprocess=True):
        """
        Loading single file training data
        :param patient:
        :param filename:
        :return:
        """
        #print "\nLoading train data for " + patient + filename
        eeg_data_tmp = EEGData(filename)
        # a list of Instance's
        eeg_data = eeg_data_tmp.get_instances()
        assert len(eeg_data) == 1
        # eeg_data is now an Instance

        eeg_data = eeg_data[0]
        if filename.find('interictal') > -1:
            y_seizure = 0
            y_early = 0
        elif eeg_data.latency < 15:
            y_seizure = 1
            y_early = 1
        else:
            y_seizure = 1
            y_early = 0

        fs = eeg_data.sample_rate

        # preprocessing
        data = eeg_data.eeg_data

        params = self.params
        params['fs'] = fs
        ### comment if no preprocessing
        if preprocess == True:
            eeg_data.eeg_data = preprocessing.preprocess_multichannel_data(
                data, params)
        ###
        x = self.feature_extractor.extract(eeg_data)
        self.features_train.append(np.hstack(x))
        self.type_labels.append(y_seizure)
        self.early_labels.append(y_early)
    def load_test_data_from_file(patient_name, filename, params=None):
        """
        Loading single file test data
        :return: EEG data Instance (no labels returned)
        """
        assert (filename.find('test'))
        #print "\nLoading test data for " + patient_name + filename
        eeg_data_tmp = EEGData(filename)
        eeg_data = eeg_data_tmp.get_instances()
        assert len(eeg_data) == 1
        # an Instance
        eeg_data = eeg_data[0]
        fs = eeg_data.sample_rate
        data = eeg_data.eeg_data
        params['fs'] = fs

        eeg_data.eeg_data = preprocessing.preprocess_multichannel_data(
            data, params)
        return eeg_data
    def _load_training_data_from_file(self, patient, filename, preprocess=True):
        """
        Loading single file training data
        :param patient:
        :param filename:
        :return:
        """
        #print "\nLoading train data for " + patient + filename
        eeg_data_tmp = EEGData(filename)
        # a list of Instance's
        eeg_data = eeg_data_tmp.get_instances()
        assert len(eeg_data) == 1
        # eeg_data is now an Instance

        eeg_data = eeg_data[0]
        if filename.find('interictal') > -1:
            y_seizure=0
            y_early=0
        elif eeg_data.latency < 15:
            y_seizure=1
            y_early=1
        else:
            y_seizure=1
            y_early=0

        fs = eeg_data.sample_rate

        # preprocessing
        data = eeg_data.eeg_data

        params = self.params
        params['fs']=fs
        ### comment if no preprocessing
        if preprocess==True:
            eeg_data.eeg_data = preprocessing.preprocess_multichannel_data(data,params)
        ###
        x = self.feature_extractor.extract(eeg_data)
        self.features_train.append(np.hstack(x))
        self.type_labels.append(y_seizure)
        self.early_labels.append(y_early)
Ejemplo n.º 8
0
    def _load_data_from_file(self, filename):
        eeg = EEGData(filename)
        instances = eeg.get_instances()
        filename2 = filename.replace('interictal', 'ictal')
        eeg2 = EEGData(filename2)
        instances2 = eeg2.get_instances()

        feature_vectors = []

        for instance in instances:
            new_features = self._get_feature_vector_from_instance(instance)
            feature_vectors.append(new_features)
        for instance in instances2:
            new_features = self._get_feature_vector_from_instance(instance)
            feature_vectors.append(new_features)

        self.episode_matrices.append(self._merge_vectors_into_matrix(feature_vectors))
#        self.type_labels.append(np.ones(len(feature_vectors), dtype=np.int8) * eeg.label)
        eeg_labels = np.ones(len(instances), dtype=np.int8) * eeg.label
        eeg2_labels = np.ones(len(instances2), dtype=np.int8) * eeg2.label
        self.type_labels.append(np.concatenate((eeg_labels, eeg2_labels)))

        # Only have 1 if there is a seizure and it is early
#        self.early_labels.append(np.array(map(self._is_early, instances), dtype=np.int8) * eeg.label)
        early_labels = np.array(list(map(self._is_early, instances)), dtype=np.int8) * eeg.label
        early2_labels = np.array(list(map(self._is_early, instances2)), dtype=np.int8) * eeg2.label
        self.early_labels.append(np.concatenate((early_labels, early2_labels)))