From 9829f4b77166e13ba7a138ecf76e764d126c9a1a Mon Sep 17 00:00:00 2001 From: andrew Date: Sat, 23 Sep 2023 16:15:31 +0800 Subject: [PATCH] =?UTF-8?q?numba=E5=8A=A0=E9=80=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- RespCoarseAlign.py | 30 ++++++++++++++---------------- requirements.txt | 2 +- 2 files changed, 15 insertions(+), 17 deletions(-) diff --git a/RespCoarseAlign.py b/RespCoarseAlign.py index b5c9307..7aac9f8 100644 --- a/RespCoarseAlign.py +++ b/RespCoarseAlign.py @@ -19,7 +19,7 @@ from PySide6.QtGui import QPixmap, QImage from PySide6.QtWidgets import QApplication, QMainWindow, QFileDialog, QMessageBox, QWidget, QPushButton from matplotlib.backends.backend_agg import FigureCanvasAgg as FigureCanvas from matplotlib.figure import Figure -# from numba import njit +from numba import njit from scipy import signal from ui.Mian import Ui_mainWindow as Ui_respCoarseAlign @@ -509,7 +509,7 @@ class Data: return canvas.buffer_rgba(), width, height -# @njit("int64[:](int64[:],int64[:])", nogil=True, parallel=True) +@njit("int64[:](int64[:],int64[:])", nogil=True, parallel=True) def get_Correlate(a, v): result = np.empty(len(a) - len(v) * 1 - 1, dtype=np.int64) for i in range(len(a) - len(v) - 1): @@ -762,13 +762,12 @@ class MainWindow(QMainWindow): v = self.data.processed_XX[ self.data.Config["XXConfig"]["PreCut"]:len(self.data.processed_XX) - self.data.Config["XXConfig"][ "PostCut"]].copy() - # a *= 100 - # v *= 100 - # a = a.astype(np.int64) - # v = v.astype(np.int64) - # a = np.pad(a, (len(v) - 1, len(v) - 1), mode='constant') - # tho_relate = get_Correlate(a, v) / 10000 - tho_relate = np.correlate(a, v, mode='full') + a *= 100 + v *= 100 + a = a.astype(np.int64) + v = v.astype(np.int64) + a = np.pad(a, (len(v) - 1, len(v) - 1), mode='constant') + tho_relate = get_Correlate(a, v) / 10000 tho_relate2 = - tho_relate self.ui.progressBar.setValue(40) @@ -780,13 +779,12 @@ class MainWindow(QMainWindow): v = self.data.processed_XX[ self.data.Config["XXConfig"]["PreCut"]:len(self.data.processed_XX) - self.data.Config["XXConfig"][ "PostCut"]].copy() - # a *= 100 - # v *= 100 - # a = a.astype(np.int64) - # v = v.astype(np.int64) - # a = np.pad(a, (len(v) - 1, len(v) - 1), mode='constant') - # abd_relate = get_Correlate(a, v) / 10000 - abd_relate = np.correlate(a, v, mode='full') + a *= 100 + v *= 100 + a = a.astype(np.int64) + v = v.astype(np.int64) + a = np.pad(a, (len(v) - 1, len(v) - 1), mode='constant') + abd_relate = get_Correlate(a, v) / 10000 abd_relate2 = - abd_relate self.ui.progressBar.setValue(80) diff --git a/requirements.txt b/requirements.txt index ea1e0a8..1936a6c 100644 --- a/requirements.txt +++ b/requirements.txt @@ -5,4 +5,4 @@ pyedflib matplotlib pySide6 pyyaml -# numba \ No newline at end of file +numba \ No newline at end of file