diff --git a/brainglobe_stitch/image_mosaic.py b/brainglobe_stitch/image_mosaic.py index 75b30fe..1a2a56d 100644 --- a/brainglobe_stitch/image_mosaic.py +++ b/brainglobe_stitch/image_mosaic.py @@ -93,6 +93,10 @@ def __init__(self, directory: Path): self.tiles[0].resolution_pyramid ) + def __del__(self): + if self.h5_file is not None: + self.h5_file.close() + def load_mesospim_directory(self) -> None: """ Load the mesoSPIM directory and its data into the ImageMosaic. diff --git a/tests/test_unit/test_image_mosaic.py b/tests/test_unit/test_image_mosaic.py index fe83f2c..9dc1016 100644 --- a/tests/test_unit/test_image_mosaic.py +++ b/tests/test_unit/test_image_mosaic.py @@ -10,7 +10,9 @@ def image_mosaic(naive_bdv_directory): os.remove(naive_bdv_directory / "test_data_bdv_tile_config.txt") image_mosaic = ImageMosaic(naive_bdv_directory) - return image_mosaic + yield image_mosaic + + del image_mosaic def test_image_mosaic_init(image_mosaic, naive_bdv_directory): @@ -24,3 +26,16 @@ def test_image_mosaic_init(image_mosaic, naive_bdv_directory): image_mosaic.h5_path == naive_bdv_directory / "test_data_original_bdv.h5" ) + assert ( + image_mosaic.meta_path + == naive_bdv_directory / "test_data_bdv.h5_meta.txt" + ) + assert image_mosaic.h5_file is not None + assert len(image_mosaic.channel_names) == 2 + assert len(image_mosaic.tiles) == 8 + assert len(image_mosaic.tile_names) == 8 + assert image_mosaic.x_y_resolution == 4.08 + assert image_mosaic.z_resolution == 5.0 + assert image_mosaic.num_channels == 2 + assert len(image_mosaic.intensity_adjusted) == 5 + assert len(image_mosaic.overlaps_interpolated) == 5