# SVG download API help

**URL:** <https://community.brain-map.org/t/svg-download-api-help/1292>\
**Category:** Technical\
**Created:** [September 25, 2021, 7:03pm UTC](https://community.brain-map.org/t/svg-download-api-help/1292 "2021-09-25T19:03:49Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![cornhundred](https://yyz1.discourse-cdn.com/flex027/user_avatar/community.brain-map.org/cornhundred/32/394_2.png) [@cornhundred](https://community.brain-map.org/u/cornhundred)\
**Post date:** [September 25, 2021, 7:03pm UTC](https://community.brain-map.org/t/svg-download-api-help/1292/1 "2021-09-25T19:03:49Z")

</div>

Hi,

I’m trying to figure out how to download the reference SVG outlines from the brain atlas. We have an example working on [Observable HQ](https://observablehq.com/@cornhundred/allen-brain-atlas-svg-test)

 ![Screenshot_20210925-145633](https://canada1.discourse-cdn.com/flex027/uploads/brainobservatory/original/1X/d57da14a70905eca3487fe88001339474104ca46.jpeg)

But I’m not sure how to download a different slice. I would like to download slice 90 (see below)

 ![Screenshot_20210925-145819](https://canada1.discourse-cdn.com/flex027/uploads/brainobservatory/original/1X/1e8fb04566353e39b577809a53ae51cbdf27bb00.jpeg)

to approximate the slice of spatial transcriptomics data we have made available on our Vizgen deck.gl Visualizer  
[Applications - Vizgen](https://vizgen.com/applications/#visual) (see below screenshot)

 ![Screenshot_20210925-145256](https://canada1.discourse-cdn.com/flex027/uploads/brainobservatory/original/1X/455deea24f5c76fde898044a1db1b6344b098516.jpeg)

Also, if anyone knows how we might go about warping the brain atlas to our sample we’d be interested in that as well.

My question might be similar to this one: [How do I download reference atlas images? - #5 by nileg](https://community.brain-map.org/t/how-do-i-download-reference-atlas-images/94/5)

Best,  
Nick

---

<div class="post-metadata">

**Author:** ![gouwens](https://avatars.discourse-cdn.com/v4/letter/g/bcef8e/32.png) [@gouwens](https://community.brain-map.org/u/gouwens)\
**Post date:** [October 13, 2021, 7:41pm UTC](https://community.brain-map.org/t/svg-download-api-help/1292/2 "2021-10-13T19:41:39Z")

</div>

The information about downloading specific images and SVGs is found [on this documentation page](https://help.brain-map.org/display/api/Atlas+Drawings+and+Ontologies).

First, you need to decide what atlas you are using. The screenshot of slice 90 in your post looked like the most recent “Adult Mouse, 3D Coronal” atlas, but I believe your example on the SVG test page is from the older “Mouse, P56, Coronal” atlas.

You can query the API for all the slices (in XML format) used for the reference atlas with something like the following. I’ve based it on the example shown on the linked documentation page, but changed the atlas id to match the “Adult Mouse, 3D Coronal” atlas (id = 602630314).

```nohighlight
http://api.brain-map.org/api/v2/data/query.xml?criteria=model::AtlasImage,
rma::criteria,
[annotated$eqtrue],
atlas_data_set(atlases[id$eq602630314]),
alternate_images[image_type$eq'Atlas+-+Adult+Mouse'],
rma::options[order$eq'sub_images.section_number'][num_rows$eqall]

```

The query returns the images ordered by the section number, which puts them in the same order as the atlas. You can verify that you have the same number of `atlas-image` entries in your query response as are in the reference atlas (132 images).

So, if you want to get the SVG for image 90 out of 132 in the reference atlas, you would go to the 90th `atlas-image` returned by the query and find its `id` attribute. Alternatively, you could specify that you want only the 90th row of the query by modifying like so:

```nohighlight
http://api.brain-map.org/api/v2/data/query.xml?criteria=model::AtlasImage,
rma::criteria,
[annotated$eqtrue],
atlas_data_set(atlases[id$eq602630314]),
alternate_images[image_type$eq'Atlas+-+Adult+Mouse'],
rma::options[order$eq'sub_images.section_number'][num_rows$eq1][start_row$eq89]

```

(Note that we set the `start_row` option to 89, not 90, because rows are numbered starting from 0 by the API).

This particular atlas image has an ID of 576986811.

You can then get that SVG using a query similar to your test example, just using this ID instead:

```nohighlight
http://api.brain-map.org/api/v2/svg_download/576986811?groups=28

```

Hope that helps!
