Skip to content

Commit 9362998

Browse files
adding more options to classifier
1 parent 0aa4c3f commit 9362998

File tree

1 file changed

+15
-7
lines changed

1 file changed

+15
-7
lines changed

suite2p/classification/classify.py

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from . import Classifier
55

66

7-
def classify(ops, stat, keys=['npix_norm', 'compact', 'skew']):
7+
def classify(ops, stat, classfile=None, keys=['npix_norm', 'compact', 'skew']):
88
"""
99
Applies classifier and saves output to iscell.npy. Also, saves stat.npy.
1010
@@ -16,6 +16,9 @@ def classify(ops, stat, keys=['npix_norm', 'compact', 'skew']):
1616
1717
stat : array of dicts
1818
19+
classfile: string (optional)
20+
path to classifier
21+
1922
Returns
2023
-------
2124
@@ -28,12 +31,17 @@ def classify(ops, stat, keys=['npix_norm', 'compact', 'skew']):
2831
"""
2932
# apply default classifier
3033
if len(stat) > 0:
31-
user_dir = Path.home().joinpath('.suite2p')
32-
classfile = user_dir.joinpath('classifiers', 'classifier_user.npy')
33-
if not Path(classfile).is_file():
34-
s2p_dir = Path(__file__).parent.parent
35-
classfile = os.fspath(s2p_dir.joinpath('classifiers', 'classifier.npy'))
36-
print('NOTE: applying classifier %s'%classfile)
34+
if classfile is None or not Path(classfile).is_file():
35+
print('NOTE: applying default $HOME/.suite2p/classifiersclassifier_user.npy')
36+
user_dir = Path.home().joinpath('.suite2p')
37+
classfile = user_dir.joinpath('classifiers', 'classifier_user.npy')
38+
if not Path(classfile).is_file():
39+
print('(no user default classifier exists)')
40+
print('NOTE: applying $HOME/.suite2p/classifiers/classifier.npy')
41+
s2p_dir = Path(__file__).parent.parent
42+
classfile = os.fspath(s2p_dir.joinpath('classifiers', 'classifier.npy'))
43+
else:
44+
print('NOTE: applying classifier %s'%classfile)
3745
for k in keys:
3846
if k not in stat[0]:
3947
keys.remove(k)

0 commit comments

Comments
 (0)