suite2p.classification package#
Copyright © 2023 Howard Hughes Medical Institute, Authored by Carsen Stringer and Marius Pachitariu.
Classifier #
ROI classifier model that uses a weighted, non-parametric, naive Bayes classifier.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
classfile
|
str, optional (default None)
|
Path to saved classifier. |
None
|
keys
|
list of str, optional (default None)
|
Keys of ROI stat to use to classify. |
None
|
Source code in suite2p/classification/classifier.py
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 | |
load #
load(classfile, keys=None)
Load a saved classifier containing stats with classification labels.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
classfile
|
str
|
Path to saved classifier. |
required |
keys
|
list of str, optional (default None)
|
Keys of ROI stat to use to classify. |
None
|
Source code in suite2p/classification/classifier.py
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 | |
predict_proba #
predict_proba(stat)
Apply classifier and predict probabilities.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
stat
|
list of dict
|
List of ROI statistics dictionaries, each containing the keys in self.keys. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
y_pred |
ndarray
|
Predicted probability of each ROI being a cell, shape (n_rois,). |
Source code in suite2p/classification/classifier.py
81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 | |
run #
run(stat, p_threshold=0.5)
Return cell classification thresholded with p_threshold and its probability.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
stat
|
list of dict
|
List of ROI statistics dictionaries, each containing the keys in self.keys. |
required |
p_threshold
|
float, optional (default 0.5)
|
Probability threshold for classifying an ROI as a cell. |
0.5
|
Returns:
| Name | Type | Description |
|---|---|---|
iscell |
ndarray
|
Array of shape (n_rois, 2) where column 0 is the binary classification and column 1 is the probability. |
Source code in suite2p/classification/classifier.py
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 | |
save #
save(filename)
Save classifier to an .npy file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
filename
|
str
|
Path to save the classifier file. |
required |
Source code in suite2p/classification/classifier.py
101 102 103 104 105 106 107 108 109 110 111 112 113 114 | |
Copyright © 2023 Howard Hughes Medical Institute, Authored by Carsen Stringer and Marius Pachitariu.
classify #
classify(stat, classfile, keys=('skew', 'npix_norm', 'compact'))
Classify ROIs as cells or not cells using a saved classifier.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
stat
|
ndarray
|
Array of dictionaries, each containing ROI statistics, including the |
required |
classfile
|
str or Path
|
Path to saved classifier. |
required |
keys
|
sequence of str, optional (default ("skew", "npix_norm", "compact"))
|
Keys of ROI stat to use to classify. |
('skew', 'npix_norm', 'compact')
|
Returns:
| Name | Type | Description |
|---|---|---|
iscell |
ndarray
|
Array of shape (n_rois, 2) where column 0 is the binary classification and column 1 is the probability. |
Source code in suite2p/classification/classify.py
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 | |