diff --git a/pyfluo/data.py b/pyfluo/data.py index d39c41d..2de4796 100644 --- a/pyfluo/data.py +++ b/pyfluo/data.py @@ -1434,4 +1434,16 @@ def process_roi(self, dist_thresh=5, **kwargs): closeby_kw.update(distance_thresh = dist_thresh_pix) roi_new = process_roi(roi, dff, closeby_kw=closeby_kw, **kwargs) + + # remove anything outside motion borders + y0,x0 = int(np.floor(self.motion_borders.ymin)), int(np.floor(self.motion_borders.xmin)) + y1,x1 = int(np.ceil(self.motion_borders.ymax)), int(np.ceil(self.motion_borders.xmax)) + if roi_new.ndim == 2: + roi_new = np.array([roi_new]) + roi_new = roi_new.astype(bool) + roi_new[:,:y0,:] = False + roi_new[:,y1:,:] = False + roi_new[:,:,:x0] = False + roi_new[:,:,x1:] = False + self.set_roi(roi_new)