Esempio n. 1
0
    def __init__(self):
        SvgApi.__init__(
            self
        )  # https://github.com/AllenInstitute/AllenSDK/blob/master/allensdk/api/queries/svg_api.py
        ImageDownloadApi.__init__(
            self
        )  # https://github.com/AllenInstitute/AllenSDK/blob/master/allensdk/api/queries/image_download_api.py
        self.annsetsapi = AnnotatedSectionDataSetsApi(
        )  # https://github.com/AllenInstitute/AllenSDK/blob/master/allensdk/api/queries/annotated_section_data_sets_api.py
        self.oapi = OntologiesApi(
        )  # https://github.com/AllenInstitute/AllenSDK/blob/master/allensdk/api/queries/ontologies_api.py

        # Get metadata about atlases
        self.atlases = pd.DataFrame(self.oapi.get_atlases_table())
        self.atlases_names = sorted(list(self.atlases['name'].values))

        self.mouse_coronal_atlas_id = int(self.atlases.loc[
            self.atlases['name'] == "Mouse, P56, Coronal"].id.values[0])
        self.mouse_sagittal_atlas_id = int(self.atlases.loc[
            self.atlases['name'] == "Mouse, P56, Sagittal"].id.values[0])
        self.mouse_3D_atlas_id = int(self.atlases.loc[
            self.atlases['name'] == "Mouse, Adult, 3D Coronal"].id.values[0])

        # Get metadata about products
        if connected_to_internet():
            self.products = pd.DataFrame(
                send_query(
                    "http://api.brain-map.org/api/v2/data/query.json?criteria=model::Product"
                ))
            self.mouse_brain_reference_product_id = 12
            self.mouse_brain_ish_data_product_id = 1
            self.products_names = sorted(list(self.products["name"].values))
            self.mouse_products_names = sorted(
                list(self.products.loc[self.products.species == "Mouse"]
                     ["name"].values))
        else:
            raise ConnectionError(
                "It seems that you are not connected to the internet, you won't be able to download stuff."
            )
Esempio n. 2
0
    def __init__(self):
        SvgApi.__init__(
            self
        )  # https://github.com/AllenInstitute/AllenSDK/blob/master/allensdk/api/queries/svg_api.py
        ImageDownloadApi.__init__(
            self
        )  # https://github.com/AllenInstitute/AllenSDK/blob/master/allensdk/api/queries/image_download_api.py
        self.annsetsapi = (
            AnnotatedSectionDataSetsApi()
        )  # https://github.com/AllenInstitute/AllenSDK/blob/master/allensdk/api/queries/annotated_section_data_sets_api.py
        self.oapi = (
            OntologiesApi()
        )  # https://github.com/AllenInstitute/AllenSDK/blob/master/allensdk/api/queries/ontologies_api.py

        # Get metadata about atlases
        self.atlases = pd.DataFrame(self.oapi.get_atlases_table())
        self.atlases_names = sorted(list(self.atlases["name"].values))

        self.mouse_coronal_atlas_id = int(self.atlases.loc[
            self.atlases["name"] == self.mouse_coronal].id.values[0])
        self.mouse_sagittal_atlas_id = int(self.atlases.loc[
            self.atlases["name"] == self.mouse_sagittal].id.values[0])
        self.mouse_3D_atlas_id = int(self.atlases.loc[
            self.atlases["name"] == self.mouse3d].id.values[0])

        # Get metadata about products
        self.products = pd.DataFrame(
            send_query(
                "http://api.brain-map.org/api/v2/data/query.json?criteria=model::Product"
            ))
        self.mouse_brain_reference_product_id = 12
        self.mouse_brain_ish_data_product_id = 1
        self.products_names = sorted(list(self.products["name"].values))
        self.mouse_products_names = sorted(
            list(self.products.loc[self.products.species == "Mouse"]
                 ["name"].values))
Esempio n. 3
0
    
def verify_svg(file_path, width_scale, height_scale):
    # we're using this function to display scaled svg in the rendered notebook.
    # we suggest that in your own work you use a tool such as inkscape or illustrator to view svg
    
    with open(file_path, 'rb') as svg_file:
        svg = svg_file.read()
    encoded_svg = b64encode(svg)
    decoded_svg = encoded_svg.decode('ascii')
    
    st = r'<img class="figure" src="data:image/svg+xml;base64,{}" width={}% height={}%></img>'.format(decoded_svg, width_scale, height_scale)
    display(HTML(st))


image_api = ImageDownloadApi()
svg_api = SvgApi()


#Downloading all of the images from a section data set

section_data_set_id = 71724696
downsample = 4
expression = 1

section_image_directory = str(section_data_set_id) + '_section_images'
format_str = '.jpg'

section_images = image_api.section_image_query(section_data_set_id)
section_image_ids = [si['id'] for si in section_images]

print(len(section_image_ids))
Esempio n. 4
0
def svg():
    sa = SvgApi()
    return sa