From 27c035a1303031308d401faa826a31e0eeb1b7a3 Mon Sep 17 00:00:00 2001 From: Viktor Plattner Date: Tue, 27 Feb 2024 13:04:28 +0000 Subject: [PATCH 1/8] first commit, quick fixes of old syntax to try running it on the HPC --- .../atlas_generation/atlas_scripts/admba_3d_dev_mouse.py | 5 ++++- brainglobe_atlasapi/atlas_generation/mesh_utils.py | 2 +- brainglobe_atlasapi/atlas_generation/volume_utils.py | 2 ++ 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/brainglobe_atlasapi/atlas_generation/atlas_scripts/admba_3d_dev_mouse.py b/brainglobe_atlasapi/atlas_generation/atlas_scripts/admba_3d_dev_mouse.py index de923763..498bbb69 100644 --- a/brainglobe_atlasapi/atlas_generation/atlas_scripts/admba_3d_dev_mouse.py +++ b/brainglobe_atlasapi/atlas_generation/atlas_scripts/admba_3d_dev_mouse.py @@ -12,7 +12,10 @@ import numpy as np import pandas as pd from rich.progress import track + +######## I had to manually install this from skimage import io +######## from brainglobe_atlasapi import utils from brainglobe_atlasapi.atlas_generation.mesh_utils import ( @@ -227,7 +230,7 @@ def create_atlas( working_dir = Path(working_dir) # Generated atlas path: working_dir = ( - working_dir / "brainglobe_workingdir" / atlas_config.atlas_name + working_dir / "admba_3d_dev_mouse" / atlas_config.atlas_name ) working_dir.mkdir(exist_ok=True, parents=True) diff --git a/brainglobe_atlasapi/atlas_generation/mesh_utils.py b/brainglobe_atlasapi/atlas_generation/mesh_utils.py index 3f5fc3dd..2e47535f 100644 --- a/brainglobe_atlasapi/atlas_generation/mesh_utils.py +++ b/brainglobe_atlasapi/atlas_generation/mesh_utils.py @@ -158,7 +158,7 @@ def extract_mesh_from_mask( mesh = mesh.extractLargestRegion() # decimate - mesh.decimate(decimate_fraction, method="pro") + mesh.decimate_pro(decimate_fraction) if smooth: mesh.smoothLaplacian() diff --git a/brainglobe_atlasapi/atlas_generation/volume_utils.py b/brainglobe_atlasapi/atlas_generation/volume_utils.py index af4904ad..252f0073 100644 --- a/brainglobe_atlasapi/atlas_generation/volume_utils.py +++ b/brainglobe_atlasapi/atlas_generation/volume_utils.py @@ -14,7 +14,9 @@ import os +######## I had to manually install this import imio +######## import numpy as np From 0c1584a300cf48e9dad7f2bb5bc16aa91ce84427 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 27 Feb 2024 14:42:17 +0000 Subject: [PATCH 2/8] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- .../atlas_generation/atlas_scripts/admba_3d_dev_mouse.py | 6 ++---- brainglobe_atlasapi/atlas_generation/volume_utils.py | 1 + 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/brainglobe_atlasapi/atlas_generation/atlas_scripts/admba_3d_dev_mouse.py b/brainglobe_atlasapi/atlas_generation/atlas_scripts/admba_3d_dev_mouse.py index 498bbb69..f0b9730a 100644 --- a/brainglobe_atlasapi/atlas_generation/atlas_scripts/admba_3d_dev_mouse.py +++ b/brainglobe_atlasapi/atlas_generation/atlas_scripts/admba_3d_dev_mouse.py @@ -15,8 +15,8 @@ ######## I had to manually install this from skimage import io -######## +######## from brainglobe_atlasapi import utils from brainglobe_atlasapi.atlas_generation.mesh_utils import ( Region, @@ -229,9 +229,7 @@ def create_atlas( if isinstance(working_dir, str): working_dir = Path(working_dir) # Generated atlas path: - working_dir = ( - working_dir / "admba_3d_dev_mouse" / atlas_config.atlas_name - ) + working_dir = working_dir / "admba_3d_dev_mouse" / atlas_config.atlas_name working_dir.mkdir(exist_ok=True, parents=True) download_dir_path = working_dir / "downloads" diff --git a/brainglobe_atlasapi/atlas_generation/volume_utils.py b/brainglobe_atlasapi/atlas_generation/volume_utils.py index 252f0073..498f964c 100644 --- a/brainglobe_atlasapi/atlas_generation/volume_utils.py +++ b/brainglobe_atlasapi/atlas_generation/volume_utils.py @@ -16,6 +16,7 @@ ######## I had to manually install this import imio + ######## import numpy as np From a3e6dcdea14733f3212feade7dfc1fbc93d0692e Mon Sep 17 00:00:00 2001 From: Viktor Plattner Date: Tue, 27 Feb 2024 16:18:31 +0000 Subject: [PATCH 3/8] humanatlas.py: from brainio import brainio has to be installed manually --- .../atlas_generation/atlas_scripts/humanatlas.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/brainglobe_atlasapi/atlas_generation/atlas_scripts/humanatlas.py b/brainglobe_atlasapi/atlas_generation/atlas_scripts/humanatlas.py index a575bfa3..aa8d87a2 100644 --- a/brainglobe_atlasapi/atlas_generation/atlas_scripts/humanatlas.py +++ b/brainglobe_atlasapi/atlas_generation/atlas_scripts/humanatlas.py @@ -8,6 +8,8 @@ import treelib import urllib3 from allensdk.core.structure_tree import StructureTree + +### I had to install manually from brainio import brainio from rich.progress import track From a8f4631a285eb6c9d024a09f24a59e1fe7998065 Mon Sep 17 00:00:00 2001 From: Viktor Plattner Date: Wed, 28 Feb 2024 13:31:21 +0000 Subject: [PATCH 4/8] fixing azba_zfish issue: replace smoothLaplacian with smooth in mesh_utils.py --- brainglobe_atlasapi/atlas_generation/mesh_utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/brainglobe_atlasapi/atlas_generation/mesh_utils.py b/brainglobe_atlasapi/atlas_generation/mesh_utils.py index 2e47535f..c4b7c2e9 100644 --- a/brainglobe_atlasapi/atlas_generation/mesh_utils.py +++ b/brainglobe_atlasapi/atlas_generation/mesh_utils.py @@ -161,7 +161,7 @@ def extract_mesh_from_mask( mesh.decimate_pro(decimate_fraction) if smooth: - mesh.smoothLaplacian() + mesh.smooth() if obj_filepath is not None: write(mesh, str(obj_filepath)) From 58495b621cef355aae4225ac2799859586febe5e Mon Sep 17 00:00:00 2001 From: Viktor Plattner Date: Thu, 29 Feb 2024 12:32:47 +0000 Subject: [PATCH 5/8] fixing kim_developmental_ccf_mouse.py issue: pandas syntax and df handling --- .../atlas_scripts/kim_developmental_ccf_mouse.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/brainglobe_atlasapi/atlas_generation/atlas_scripts/kim_developmental_ccf_mouse.py b/brainglobe_atlasapi/atlas_generation/atlas_scripts/kim_developmental_ccf_mouse.py index a02067cf..d70827e3 100644 --- a/brainglobe_atlasapi/atlas_generation/atlas_scripts/kim_developmental_ccf_mouse.py +++ b/brainglobe_atlasapi/atlas_generation/atlas_scripts/kim_developmental_ccf_mouse.py @@ -133,8 +133,10 @@ def create_atlas( df = pd.read_csv(structures_file) clean_up_df_entries(df) - df.loc[len(df)] = ["root", ROOT_ID, "root", ROOT_ID] - df.append(["root", ROOT_ID, "root", ROOT_ID]) + new_row = pd.DataFrame( + [["root", ROOT_ID, "root", ROOT_ID]], columns=df.columns + ) + df = pd.concat([df, new_row], ignore_index=True) id_dict = dict(zip(df["ID"], df["Parent ID"])) From 5d4f4b0f484089222b3896d34eb1b3a7f63ff863 Mon Sep 17 00:00:00 2001 From: Viktor Plattner Date: Thu, 29 Feb 2024 13:46:06 +0000 Subject: [PATCH 6/8] fixing allen_cord.py: updating source URL --- .../atlas_generation/atlas_scripts/allen_cord.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/brainglobe_atlasapi/atlas_generation/atlas_scripts/allen_cord.py b/brainglobe_atlasapi/atlas_generation/atlas_scripts/allen_cord.py index a2c80ea9..5e3e8c40 100644 --- a/brainglobe_atlasapi/atlas_generation/atlas_scripts/allen_cord.py +++ b/brainglobe_atlasapi/atlas_generation/atlas_scripts/allen_cord.py @@ -221,10 +221,7 @@ def create_atlas(working_dir): ORIENTATION = "asr" RESOLUTION = (20, 10, 10) ROOT_ID = 250 - ATLAS_FILE_URL = ( - "https://md-datasets-cache-zipfiles-prod.s3.eu-west-1." - "amazonaws.com/4rrggzv5d5-1.zip" - ) + ATLAS_FILE_URL = "https://prod-dcd-datasets-cache-zipfiles.s3.eu-west-1.amazonaws.com/4rrggzv5d5-1.zip" ATLAS_PACKAGER = "MetaCell LLC, Ltd." download_dir_path = working_dir / "downloads" From a69bf7306f2bc13671c040289f3aabdd9d46351b Mon Sep 17 00:00:00 2001 From: Viktor Plattner Date: Fri, 1 Mar 2024 13:50:58 +0000 Subject: [PATCH 7/8] adding packages to dependencies --- .../atlas_generation/atlas_scripts/admba_3d_dev_mouse.py | 2 -- .../atlas_generation/atlas_scripts/humanatlas.py | 2 -- brainglobe_atlasapi/atlas_generation/volume_utils.py | 4 ++-- pyproject.toml | 4 ++++ 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/brainglobe_atlasapi/atlas_generation/atlas_scripts/admba_3d_dev_mouse.py b/brainglobe_atlasapi/atlas_generation/atlas_scripts/admba_3d_dev_mouse.py index f0b9730a..33e0fa82 100644 --- a/brainglobe_atlasapi/atlas_generation/atlas_scripts/admba_3d_dev_mouse.py +++ b/brainglobe_atlasapi/atlas_generation/atlas_scripts/admba_3d_dev_mouse.py @@ -12,8 +12,6 @@ import numpy as np import pandas as pd from rich.progress import track - -######## I had to manually install this from skimage import io ######## diff --git a/brainglobe_atlasapi/atlas_generation/atlas_scripts/humanatlas.py b/brainglobe_atlasapi/atlas_generation/atlas_scripts/humanatlas.py index aa8d87a2..a575bfa3 100644 --- a/brainglobe_atlasapi/atlas_generation/atlas_scripts/humanatlas.py +++ b/brainglobe_atlasapi/atlas_generation/atlas_scripts/humanatlas.py @@ -8,8 +8,6 @@ import treelib import urllib3 from allensdk.core.structure_tree import StructureTree - -### I had to install manually from brainio import brainio from rich.progress import track diff --git a/brainglobe_atlasapi/atlas_generation/volume_utils.py b/brainglobe_atlasapi/atlas_generation/volume_utils.py index 498f964c..1e9bc57c 100644 --- a/brainglobe_atlasapi/atlas_generation/volume_utils.py +++ b/brainglobe_atlasapi/atlas_generation/volume_utils.py @@ -15,7 +15,7 @@ import os ######## I had to manually install this -import imio +import brainglobe_utils.image_io as image_io ######## import numpy as np @@ -88,7 +88,7 @@ def load_labelled_volume(data, vmin=0, alpha=1, **kwargs): raise FileNotFoundError(f"Volume data file {data} not found") try: - data = imio.load_any(data) + data = image_io.load_any(data) except Exception as e: raise ValueError( f"Could not load volume data from file: {data} - {e}" diff --git a/pyproject.toml b/pyproject.toml index f1974efd..74d10179 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -37,6 +37,10 @@ dependencies = [ "treelib", "vedo", "xmltodict", + "scikit-image", + "brainio", + "brainglobe-utils", + ] dynamic = ["version"] From 4ab0f5e540a0b208f5fa6df2e90eaeca52758ff8 Mon Sep 17 00:00:00 2001 From: Viktor Plattner Date: Fri, 1 Mar 2024 15:27:15 +0000 Subject: [PATCH 8/8] removing unnecessary comments --- .../atlas_generation/atlas_scripts/admba_3d_dev_mouse.py | 1 - brainglobe_atlasapi/atlas_generation/volume_utils.py | 3 --- 2 files changed, 4 deletions(-) diff --git a/brainglobe_atlasapi/atlas_generation/atlas_scripts/admba_3d_dev_mouse.py b/brainglobe_atlasapi/atlas_generation/atlas_scripts/admba_3d_dev_mouse.py index 33e0fa82..4974c149 100644 --- a/brainglobe_atlasapi/atlas_generation/atlas_scripts/admba_3d_dev_mouse.py +++ b/brainglobe_atlasapi/atlas_generation/atlas_scripts/admba_3d_dev_mouse.py @@ -14,7 +14,6 @@ from rich.progress import track from skimage import io -######## from brainglobe_atlasapi import utils from brainglobe_atlasapi.atlas_generation.mesh_utils import ( Region, diff --git a/brainglobe_atlasapi/atlas_generation/volume_utils.py b/brainglobe_atlasapi/atlas_generation/volume_utils.py index 1e9bc57c..3ca40085 100644 --- a/brainglobe_atlasapi/atlas_generation/volume_utils.py +++ b/brainglobe_atlasapi/atlas_generation/volume_utils.py @@ -14,10 +14,7 @@ import os -######## I had to manually install this import brainglobe_utils.image_io as image_io - -######## import numpy as np