MouseLand / suite2p

cell detection in calcium imaging recordings
http://www.suite2p.org
GNU General Public License v3.0
344 stars 240 forks source link

BUG: oasis batches cells, not frames #997

Open RandallJEllis opened 1 year ago

RandallJEllis commented 1 year ago

Describe the issue:

In the oasis function, the batching is done on the row dimension (cells), not the column dimension (frames), but the docstring says batch_size controls the batching of frames:

F : float, 2D array size [neurons x time], in pipeline uses neuropil-subtracted fluorescence batch_size : int number of frames processed per batch

NN, NT = F.shape
F = F.astype(np.float32)
S = np.zeros((NN, NT), dtype=np.float32)
for i in range(0, NN, batch_size):
f = F[i:i + batch_size]
v = np.zeros((f.shape[0], NT), dtype=np.float32)
w = np.zeros((f.shape[0], NT), dtype=np.float32)
t = np.zeros((f.shape[0], NT), dtype=np.int64)
l = np.zeros((f.shape[0], NT), dtype=np.float32)
s = np.zeros((f.shape[0], NT), dtype=np.float32)
oasis_matrix(f, v, w, t, l, s, tau, fs)
S[i:i + batch_size] = s
return S

Reproduce the code example:

import numpy as np

batch_size = 200

# generate data with 1000 rows (cells) and 10000 columns (frames)
F = np.random.rand(1000,10000)

# subset the same way Suite2p does
f = F[0:0 + batch_size]
print(f.shape)
#(200,10000)

Error message:

No response

Version information:

0.12.1

Context for the issue:

No response