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

fixing kim dev atlases #304

Merged
merged 12 commits into from
Jun 3, 2024
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
__version__ = "1"
__version__ = "2"

Check warning on line 1 in brainglobe_atlasapi/atlas_generation/atlas_scripts/kim_developmental_ccf_mouse.py

View check run for this annotation

Codecov / codecov/patch

brainglobe_atlasapi/atlas_generation/atlas_scripts/kim_developmental_ccf_mouse.py#L1

Added line #L1 was not covered by tests

import json
import multiprocessing as mp
import time
import zipfile
from pathlib import Path

import imio
import numpy as np
import pandas as pd
from brainglobe_utils.image_io import load_nii

Check warning on line 11 in brainglobe_atlasapi/atlas_generation/atlas_scripts/kim_developmental_ccf_mouse.py

View check run for this annotation

Codecov / codecov/patch

brainglobe_atlasapi/atlas_generation/atlas_scripts/kim_developmental_ccf_mouse.py#L11

Added line #L11 was not covered by tests
from rich.progress import track
from scipy.ndimage import zoom

Expand All @@ -20,7 +20,7 @@
from brainglobe_atlasapi.atlas_generation.wrapup import wrapup_atlas_from_data
from brainglobe_atlasapi.structure_tree_util import get_structures_tree

PARALLEL = True # disable parallel mesh extraction for easier debugging
PARALLEL = False # disable parallel mesh extraction for easier debugging

Check warning on line 23 in brainglobe_atlasapi/atlas_generation/atlas_scripts/kim_developmental_ccf_mouse.py

View check run for this annotation

Codecov / codecov/patch

brainglobe_atlasapi/atlas_generation/atlas_scripts/kim_developmental_ccf_mouse.py#L23

Added line #L23 was not covered by tests


def clean_up_df_entries(df):
Expand Down Expand Up @@ -118,8 +118,8 @@
# Load (and possibly downsample) annotated volume:
scaling = ANNOTATIONS_RES_UM / resolution

annotated_volume = imio.load_nii(annotations_file, as_array=True)
template_volume = imio.load_nii(template_file, as_array=True)
annotated_volume = load_nii(annotations_file, as_array=True)
template_volume = load_nii(template_file, as_array=True)

Check warning on line 122 in brainglobe_atlasapi/atlas_generation/atlas_scripts/kim_developmental_ccf_mouse.py

View check run for this annotation

Codecov / codecov/patch

brainglobe_atlasapi/atlas_generation/atlas_scripts/kim_developmental_ccf_mouse.py#L121-L122

Added lines #L121 - L122 were not covered by tests

annotated_volume = zoom(
annotated_volume, (scaling, scaling, scaling), order=0, prefilter=False
Expand Down Expand Up @@ -175,9 +175,7 @@

tree = get_structures_tree(structures)

rotated_annotations = np.rot90(annotated_volume, axes=(0, 2))

labels = np.unique(rotated_annotations).astype(np.int32)
labels = np.unique(annotated_volume).astype(np.int32)

Check warning on line 178 in brainglobe_atlasapi/atlas_generation/atlas_scripts/kim_developmental_ccf_mouse.py

View check run for this annotation

Codecov / codecov/patch

brainglobe_atlasapi/atlas_generation/atlas_scripts/kim_developmental_ccf_mouse.py#L178

Added line #L178 was not covered by tests
for key, node in tree.nodes.items():
if key in labels:
is_label = True
Expand All @@ -195,7 +193,6 @@

if PARALLEL:
pool = mp.Pool(mp.cpu_count() - 2)

try:
pool.map(
create_region_mesh,
Expand All @@ -205,7 +202,7 @@
node,
tree,
labels,
rotated_annotations,
annotated_volume,
ROOT_ID,
closing_n_iters,
decimate_fraction,
Expand All @@ -229,7 +226,7 @@
node,
tree,
labels,
rotated_annotations,
annotated_volume,
ROOT_ID,
closing_n_iters,
decimate_fraction,
Expand Down
Loading