实现todo1
This commit is contained in:
parent
383b19772b
commit
7be32c1a24
@ -87,6 +87,6 @@ PSG_Post: 对PSG后端截断若干个点,单位为点的个数,仅计算信
|
|||||||
~~bug1: 预置截断时,选点后图显示不准确~~ 已修复
|
~~bug1: 预置截断时,选点后图显示不准确~~ 已修复
|
||||||
~~bug2: 自定义起始位置spinbox编辑未结束会进行计算~~ 已修复
|
~~bug2: 自定义起始位置spinbox编辑未结束会进行计算~~ 已修复
|
||||||
|
|
||||||
todo1: 将相关计算分段计算,减少程序卡顿
|
~~todo1: 将相关计算分段计算,减少程序卡顿~~ 已实现
|
||||||
todo2: 将程序编译为exe文件,减少安装依赖的过程
|
todo2: 将程序编译为exe文件,减少安装依赖的过程
|
||||||
todo3: 加入可控选择CPU数量或占用百分比,避免造成电脑卡顿
|
~~todo3: 加入可控选择CPU数量或占用百分比,避免造成电脑卡顿~~ 后者较难实现,暂行搁置
|
||||||
|
@ -15,7 +15,6 @@ import pyedflib
|
|||||||
import numpy as np
|
import numpy as np
|
||||||
import pandas as pd
|
import pandas as pd
|
||||||
from PySide6.QtGui import QPixmap, QImage
|
from PySide6.QtGui import QPixmap, QImage
|
||||||
|
|
||||||
from PySide6.QtWidgets import QApplication, QMainWindow, QFileDialog, QMessageBox, QWidget, QPushButton
|
from PySide6.QtWidgets import QApplication, QMainWindow, QFileDialog, QMessageBox, QWidget, QPushButton
|
||||||
from matplotlib.backends.backend_agg import FigureCanvasAgg as FigureCanvas
|
from matplotlib.backends.backend_agg import FigureCanvasAgg as FigureCanvas
|
||||||
from matplotlib.figure import Figure
|
from matplotlib.figure import Figure
|
||||||
@ -513,16 +512,19 @@ class Data:
|
|||||||
return canvas.buffer_rgba(), width, height
|
return canvas.buffer_rgba(), width, height
|
||||||
|
|
||||||
|
|
||||||
@njit("int64[:](int64[:],int64[:])", nogil=True, parallel=True)
|
@njit("int64[:](int64[:],int64[:], int32[:])", nogil=True, parallel=True)
|
||||||
def get_Correlate(a, v):
|
def get_Correlate(a, v, between):
|
||||||
result = np.empty(len(a) - len(v) * 1 - 1, dtype=np.int64)
|
begin, end = between
|
||||||
for i in prange(len(a) - len(v) - 1):
|
if end == 0:
|
||||||
result[i] = np.sum(a[i:i + len(v)] * v)
|
end = len(a) - len(v) - 1
|
||||||
|
result = np.empty(end - begin, dtype=np.int64)
|
||||||
|
for i in prange(end - begin):
|
||||||
|
result[i] = np.sum(a[begin + i: begin + i + len(v)] * v)
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
|
||||||
get_Correlate(np.array([0, 0, 0, 0, 1, 2, 3, 4, 5, 0, 0, 0, 0], dtype=np.int64),
|
get_Correlate(np.array([0, 0, 0, 0, 1, 2, 3, 4, 5, 0, 0, 0, 0], dtype=np.int64),
|
||||||
np.array([1, 2, 3, 4, 5], dtype=np.int64))
|
np.array([1, 2, 3, 4, 5], dtype=np.int64), between=np.array([0, 0]))
|
||||||
|
|
||||||
|
|
||||||
class MainWindow(QMainWindow):
|
class MainWindow(QMainWindow):
|
||||||
@ -546,7 +548,6 @@ class MainWindow(QMainWindow):
|
|||||||
self.ui.checkBox_PTHO.setEnabled(False)
|
self.ui.checkBox_PTHO.setEnabled(False)
|
||||||
self.ui.checkBox_custom.setEnabled(False)
|
self.ui.checkBox_custom.setEnabled(False)
|
||||||
|
|
||||||
|
|
||||||
# 绑定事件
|
# 绑定事件
|
||||||
# 刷新键分别获取PSG和XX文件夹里面的数据,获取所有编号显示在下拉框,比对编号同时存在的可选,仅存在一个文件夹的编号不可选
|
# 刷新键分别获取PSG和XX文件夹里面的数据,获取所有编号显示在下拉框,比对编号同时存在的可选,仅存在一个文件夹的编号不可选
|
||||||
self.ui.pushButton_Refresh.clicked.connect(self.__refresh__)
|
self.ui.pushButton_Refresh.clicked.connect(self.__refresh__)
|
||||||
@ -574,7 +575,6 @@ class MainWindow(QMainWindow):
|
|||||||
self.ui.checkBox_NABD.stateChanged.connect(self.__enableAlign__)
|
self.ui.checkBox_NABD.stateChanged.connect(self.__enableAlign__)
|
||||||
self.ui.spinBox_custom.editingFinished.connect(self.__enableAlign__)
|
self.ui.spinBox_custom.editingFinished.connect(self.__enableAlign__)
|
||||||
|
|
||||||
|
|
||||||
def __readInfo__(self):
|
def __readInfo__(self):
|
||||||
"""
|
"""
|
||||||
读取信息
|
读取信息
|
||||||
@ -772,12 +772,23 @@ class MainWindow(QMainWindow):
|
|||||||
a = a.astype(np.int64)
|
a = a.astype(np.int64)
|
||||||
v = v.astype(np.int64)
|
v = v.astype(np.int64)
|
||||||
a = np.pad(a, (len(v) - 1, len(v) - 1), mode='constant')
|
a = np.pad(a, (len(v) - 1, len(v) - 1), mode='constant')
|
||||||
tho_relate = get_Correlate(a, v) / 10000
|
tho_relate = np.zeros(len(a) - len(v) - 1, dtype=np.int64)
|
||||||
|
len_calc = len(a) - len(v) - 1
|
||||||
|
# 将序列分成一百份来计算
|
||||||
|
for i in range(100):
|
||||||
|
tho_relate[i * len_calc // 100:(i + 1) * len_calc // 100] = get_Correlate(a, v, np.array(
|
||||||
|
[i * len_calc // 100, (i + 1) * len_calc // 100]))
|
||||||
|
|
||||||
|
self.ui.progressBar.setValue(i)
|
||||||
|
QApplication.processEvents()
|
||||||
|
|
||||||
|
tho_relate = tho_relate / 10000
|
||||||
tho_relate2 = - tho_relate
|
tho_relate2 = - tho_relate
|
||||||
|
|
||||||
self.ui.progressBar.setValue(40)
|
self.ui.progressBar.setValue(0)
|
||||||
self.ui.label_Info.setText("计算互相关2/2...")
|
self.ui.label_Info.setText("计算互相关2/2...")
|
||||||
QApplication.processEvents()
|
QApplication.processEvents()
|
||||||
|
|
||||||
a = self.data.processed_ABD[
|
a = self.data.processed_ABD[
|
||||||
self.data.Config["PSGConfig"]["PreCut"]:len(self.data.processed_ABD) - self.data.Config["PSGConfig"][
|
self.data.Config["PSGConfig"]["PreCut"]:len(self.data.processed_ABD) - self.data.Config["PSGConfig"][
|
||||||
"PostCut"]].copy()
|
"PostCut"]].copy()
|
||||||
@ -789,7 +800,17 @@ class MainWindow(QMainWindow):
|
|||||||
a = a.astype(np.int64)
|
a = a.astype(np.int64)
|
||||||
v = v.astype(np.int64)
|
v = v.astype(np.int64)
|
||||||
a = np.pad(a, (len(v) - 1, len(v) - 1), mode='constant')
|
a = np.pad(a, (len(v) - 1, len(v) - 1), mode='constant')
|
||||||
abd_relate = get_Correlate(a, v) / 10000
|
|
||||||
|
abd_relate = np.zeros(len(a) - len(v) - 1, dtype=np.int64)
|
||||||
|
len_calc = len(a) - len(v) - 1
|
||||||
|
# 将序列分成一百份来计算
|
||||||
|
for i in range(100):
|
||||||
|
abd_relate[i * len_calc // 100:(i + 1) * len_calc // 100] = get_Correlate(a, v, np.array(
|
||||||
|
[i * len_calc // 100, (i + 1) * len_calc // 100]))
|
||||||
|
self.ui.progressBar.setValue(i)
|
||||||
|
QApplication.processEvents()
|
||||||
|
|
||||||
|
abd_relate = abd_relate / 10000
|
||||||
abd_relate2 = - abd_relate
|
abd_relate2 = - abd_relate
|
||||||
|
|
||||||
self.ui.progressBar.setValue(80)
|
self.ui.progressBar.setValue(80)
|
||||||
|
Loading…
Reference in New Issue
Block a user