MouseLand / suite2p

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

Extract ROI from the second channel #1072

Closed Ayetheint closed 6 months ago

Ayetheint commented 7 months ago

Hi, I have similar questions like #150. I ran Suite2P using GUI to detect GCaMP activity and also have red channel in one-plane .tiff file that label some cells. I want to select which cells have red labelling on Suite2P GUI. I only used GUI so it would be nice if I could do that on GUI or appreciate instructions if I have use Jupyter Notebook or something else. Thanks.

chriski777 commented 6 months ago

Hi @Ayetheint, you should be able to do this using the Jupyter Notebook and the suite2p outputs. You'll want to start by loading the stat.npy, iscell.npy, redcell.npy files.

import numpy as np
rois = np.load('stat.npy', allow_pickle=True)[()]
iscell = np.load('iscell.npy', allow_pickle=True)[()]
redcellprobs = np.load('redcell.npy', allow_pickle=True)[()]

rois will be an array of length num_rois in which each element contains a dictionary containing ROI-specific information. xpix and ypix of the ROI dictionary will contain the x and y-coordinates of the pixels corresponding to the ROI. redcellprobs contains an array of shape num_rois x 2 in which the first column specifies whether the ROI was detected on the red channel. You can use the first column of redcellprobs and iscell to identify the ROIs that had red labeling and were classified as cells. Then you can take the xpix and ypix coordinates to get the cells with red labeling.