-
Notifications
You must be signed in to change notification settings - Fork 393
Open
Description
My supervisor gave me a piece of code. I ran it on the latest version of CaImAn, but Mask R-CNN consistently produces no ROIs, while it works well with the TensorFlow version utils.mrcnn_inference using the same config.
############ Segmentation
# Create mean and correlation images
img = mean_image(mc.mmap_file[0], window = 1000, dview=dview)
img = (img-np.mean(img))/np.std(img)
Cn = local_correlations_movie_offline(mc.mmap_file[0], fr=fr, window=fr*4, #### [0] ???
stride=fr*4, winSize_baseline=fr,
remove_baseline=True, gaussian_blur=gaussian_blur,
dview=dview).max(axis=0)
img_corr = (Cn-np.mean(Cn))/np.std(Cn)
summary_images = np.stack([img, img, img_corr], axis=0).astype(np.float32)
# Save summary images which could be further used in the VolPy GUI
cm.movie(summary_images).save(cells_savedir+ '//summary_images.tif')
print(cells_savedir+ '//summary_images.tif')
use_maskrcnn = True # set to True to predict the ROIs using the mask R-CNN
if not use_maskrcnn: # use manual annotations
with h5py.File(path_ROIs, 'r') as fl:
ROIs = fl['mov'][()] # load ROIs
else:
weights_path = "/root/caiman_data/model/mask_rcnn"
ROIs = utils.mrcnn_inference_pytorch(img=summary_images.transpose([1, 2, 0]), size_range=size_range,#[5, 22], size_range=[5,45]
weights_path=weights_path, display_result=True) # size parameter decides size range of masks to be selected
cm.movie(ROIs).save(cells_savedir + '//mrcnn_ROIs.hdf5')
print(cells_savedir + '//mrcnn_ROIs.hdf5')Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels