Open silkenelson opened 2 years ago
@vespos this seems like a nice implementation, but it will not work if one wanted overlapping ROIs. One could use bits rather than integers for that, but I may be overthinking this problem right now. @Yanwen-Sun what do you think?
I love the idea of overlapping ROIs. Either use bits, or a 3D mask? I guess the first solution is more beautiful.
(from Yanwen:) I am not sure whether we want it to be able to get probabilites for multiple ROIs
def getProb_img(photonlist, mask, Np=12): nx,ny = mask.shape
nroi as the number of rois
nroi = int(mask.max()) p = np.zeros((1,Np,nroi)) ave0, xedges, yedges = np.histogram2d(photonlist[:,1]+0.5, photonlist[:,2]+0.5, bins=[np.arange(nx+1),np.arange(ny+1)]) for roi_num in range(1,nroi+1): npx = np.where(mask == roi_num)[0].size p[0,:,roi_num-1] = np.bincount(np.int32(ave0[mask==roi_num].ravel()),minlength = Np)[:Np] p[0,-1,roi_num-1] = ave0[mask == roi_num].sum() p[0,:,roi_num-1] /=float(npx) return p