def load_tif(self,paths): """ read tifs found at paths (list with paths) """ # reading x,y,t = io.read_tiffstack(paths[0]).shape n = len(paths) self.Main.Data.raw = sp.zeros((x,y,t,n),dtype='uint16') self.Main.Data.dFF = sp.zeros((x,y,t,n),dtype='float32') for n,path in enumerate(paths): print "loading dataset from " + path print "Dataset size: " + str(os.stat(path).st_size / 1000000.0) + ' MB' self.Main.MainWindow.statusBar().showMessage("loading dataset: " + path) self.Main.Data.raw[:,:,:,n] = io.read_tiffstack(path) self.Main.MainWindow.statusBar().clearMessage()
def load_tif(self, paths): """ read tifs found at paths (list with paths) """ # reading x, y, t = io.read_tiffstack(paths[0]).shape n = len(paths) self.Main.Data.raw = sp.zeros((x, y, t, n), dtype='uint16') self.Main.Data.dFF = sp.zeros((x, y, t, n), dtype='float32') for n, path in enumerate(paths): print "loading dataset from " + path print "Dataset size: " + str( os.stat(path).st_size / 1000000.0) + ' MB' self.Main.MainWindow.statusBar().showMessage("loading dataset: " + path) self.Main.Data.raw[:, :, :, n] = io.read_tiffstack(path) self.Main.MainWindow.statusBar().clearMessage()
def load_nonparametric_ROIs(self, size_filter=None, thresh=0.5): """ reads a *_mask.tif size_filter can be a tuple and segments with an area smaller than size_filter[0] or larger size_filter[1] are considered to be valid ROIs """ self.Main.ROIs.reset() # get mask data file_path = self.OpenFileDialog( title='load nonparametric ROIs', default_dir=self.Main.Options.general['cwd'], extension='*.tif')[0] masks = io.read_tiffstack(file_path) # skimage based segmentation masks_thresh = masks > thresh masks_label = sp.zeros(masks_thresh.shape) for i in range(masks_thresh.shape[2]): masks_label[:, :, i] = sklabel(masks_thresh[:, :, i]) # split into a array of submasks Nsubmasks = [ int(masks_label[:, :, i].max()) for i in range(masks_label.shape[2]) ] submasks = sp.zeros((masks.shape[0], masks.shape[1], sum(Nsubmasks)), dtype='bool') i = 0 for j in range(masks_label.shape[2]): mask = masks_label[:, :, j] for l in range(1, Nsubmasks[j] + 1): submasks[mask == l, i] = True i += 1 # for each mask, calculate a contour contours = [] for i in range(submasks.shape[2]): contour = find_contours(submasks[:, :, i], level=0.5) contours.append(contour) # add PolyLineROI for i in range(submasks.shape[2]): self.Main.ROIs.add_ROI(kind='nonparametric', label=str(i), contour=contours[i], mask=submasks[:, :, i]) pass
def load_nonparametric_ROIs(self,size_filter=None,thresh=0.5): """ reads a *_mask.tif size_filter can be a tuple and segments with an area smaller than size_filter[0] or larger size_filter[1] are considered to be valid ROIs """ self.Main.ROIs.reset() # get mask data file_path = self.OpenFileDialog(title='load nonparametric ROIs',default_dir = self.Main.Options.general['cwd'], extension='*.tif')[0] masks = io.read_tiffstack(file_path) # skimage based segmentation masks_thresh = masks > thresh masks_label = sp.zeros(masks_thresh.shape) for i in range(masks_thresh.shape[2]): masks_label[:,:,i] = sklabel(masks_thresh[:,:,i]) # split into a array of submasks Nsubmasks = [int(masks_label[:,:,i].max()) for i in range(masks_label.shape[2])] submasks = sp.zeros((masks.shape[0],masks.shape[1],sum(Nsubmasks)),dtype='bool') i = 0 for j in range(masks_label.shape[2]): mask = masks_label[:,:,j] for l in range(1,Nsubmasks[j]+1): submasks[mask == l,i] = True i += 1 # for each mask, calculate a contour contours = [] for i in range(submasks.shape[2]): contour = find_contours(submasks[:,:,i],level=0.5) contours.append(contour) # add PolyLineROI for i in range(submasks.shape[2]): self.Main.ROIs.add_ROI(kind='nonparametric',label=str(i),contour=contours[i],mask=submasks[:,:,i]) pass