Esempio n. 1
0
    def filtration(self, model_for_filtration, choice_filter):
        trend_filter = Trend()  # Тренд фильтра

        # Фильтр низких частот
        if choice_filter == 1:
            trend_filter.generation_trend_filter_potter()

        # Фильтр высоких частот
        if choice_filter == 2:
            trend_filter.generating_trend_high_potter()

        # Фильтр полосовой
        if choice_filter == 3:
            trend_filter.generating_trend_bandpass_filter()

        # Фильтр режекторный
        if choice_filter == 4:
            trend_filter.generating_trend_notch_filter()

        # Тренд существущей модели
        trend_model = Trend()
        trend_model.x = model_for_filtration.x
        trend_model.y = model_for_filtration.y
        trend_model.n = model_for_filtration.n

        trend = convolution(trend_model, trend_filter)
        self.x = trend.x
        self.y = trend.y
Esempio n. 2
0
    def filtration(self):
        if self.radioButton_image.isChecked():

            filter_trend = Trend()
            type_of_filter = self.comboBox_3.currentText()

            m = self.lineEdit_2.text()
            delta_t = self.lineEdit.text()
            fc_1 = self.lineEdit_3.text()
            fc_2 = self.lineEdit_4.text()
            error_dialog = QtWidgets.QErrorMessage()

            if m != '':
                try:
                    m = int(m)
                    filter_trend.m = m

                except:
                    error_dialog.showMessage(
                        'Значение m должны быть целочисленными. Использовано значение m по '
                        'умолчанию')

            if delta_t != '':
                try:
                    delta_t = float(delta_t)
                    filter_trend.delta_t = delta_t

                except:
                    error_dialog.showMessage(
                        'Значение delta t должны быть вещественными. Использовано значение delta t по '
                        'умолчанию')

            if fc_1 != '':
                try:
                    fc_1 = int(fc_1)
                    filter_trend.fc_1 = fc_1

                except:
                    error_dialog.showMessage(
                        'Значение fc_1 должны быть целочисленными. Использовано значение fc_1 по '
                        'умолчанию')

            if fc_2 != '':
                try:
                    fc_2 = int(fc_2)
                    filter_trend.fc_2 = fc_2

                except:
                    error_dialog.showMessage(
                        'Значение fc_2 должны быть целочисленными. Использовано значение fc_2 по '
                        'умолчанию')

            if type_of_filter == 'Низких частот':
                filter_trend.generation_trend_filter_potter()

            elif type_of_filter == 'Высоких частот':
                filter_trend.generating_trend_high_potter()

            elif type_of_filter == 'Полосовой':
                filter_trend.generating_trend_bandpass_filter()

            elif type_of_filter == 'Режекторный':
                filter_trend.generating_trend_notch_filter()

            place_to_show_image: int = int(self.comboBox_2.currentText())

            try:
                position_img: int = int(self.comboBox.currentText())
                img_path: str = POSITION_FOR_ANALYSIS.get(position_img)
            except:
                error_dialog.showMessage(
                    'Не найдено изображение для фильтрации')
                return

            filtration(img_path, filter_trend, place_to_show_image)

        else:
            type_of_filter_with_mask: str = self.comboBox_4.currentText()
            place_to_show_image: int = int(self.comboBox_2.currentText())
            error_dialog: object = QtWidgets.QErrorMessage()

            try:
                n_of_maska: int = int(self.lineEdit_5.text())
                if n_of_maska % 2 == 0:
                    n_of_maska = n_of_maska + 1

            except:
                n_of_maska: int = 3

            try:
                position_img: int = int(self.comboBox.currentText())
                img_path: str = POSITION_FOR_ANALYSIS.get(position_img)
            except:
                error_dialog.showMessage(
                    'Не найдено изображение для фильтрации')
                return

            if type_of_filter_with_mask == 'Арифметический':
                arithmetic_filter_img(img_path, place_to_show_image,
                                      n_of_maska)

            elif type_of_filter_with_mask == 'Медианный':
                median_img(img_path, place_to_show_image, n_of_maska)

        self.main_window.show_img(place_to_show_image)

        self.close_window()
