From 1f760a2d328a0f11a6a133dcf63918f761e35e3b Mon Sep 17 00:00:00 2001 From: Ramin Date: Sat, 4 Nov 2023 10:39:57 +0330 Subject: [PATCH] dection based on the selected channel and so on --- ross_backend/resources/detect.py | 7 +++++-- ross_ui/controller/mainWindow.py | 2 +- ross_ui/model/api.py | 7 ++++--- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/ross_backend/resources/detect.py b/ross_backend/resources/detect.py index 5af8d36..d52902f 100644 --- a/ross_backend/resources/detect.py +++ b/ross_backend/resources/detect.py @@ -26,7 +26,8 @@ class DetectDefault(Resource): parser.add_argument('post_thr', type=int, required=True) parser.add_argument('dead_time', type=int, required=True) parser.add_argument('run_detection', type=bool, default=False) - parser.add_argument('project_id', type=int, default=False) + parser.add_argument('project_id', type=int, default=0) + parser.add_argument('channel', type=int, default=0) @jwt_required def get(self): @@ -40,6 +41,8 @@ def get(self): def post(self): data = DetectDefault.parser.parse_args() project_id = data['project_id'] + channel = data['channel'] + user_id = get_jwt_identity() config = ConfigDetectionModel.find_by_project_id(project_id) if config: @@ -83,7 +86,7 @@ def post(self): with open(raw.data, 'rb') as f: data = pickle.load(f) - spikeMat, spikeTime, pca_spikes, inds = startDetection(data, config) + spikeMat, spikeTime, pca_spikes, inds = startDetection(data(channel), config) data_file = {'spikeMat': spikeMat, 'spikeTime': spikeTime, 'config': config.json(), 'pca_spikes': pca_spikes, diff --git a/ross_ui/controller/mainWindow.py b/ross_ui/controller/mainWindow.py index 60bd8f3..773cc71 100644 --- a/ross_ui/controller/mainWindow.py +++ b/ross_ui/controller/mainWindow.py @@ -538,7 +538,7 @@ def onDetect(self): config_detect = self.read_config_detect() self.statusBar().showMessage(self.tr("Detection Started...")) self.processEvents() - res = self.user.start_detection(config_detect) + res = self.user.start_detection(config_detect, self.combo_box_channel.currentIndex()) if res['stat']: self.statusBar().showMessage(self.tr("Detection Done."), 2500) diff --git a/ross_ui/model/api.py b/ross_ui/model/api.py index 0daf70e..c2ad23a 100644 --- a/ross_ui/model/api.py +++ b/ross_ui/model/api.py @@ -206,12 +206,13 @@ def get_config_sort(self): return {'stat': False, 'message': response.json()["message"]} return {'stat': False, 'message': 'Not Logged In!'} - def start_detection(self, config): + def start_detection(self, config, channel): if self.access_token is not None: data = config data['run_detection'] = True data['project_id'] = self.project_id + data['channel'] = channel response = requests.post(self.url + '/detect', headers={'Authorization': 'Bearer ' + self.access_token}, @@ -222,8 +223,8 @@ def start_detection(self, config): elif response.status_code == 401: ret = self.refresh_jwt_token() if ret: - self.start_detection(config) - return {'stat': False, 'message': response.json()["message"]} + self.start_detection(config, channel) + return {'stat': False, 'message': response.content} return {'stat': False, 'message': 'Not Logged In!'} def start_sorting(self, config):