(image_path, cells_path, cells2labels_path, channels=[], to_pad=False, crop_size=0)
| 45 | |
| 46 | |
| 47 | def load_image(image_path, cells_path, cells2labels_path, channels=[], to_pad=False, crop_size=0): |
| 48 | image = load_data(image_path) |
| 49 | if len(channels) > 0: |
| 50 | image = image[..., channels] |
| 51 | cells = load_data(cells_path).astype(np.int64) |
| 52 | if cells2labels_path.endswith(".npz"): |
| 53 | cells2labels = np.load(cells2labels_path, allow_pickle=True)['data'].astype(np.int32) |
| 54 | elif cells2labels_path.endswith(".txt"): |
| 55 | with open(cells2labels_path, "r") as f: |
| 56 | cells2labels = np.array(f.read().strip().split('\n')).astype(float).astype(int) |
| 57 | if to_pad: |
| 58 | image = np.pad(image, ((crop_size // 2, crop_size // 2), (crop_size // 2, crop_size // 2), (0, 0)), 'constant') |
| 59 | cells = np.pad(cells, ((crop_size // 2, crop_size // 2), (crop_size // 2, crop_size // 2)), 'constant') |
| 60 | return image, cells, cells2labels |
| 61 | |
| 62 | |
| 63 | def _extend_slices_1d(slc, crop_size, max_size): |
no test coverage detected