Esempio n. 3
0
    def calculation(self):

        # y(x)=kx+b
        if self.option == 1:
            trend = Trend()
            trend.generating_trend_line()

            self.y = trend.y

        # y(x)=-kx+b
        if self.option == 2:
            trend = Trend()
            trend.generating_trend_line()
            trend.y = np.flip(trend.y)

            self.y = trend.y

        # y(x) = beta * exp^(alpha * i)
        if self.option == 3:
            trend = Trend()
            trend.generating_exhibitor()

            self.y = trend.y

        # y(x) = beta * exp^(alpha * -i)
        if self.option == 4:
            trend = Trend()
            trend.generating_exhibitor()
            trend.y = np.flip(trend.y)

            self.y = trend.y

        # Встроенный рандом
        if self.option == 5:
            trend = Trend()
            trend.generating_trend_random(self.s_min, self.s_max)

            self.y = trend.y

        # Кастомный рандом
        if self.option == 6:
            trend = Trend()
            trend.generating_custom_random()

            self.y = trend.y

        # Рандом + сдвиг
        if self.option == 7:
            trend1 = Trend()
            trend1.generating_trend_random(self.s_min, self.s_max)

            trend = self.shift(trend1)

            self.y = trend.y

            # Указали, что не требуется нормализация
            self.flag_normalisation = 0

        # Значения за областью
        if self.option == 8:
            trend1 = Trend()
            trend1.generating_random_spikes(self.s_min, self.s_max)

            self.y = trend1.y

            # Указали, что не требуется нормализация
            self.flag_normalisation = 0

        # Адитивная модель №1
        if self.option == 9:
            trend1 = Trend()
            trend1.generating_trend_line()
            trend1.y = np.flip(trend1.y)

            trend2 = Trend()
            trend2.generating_trend_random(self.s_min, self.s_max)

            trend = sum_trend(trend1, trend2)

            self.y = trend.y

        # Адитивная модель №2
        if self.option == 10:
            trend1 = Trend()
            trend1.generating_trend_line()

            trend2 = Trend()
            trend2.generating_trend_random(self.s_min, self.s_max)

            trend = sum_trend(trend1, trend2)

            self.y = trend.y

        # Мультипликативная модель №1
        if self.option == 11:
            trend1 = Trend()
            trend1.generating_trend_line()
            trend1.y = np.flip(trend1.y)

            trend2 = Trend()
            trend2.generating_trend_random(self.s_min, self.s_max)

            trend = multi(trend1, trend2)

            self.y = trend.y

        # Мультипликативная модель №2
        if self.option == 12:
            trend1 = Trend()
            trend1.generating_trend_line()

            trend2 = Trend()
            trend2.generating_trend_random(self.s_min, self.s_max)

            trend = multi(trend1, trend2)

            self.y = trend.y

        # График кусочной функции
        if self.option == 13:
            trend = Trend()
            trend.generating_piecewise_function(self.s_min, self.s_max)

            self.y = trend.y

        # График гармонический процесс
        if self.option == 17:
            trend = Trend()
            trend.generating_harmonic_process()

            if self.c != 0:
                self.y = self.y + self.c

            else:
                self.y = trend.y

            self.flag_normalisation = 0
            self.normalisation_axis()

        # График полигармонического процесса
        # x(t) = x1(t) + x2(t) = x3(t)
        # xi(t) = Ai * sin(2piFit)
        # A1 = 25       f1 = 11
        # A2 = 35       f2 = 41
        # A3 = 30       f3 = 141

        if self.option == 19:
            trend1 = Trend()
            trend2 = Trend()
            trend3 = Trend()

            trend1.a_0 = 25
            trend1.f_0 = 11
            trend1.generating_harmonic_process()

            trend2.a_0 = 35
            trend2.f_0 = 41
            trend2.generating_harmonic_process()

            trend3.a_0 = 30
            trend3.f_0 = 141
            trend3.generating_harmonic_process()

            trend4 = sum_trend(trend1, trend2)
            trend = sum_trend(trend4, trend3)

            self.y = trend.y

        # График Рандом + спайки
        if self.option == 20:
            trend_1 = Trend()
            trend_1.generating_trend_random(self.s_min, self.s_max)

            trend_2 = Trend()
            trend_2.generating_random_spikes(self.s_min, self.s_max)

            trend = sum_trend(trend_1, trend_2)

            self.y = trend.y

            self.flag_normalisation = 0
            self.axis_max = np.amax(self.y) * 1.2
            self.axis_min = np.amin(self.y) * 1.2

        # График Гармонический процесс + trend
        if self.option == 25:
            trend_1 = Trend()
            trend_2 = Trend()

            trend_1.generating_harmonic_process()
            trend_2.generating_trend_line()
            trend = sum_trend(trend_1, trend_2)

            self.y = trend.y

        # График Гармонический процесс + спайки
        if self.option == 26:
            trend_1 = Trend()
            trend_2 = Trend()

            trend_1.generating_harmonic_process()
            trend_2.generating_random_spikes(self.s_min, self.s_max)

            trend = sum_trend(trend_1, trend_2)

            self.y = trend.y

            self.flag_normalisation = 0
            self.normalisation_axis()

        # График ГП(гармонический процесс) + спайки + рандом + trend
        if self.option == 27:
            trend_1 = Trend()
            trend_2 = Trend()
            trend_3 = Trend()
            trend_4 = Trend()

            trend_1.generating_harmonic_process()
            trend_2.generating_random_spikes(self.s_min, self.s_max)
            trend_3.generating_trend_random(self.s_min, self.s_max)
            trend_4.generating_trend_line()

            trend = (trend_1, trend_2)
            trend = (trend, trend_3)
            trend = (trend, trend_4)

            self.y = trend.y

            self.flag_normalisation = 0
            self.normalisation_axis()

        # График из файла
        if self.option == 28:
            trend = Trend()
            trend.generating_trend_from_file()

            self.y = trend.y

            self.flag_normalisation = 0
            self.normalisation_axis()

        # График ГП + экспонента (кардиограма)
        if self.option == 29:
            self.n = 200
            self.x = np.arange(0, self.n)
            # self.delta_t = 0.005
            # self.display_n = self.n
            self.s_max = 1

            trend_1 = Trend()
            trend_1.n = self.n
            trend_1.x = self.x
            trend_1.delta_t = 0.005
            trend_1.generating_harmonic_process()

            trend_2 = Trend()
            trend_2.n = self.n
            trend_2.x = self.x
            trend_2.generating_exhibitor()

            # Получили тренд сердцебиения
            trend = multi(trend_1, trend_2)
            # self.y = trend.y
            # self.normalization()
            # trend.y = self.y

            self.n = 1000
            trend_3 = Trend()
            trend_3.generating_spikes(100)

            trend = convolution(trend_3, trend)

            self.y = trend.y
            self.x = trend.x
            self.s_max = 100
            self.s_min = -self.s_max

        # Реализация фильтров
        # Низких частот
        if self.option == 30:
            trend = Trend()
            trend.generation_trend_filter_potter()

            self.y = trend.y
            self.x = trend.x
            self.n = trend.n
            self.display_n = trend.display_n
            self.dt = trend.dt

        # Фильтр высоких частот
        if self.option == 31:
            trend = Trend()
            trend.generating_trend_high_potter()

            self.y = trend.y
            self.x = trend.x
            self.n = trend.n
            self.display_n = trend.display_n
            self.dt = trend.dt

        # Полосовой фильтр
        if self.option == 32:
            trend = Trend()
            trend.generating_trend_bandpass_filter()

            self.y = trend.y
            self.x = trend.x
            self.n = trend.n
            self.display_n = trend.display_n
            self.dt = trend.dt

        # Режекторный фильтр
        if self.option == 33:
            trend = Trend()
            trend.generating_trend_notch_filter()

            self.y = trend.y
            self.x = trend.x
            self.n = trend.n
            self.display_n = trend.display_n
            self.dt = trend.dt

        # Звук ma.wav
        if self.option == 34:
            self.name_of_wav_file = "../input files/custom.wav"
            sound_trend = Sound(self.name_of_wav_file)

            self.x = sound_trend.x
            self.y = sound_trend.y * self.c
            self.rate = sound_trend.rate

            self.n = len(self.x)
            self.flag_checking_display_n = 1

        # Звук my_voice.wav
        if self.option == 35:
            self.name_of_wav_file = "../input files/my_voice.wav"
            sound_trend = Sound(self.name_of_wav_file)

            self.x = sound_trend.x
            self.y = sound_trend.y * self.c
            self.rate = sound_trend.rate

            self.n = len(self.x)
            self.flag_checking_display_n = 1

        # Экзамен
        if self.option == 36:
            trend = Trend()
            trend.generating_trend_from_file_exam()

            self.y = trend.y

            self.flag_normalisation = 0
            self.normalisation_axis()

        # Модель Input: кардиограма, заполненная нулями с 200 до 1000
        if self.option == 37:
            self.n = 200
            self.x = np.arange(0, self.n)
            self.s_max = 1

            trend_1 = Trend()
            trend_1.n = self.n
            trend_1.x = self.x
            trend_1.delta_t = 0.005
            trend_1.generating_harmonic_process()

            trend_2_n = 800
            trend_2_y = np.zeros(trend_2_n)

            self.n = 1000
            self.x = np.arange(0, self.n)
            self.y = np.concatenate([trend_1.y, trend_2_y])

            print(self.y)
            self.s_max = 100
            self.s_min = -self.s_max