def test_03_03_load_color_frame(self): path = os.path.join(testimages_directory(), "DrosophilaEmbryo_GFPHistone.avi") workspace = self.run_workspace(path, N.LOAD_AS_COLOR_IMAGE, index=3) image = workspace.image_set.get_image(IMAGE_NAME) pixel_data = image.pixel_data self.assertSequenceEqual(pixel_data.shape, (264, 542, 3)) self.assertTrue(np.all(pixel_data >= 0)) self.assertTrue(np.all(pixel_data <= 1)) self.assertTrue(np.any(pixel_data[:, :, 0] != pixel_data[:, :, 1])) self.assertTrue(np.any(pixel_data[:, :, 0] != pixel_data[:, :, 2]))
def test_03_03_load_color_frame(self): path = os.path.join(testimages_directory(), "DrosophilaEmbryo_GFPHistone.avi") workspace = self.run_workspace(path, N.LOAD_AS_COLOR_IMAGE, index = 3) image = workspace.image_set.get_image(IMAGE_NAME) pixel_data = image.pixel_data self.assertSequenceEqual(pixel_data.shape, (264, 542, 3)) self.assertTrue(np.all(pixel_data >= 0)) self.assertTrue(np.all(pixel_data <= 1)) self.assertTrue(np.any(pixel_data[:, :, 0] != pixel_data[:, :, 1])) self.assertTrue(np.any(pixel_data[:, :, 0] != pixel_data[:, :, 2]))
def test_03_06_load_monochrome_plane(self): path = os.path.join(testimages_directory(), "5channel.tif") for i in range(5): workspace = self.run_workspace(path, N.LOAD_AS_GRAYSCALE_IMAGE, index=i) image = workspace.image_set.get_image(IMAGE_NAME) pixel_data = image.pixel_data self.assertSequenceEqual(pixel_data.shape, (64, 64)) if i == 0: plane_0 = pixel_data.copy() else: self.assertTrue(np.any(pixel_data != plane_0))
def test_04_03_load_planes(self): file_name = "RLM1 SSN3 300308 008015000.flex" maybe_download_test_image(file_name) path = testimages_directory() pathname = os.path.join(path, file_name) url = pathname2url(pathname) ftrs = (cpmeas.C_URL, cpmeas.C_SERIES, cpmeas.C_FRAME) channels = ("Channel1", "Channel2") header = ",".join([ ",".join(["_".join((ftr, channel)) for ftr in ftrs]) for channel in channels ]) csv_lines = [header] for series in range(4): csv_lines.append(",".join([ '"%s","%d","%d"' % (url, series, frame) for frame in range(2) ])) csv_text = "\n".join(csv_lines) pipeline, module, filename = self.make_pipeline(csv_text) assert isinstance(module, L.LoadData) m = cpmeas.Measurements() image_set_list = cpi.ImageSetList() try: workspace = cpw.Workspace(pipeline, module, m, None, m, image_set_list) self.assertTrue(module.prepare_run(workspace)) pixel_hashes = [] for i in range(4): m.next_image_set(i + 1) module.run(workspace) chashes = [] for channel in channels: pixel_data = m.get_image(channel).pixel_data h = hashlib.md5() h.update(pixel_data) chashes.append(h.digest()) self.assertNotEqual(chashes[0], chashes[1]) for j, ph in enumerate(pixel_hashes): for k, phh in enumerate(ph): for l, phd in enumerate(chashes): self.assertNotEqual(phh, phd) pixel_hashes.append(chashes) finally: os.remove(filename)
def test_04_03_load_planes(self): file_name = "RLM1 SSN3 300308 008015000.flex" maybe_download_tesst_image(file_name) path = testimages_directory() pathname = os.path.join(path, file_name) url = pathname2url(pathname) ftrs = (cpmeas.C_URL, cpmeas.C_SERIES, cpmeas.C_FRAME) channels = ("Channel1", "Channel2") header = ",".join([",".join(["_".join((ftr, channel)) for ftr in ftrs]) for channel in channels]) csv_lines = [header] for series in range(4): csv_lines.append(",".join(['"%s","%d","%d"' % (url, series, frame) for frame in range(2)])) csv_text = "\n".join(csv_lines) pipeline, module, filename = self.make_pipeline(csv_text) assert isinstance(module, L.LoadData) m = cpmeas.Measurements() image_set_list = cpi.ImageSetList() try: workspace = cpw.Workspace(pipeline, module, m, None, m, image_set_list) self.assertTrue(module.prepare_run(workspace)) pixel_hashes = [] for i in range(4): m.next_image_set(i+1) module.run(workspace) chashes = [] for channel in channels: pixel_data = m.get_image(channel).pixel_data h = hashlib.md5() h.update(pixel_data) chashes.append(h.digest()) self.assertNotEqual(chashes[0], chashes[1]) for j, ph in enumerate(pixel_hashes): for k, phh in enumerate(ph): for l, phd in enumerate(chashes): self.assertNotEqual(phh, phd) pixel_hashes.append(chashes) finally: os.remove(filename)