From c31da8a299e3c794ac73f7f2004ce175b47ba66b Mon Sep 17 00:00:00 2001 From: Adam Tyson Date: Thu, 16 May 2024 16:46:10 +0100 Subject: [PATCH] load data from pooch explicitly by path --- examples/user_volumetric_data.py | 20 +++++++++----------- tests/test_integration.py | 22 +++++++++++----------- 2 files changed, 20 insertions(+), 22 deletions(-) diff --git a/examples/user_volumetric_data.py b/examples/user_volumetric_data.py index c52d101b..ca0c2a7d 100644 --- a/examples/user_volumetric_data.py +++ b/examples/user_volumetric_data.py @@ -28,23 +28,21 @@ print(f"[{orange}]Running example: {Path(__file__).name}") +download_path = Path.home() / ".brainglobe" / "brainrender" / "example-data" +filename = "T_AVG_s356tTg.tif" +scene = Scene(atlas_name="mpin_zfish_1um") -retrieved_paths = pooch.retrieve( +# for some reason the list of returned by pooch does not seem to be +# in the same order every time +_ = pooch.retrieve( url="https://api.mapzebrain.org/media/Lines/brn3cGFP/average_data/T_AVG_s356tTg.zip", known_hash="54b59146ba08b4d7eea64456bcd67741db4b5395235290044545263f61453a61", - path=Path.home() - / ".brainglobe" - / "brainrender" - / "example-data", # zip will be downloaded here + path=download_path, progressbar=True, - processor=pooch.Unzip( - extract_dir="" - # path to unzipped dir, - # *relative* to the path set in 'path' - ), + processor=pooch.Unzip(extract_dir="."), ) -datafile = Path(retrieved_paths[0]) # [0] is zip file +datafile = download_path / filename # 1. load the data diff --git a/tests/test_integration.py b/tests/test_integration.py index 9f692e48..36a30328 100644 --- a/tests/test_integration.py +++ b/tests/test_integration.py @@ -302,23 +302,23 @@ def test_slice(scene): def test_user_volumetric_data(): + download_path = ( + Path.home() / ".brainglobe" / "brainrender" / "example-data" + ) + filename = "T_AVG_s356tTg.tif" scene = Scene(atlas_name="mpin_zfish_1um") - retrieved_paths = pooch.retrieve( + + # for some reason the list of returned by pooch does not seem to be + # in the same order every time + _ = pooch.retrieve( url="https://api.mapzebrain.org/media/Lines/brn3cGFP/average_data/T_AVG_s356tTg.zip", known_hash="54b59146ba08b4d7eea64456bcd67741db4b5395235290044545263f61453a61", - path=Path.home() - / ".brainglobe" - / "brainrender" - / "example-data", # zip will be downloaded here + path=download_path, progressbar=True, - processor=pooch.Unzip( - extract_dir="" - # path to unzipped dir, - # *relative* to the path set in 'path' - ), + processor=pooch.Unzip(extract_dir="."), ) - datafile = Path(retrieved_paths[0]) + datafile = download_path / filename data = load_any(datafile) source_space = AnatomicalSpace("ira") target_space = scene.atlas.space