Skip to content

Commit

Permalink
dection based on the selected channel and so on
Browse files Browse the repository at this point in the history
  • Loading branch information
Ramin authored and Ramin committed Nov 4, 2023
1 parent 28cdb76 commit 1f760a2
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
7 changes: 5 additions & 2 deletions ross_backend/resources/detect.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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:
Expand Down Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion ross_ui/controller/mainWindow.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
7 changes: 4 additions & 3 deletions ross_ui/model/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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},
Expand All @@ -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):
Expand Down

0 comments on commit 1f760a2

Please sign in to comment.