def test_manual_addition_of_ImageCollection_to_DataManager(self): # We start off by creating a :class:`jicbioimage.core.io.DataManager`. # This takes a backend argument. The backend provides a means to store # unpacked image files. from jicbioimage.core.io import DataManager, FileBackend backend = FileBackend(directory=TMP_DIR) data_manager = DataManager(backend=backend) # The :func:`jicbioimage.core.image.DataManager.conver` function is be # default an instance of the callable # :class:`jicbioimage.core.io.BFConvertWrapper` class. from jicbioimage.core.io import BFConvertWrapper, _md5_hexdigest_from_file self.assertTrue(isinstance(data_manager.convert, BFConvertWrapper)) # We also need to import an ImageCollection from jicbioimage.core.image import ImageCollection # If the input file has not already been converted with do so. fpath = os.path.join(DATA_DIR, 'z-series.ome.tif') self.assertFalse(data_manager.convert.already_converted(fpath)) if not data_manager.convert.already_converted(fpath): path_to_manifest = data_manager.convert(fpath) # unpacks and creates manifests self.assertEqual(path_to_manifest, os.path.join(TMP_DIR, _md5_hexdigest_from_file(fpath), 'manifest.json')) image_collection = ImageCollection() image_collection.parse_manifest(path_to_manifest) self.assertEqual(len(image_collection), 5) data_manager.append(image_collection) self.assertEqual(len(data_manager), 1) self.assertTrue(data_manager.convert.already_converted(fpath))
def get_microscopy_collection_from_tiff(input_file): """Return microscopy collection from tiff file.""" data_manager, backend_dir = get_data_manager() data_manager.load(input_file) md5_hex = _md5_hexdigest_from_file(input_file) manifest_path = os.path.join(backend_dir, md5_hex, "manifest.json") microscopy_collection = MicroscopyCollection() microscopy_collection.parse_manifest(manifest_path) return microscopy_collection
def test_md5_from_file_with_smaller_blocksize(self): from jicbioimage.core.io import _md5_hexdigest_from_file input_file = os.path.join(DATA_DIR, "tjelvar.png") self.assertEqual(_md5_hexdigest_from_file(input_file, 4096), "894c9860e11667d29cdbf034e58ee75f")