Skip to content

Commit d8a4fb3

Browse files
fixing error message with cellpose model download
1 parent 6cf53ac commit d8a4fb3

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

suite2p/detection/detect.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -154,11 +154,12 @@ def detection_wrapper(f_reg, mov=None, yrange=None, xrange=None,
154154

155155
ymin = int(yrange[0])
156156
xmin = int(xrange[0])
157-
for s in stat:
158-
s['ypix'] += ymin
159-
s['xpix'] += xmin
160-
s['med'][0] += ymin
161-
s['med'][1] += xmin
157+
if len(stat) > 0:
158+
for s in stat:
159+
s['ypix'] += ymin
160+
s['xpix'] += xmin
161+
s['med'][0] += ymin
162+
s['med'][1] += xmin
162163

163164

164165
if ops['preclassify'] > 0:

suite2p/gui/rungui.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,12 @@
22
from datetime import datetime
33

44
import numpy as np
5+
56
from PyQt5 import QtGui, QtCore
67
from PyQt5.QtWidgets import QDialog, QLineEdit, QLabel, QPushButton, QWidget, QGridLayout, QButtonGroup, QComboBox, QTextEdit, QFileDialog
78

9+
from cellpose.models import get_user_models, model_path, MODEL_NAMES
10+
811
from . import io
912
from .. import default_ops
1013

@@ -389,6 +392,10 @@ def compile_ops_db(self):
389392
def run_S2P(self):
390393
if len(self.opslist)==0:
391394
self.add_ops()
395+
# pre-download model
396+
pretrained_model_string = self.ops.get('pretrained_model', 'cyto')
397+
pretrained_model_string = pretrained_model_string if pretrained_model_string is not None else 'cyto'
398+
pretrained_model_path = model_path(pretrained_model_string, 0, True)
392399
self.finish = True
393400
self.error = False
394401
ops_file = os.path.join(self.ops_path, 'ops.npy')

0 commit comments

Comments
 (0)