Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

testing and fixing outdated atlas generation scripts #249

Merged
merged 8 commits into from
Mar 1, 2024
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,11 @@
import numpy as np
import pandas as pd
from rich.progress import track

######## I had to manually install this
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be added to the dependencies in pyproject.toml then, I think,

from skimage import io

########
from brainglobe_atlasapi import utils
from brainglobe_atlasapi.atlas_generation.mesh_utils import (
Region,
Expand Down Expand Up @@ -226,9 +229,7 @@ def create_atlas(
if isinstance(working_dir, str):
working_dir = Path(working_dir)
# Generated atlas path:
working_dir = (
working_dir / "brainglobe_workingdir" / 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"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
import treelib
import urllib3
from allensdk.core.structure_tree import StructureTree

### I had to install manually
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again, worth adding to the dependencies. If it is very big or hard-to-install, it can be an optional dependency like allensdk.

from brainio import brainio
from rich.progress import track

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"]))

Expand Down
4 changes: 2 additions & 2 deletions brainglobe_atlasapi/atlas_generation/mesh_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,10 +158,10 @@ def extract_mesh_from_mask(
mesh = mesh.extractLargestRegion()

# decimate
mesh.decimate(decimate_fraction, method="pro")
mesh.decimate_pro(decimate_fraction)

if smooth:
mesh.smoothLaplacian()
mesh.smooth()

if obj_filepath is not None:
write(mesh, str(obj_filepath))
Expand Down
3 changes: 3 additions & 0 deletions brainglobe_atlasapi/atlas_generation/volume_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@

import os

######## I had to manually install this
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should depend on brainglobe-utils.imageio instead (see brainglobe/brainglobe-utils#33 for details), which may need to be added to the dependencies.

import imio

########
import numpy as np


Expand Down
Loading