MCPcopy Create free account
hub / github.com/KerenLab/CellSighter / load_image

Function load_image

data/utils.py:47–60  ·  view source on GitHub ↗
(image_path, cells_path, cells2labels_path, channels=[], to_pad=False, crop_size=0)

Source from the content-addressed store, hash-verified

45
46
47def 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
63def _extend_slices_1d(slc, crop_size, max_size):

Callers 1

load_samplesFunction · 0.85

Calls 1

load_dataFunction · 0.85

Tested by

no test coverage detected