This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import json | |
from allensdk.core.structure_tree import StructureTree | |
file_name = "C:/Users/davidf/Downloads/mouse-brain-ontology.json" | |
structures = json.load(open(file_name,'r')) | |
# workaround for a bug in StructureTree.clean_structures that I just found | |
for s in structures: | |
s['id'] = int(s['id']) | |
s['structure_sets'] = [] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from allensdk.core.mouse_connectivity_cache import MouseConnectivityCache | |
# pick from 10, 25, 50, 100 for resolution | |
mcc = MouseConnectivityCache(manifest_file='mcc/manifest.json', resolution=10) | |
# careful, these will get read into memory | |
av, _ = mcc.get_annotation_volume() | |
tv, _ = mcc.get_template_volume() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from allensdk.config import enable_console_log | |
from allensdk.api.queries.rma_api import RmaApi | |
from allensdk.api.queries.image_download_api import ImageDownloadApi | |
# print download messages to your console | |
enable_console_log() | |
# instantiate api classes for downloading metadata/images | |
image_api = ImageDownloadApi() | |
rma_api = RmaApi() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import csv | |
def hex_str_to_rgb(hex_str): | |
""" convert a hex string (e.g. "FFFFFF") to an RGB dictionary """ | |
val = int(hex_str, 16) | |
return { | |
'r': val & 0x0000ff, | |
'g': (val & 0x00ff00) >> 8, | |
'b': val >> 16 | |
} |
NewerOlder