def build_dataset(self, datadir, spec, dset_name): print(dset_name) img = read_file(os.path.join(datadir, dset_name + "_img.h5")) mit0 = read_file(os.path.join(datadir, dset_name + "_mit.h5")).astype("float32") mit1 = read_file(os.path.join(datadir, dset_name + "_1eroded_mit.h5")).astype("float32") mit2 = read_file(os.path.join(datadir, dset_name + "_2eroded_mit.h5")).astype("float32") mit3 = read_file(os.path.join(datadir, dset_name + "_3eroded_mit.h5")).astype("float32") # seg = read_file(os.path.join(datadir, dset_name + "_seg.h5")) img = dp.transform.divideby(img, val=255.0, dtype="float32") mit0[mit0 != 0] = 1 #Binarizing psds mit1[mit1 != 0] = 1 #Binarizing psds mit2[mit2 != 0] = 1 #Binarizing psds mit3[mit3 != 0] = 1 #Binarizing psds vd = dp.VolumeDataset() vd.add_raw_data(key="input", data=img) vd.add_raw_data(key="mit0_label", data=mit0) vd.add_raw_data(key="mit1_label", data=mit1) vd.add_raw_data(key="mit2_label", data=mit2) vd.add_raw_data(key="mit3_label", data=mit3) # vd.add_raw_data(key="psd_mask", data=msk) vd.set_spec(spec) return vd
def make_forward_scanner(data_name, opt): # Read an EM image. if opt.dummy: img = np.random.rand(*opt.input_size[-3:]).astype('float32') else: img = emio.imread(os.path.join(opt.data_dir, data_name + '_img.h5')) img = (img / 255.).astype('float32') # Build Dataset. vd = dp.VolumeDataset() vd.add_raw_data(key='input', data=img) vd.set_spec(opt.in_spec) return dp.ForwardScanner(vd, opt.scan_spec, params=opt.scan_params)
def build_dataset(self): # Image. img = self.data['img'] # Segmentation. seg = self.data['seg'] # Mask. msk = self.data['msk_' + self.mode] # Build dataset. vd = dp.VolumeDataset() vd.add_raw_data(key='input', data=img) vd.add_raw_data(key='affinity', data=seg) vd.add_raw_mask(key='affinity_mask', data=msk, loc=True) vd.set_spec(self.spec) return vd
def make_forward_scanner(dset_name, data_dir, input_spec, scan_spec, scan_params, **params): """ Creates a DataProvider ForwardScanner from a dset name """ # Reading EM image # img = utils.read_h5(dset_name) print("image path", os.path.join(data_dir, dset_name + "_img.h5")) img = utils.read_h5(os.path.join(data_dir, dset_name + "_img.h5")) img = (img / 255.).astype("float32") # Creating DataProvider Dataset vd = dp.VolumeDataset() vd.add_raw_data(key="input", data=img) vd.set_spec(input_spec) # Returning DataProvider ForwardScanner return dp.ForwardScanner(vd, scan_spec, params=scan_params)
def build_dataset(self, datadir, spec, dset_name): print(dset_name) img = read_file(os.path.join(datadir, dset_name + "_img.h5")) psd = read_file(os.path.join(datadir, dset_name + "_mit.h5")).astype("float32") # seg = read_file(os.path.join(datadir, dset_name + "_seg.h5")) img = dp.transform.divideby(img, val=255.0, dtype="float32") psd[psd != 0] = 1 #Binarizing psds # msk = (seg == 0).astype("float32") #Boundary mask vd = dp.VolumeDataset() vd.add_raw_data(key="input", data=img) vd.add_raw_data(key="psd_label", data=psd) # vd.add_raw_data(key="psd_mask", data=msk) vd.set_spec(spec) return vd
def build_dataset(self, datadir, spec, dset_name, erode): print(dset_name) img = read_file(os.path.join(datadir, dset_name + "_img.h5")) mit_str = "_mit.h5" if erode: mit_str = "_"+str(erode)+"erode"+"_mit.h5" mit = read_file(os.path.join(datadir, dset_name + mit_str)).astype("float32") # print(img.shape) # print(mit.shape) # seg = read_file(os.path.join(datadir, dset_name + "_seg.h5")) img = dp.transform.divideby(img, val=255.0, dtype="float32") mit[mit != 0] = 1 #Binarizing psds vd = dp.VolumeDataset() vd.add_raw_data(key="input", data=img) vd.add_raw_data(key="psd_label", data=mit) # vd.add_raw_data(key="psd_mask", data=msk) vd.set_spec(spec) return vd
def build_dataset(self, datadir, spec, dset_name, resize): print(dset_name) img = read_file(os.path.join(datadir, dset_name + "_resized4_img.h5")) psd = read_file(os.path.join(datadir, dset_name + "_resized4_blood.h5")).astype("float32") # seg = read_file(os.path.join(datadir, dset_name + "_seg.h5")) img = dp.transform.divideby(img, val=255.0, dtype="float32") psd[psd != 0] = 1 #Binarizing psds #if (resize != 1): # img = utils.resize_image(img, resize) # psd = scipy.misc.imresize(psd, 1.0/resize, interp="bilinear") # msk = (seg == 0).astype("float32") #Boundary mask vd = dp.VolumeDataset() vd.add_raw_data(key="input", data=img) vd.add_raw_data(key="psd_label", data=psd) # vd.add_raw_data(key="psd_mask", data=msk) vd.set_spec(spec) return vd