Example #1
0
save_dir = bg_root_dir / f"allenbrain_atlas_{RES_UM}um"
save_dir.mkdir(exist_ok=True)

# Download annotated and template volume:
#########################################
spacecache = ReferenceSpaceCache(
    manifest=temp_path / "manifest.json",
    # downloaded files are stored relative to here
    resolution=RES_UM,
    reference_space_key="annotation/ccf_2017"
    # use the latest version of the CCF
)

# Download
annotated_volume, _ = spacecache.get_annotation_volume()
template_volume, _ = spacecache.get_template_volume()

# Save tiff stacks:
tifffile.imsave(str(save_dir / "reference.tiff"), template_volume)
tifffile.imsave(str(save_dir / "annotated.tiff"), annotated_volume)

# Download structures tree and meshes:
######################################
oapi = OntologiesApi()  # ontologies
struct_tree = spacecache.get_structure_tree()  # structures tree

# Find id of set of regions with mesh:
select_set = "Structures whose surfaces are represented by a precomputed mesh"

all_sets = pd.DataFrame(oapi.get_structure_sets())
mesh_set_id = all_sets[all_sets.description == select_set].id.values[0]
Example #2
0
import os
import numpy as np

import napari
from allensdk.core.reference_space_cache import ReferenceSpaceCache
from allensdk.core.mouse_connectivity_cache import MouseConnectivityCache

import neuro.atlas_viewer as atlas

# ------------------------- Mouse connectivity cache ------------------------- #
mcc = MouseConnectivityCache(manifest_file=os.path.join(atlas.mouse_connectivity_cache, "manifest.json"))
structure_tree = mcc.get_structure_tree()

# ------------------------- Download/Load atlas data ------------------------- #

spacecache = ReferenceSpaceCache(
	manifest=os.path.join(atlas.cache_dir, "manifest.json"),  # downloaded files are stored relative to here
	resolution=atlas.resolution,
	reference_space_key="annotation/ccf_2017"  # use the latest version of the CCF
	)
template = spacecache.get_template_volume()[0]
annotated_volume, _ = spacecache.get_annotation_volume()