Skip to content

Commit cc602bd

Browse files
committed
caiman.source_extraction.cnmf.deconvolution.GetSn(): Simplify phrasing of code
1 parent 618bcab commit cc602bd

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

caiman/source_extraction/cnmf/deconvolution.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1041,14 +1041,15 @@ def GetSn(fluor, range_ff=[0.25, 0.5], method='logmexp'):
10411041
ind2 = ff < range_ff[1]
10421042
ind = np.logical_and(ind1, ind2)
10431043
Pxx_ind = Pxx[ind]
1044-
sn = {
1045-
'mean': lambda Pxx_ind: np.sqrt(np.mean(Pxx_ind / 2)),
1046-
'median': lambda Pxx_ind: np.sqrt(np.median(Pxx_ind / 2)),
1047-
'logmexp': lambda Pxx_ind: np.sqrt(np.exp(np.mean(np.log(Pxx_ind / 2))))
1048-
}[method](Pxx_ind)
1049-
1050-
return sn
10511044

1045+
if method == 'mean':
1046+
return np.sqrt(np.mean(Pxx_ind / 2))
1047+
elif method == 'median':
1048+
return np.sqrt(np.median(Pxx_ind / 2))
1049+
elif method == 'logmexp':
1050+
return np.sqrt(np.exp(np.mean(np.log(Pxx_ind / 2))))
1051+
else
1052+
raise Exception('Invalid method requested for GetSn')
10521053

10531054
def axcov(data, maxlag=5):
10541055
"""

0 commit comments

Comments
 (0)