preprocess_2.py 501 B

123456789101112
  1. def create_hdf5(img_data, t2_data, img_label, save_path):
  2. assert img_data.shape == img_label.shape, 'shape of data and label must be the same..'
  3. f = h5py.File(save_path, "w")
  4. dset = f.create_dataset("t1data", img_data.shape, dtype=np.int16)
  5. tset = f.create_dataset("t2data", t2_data.shape, dtype=np.int16)
  6. lset = f.create_dataset("label", img_data.shape, dtype=np.uint8)
  7. dset[...] = img_data
  8. lset[...] = img_label
  9. tset[...] = t2_data
  10. print('saved hdf5 file in %s' % (save_path, ))
  11. f.close()