MouseLand / suite2p

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

DOC: How does one retrieve ncells and image distortion #990

Closed loganPasternak67854 closed 1 year ago

loganPasternak67854 commented 1 year ago

Issue with current documentation:

Hello,

I've been trying to run the example image extraction code on the Output page of the suite2p website, but I'm having an issue where some of the image matrices have pixel values larger than 255 and look distorted. I'm figuring the issue has to do with how I define ncells. I'm not quite sure where ncells comes from in the example. I currently have ncells equal to stat.size. The version of the code I have is down bellow. Please let me know if there is something I'm missing.

Thanks

def extract_ROI(statPath,opsPath):

stat = np.load(statPath,allow_pickle=True)
ops = np.load(opsPath,allow_pickle=True)
ops=ops.item()

im = np.zeros((ops['Ly'], ops['Lx']))

ncells=stat.size

#What is ncells? Is one supposed to retrieve it from ops in some way?

for n in range(0,ncells):

    ypix = stat[n]['ypix'][~stat[n]['overlap']]
    xpix = stat[n]['xpix'][~stat[n]['overlap']]
    im[ypix,xpix] = n+1

return im  

Idea or request for content:

How would one go about retrieving ncells? Is it a value that is retrieved from stat or ops. Example python code would be appreciated.

chriski777 commented 1 year ago

Hi @loganPasternak67854, n_cells is determined during the classification step of the pipeline. One of the outputs of suite2p is iscell.npy. This array will be of shape num_ROIs x 2. The first column of this array specifies whether the identified ROI is considered a cell by the classifier used during runtime. You can find n_cells by counting up how many of these ROIs have their first column value set to 1.

chriski777 commented 1 year ago

Closing this issue, @loganPasternak67854. Feel free to reopen this issue if you have any other questions!