# How to transform CCF (x, y, z) coordinates into stereotactic coordinates

**URL:** <https://community.brain-map.org/t/how-to-transform-ccf-x-y-z-coordinates-into-stereotactic-coordinates/1858>\
**Category:** Technical\
**Created:** [September 26, 2022, 2:10pm UTC](https://community.brain-map.org/t/how-to-transform-ccf-x-y-z-coordinates-into-stereotactic-coordinates/1858 "2022-09-26T14:10:34Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![GTMeijer](https://yyz1.discourse-cdn.com/flex027/user_avatar/community.brain-map.org/gtmeijer/32/687_2.png) [@GTMeijer](https://community.brain-map.org/u/GTMeijer)\
**Post date:** [September 26, 2022, 2:10pm UTC](https://community.brain-map.org/t/how-to-transform-ccf-x-y-z-coordinates-into-stereotactic-coordinates/1858/1 "2022-09-26T14:10:35Z")

</div>

The Common Coordinate Framework (CCF) is defined in a basic image coordinate system, using the top-left-rear pixel as its origin, and incrementing in the X, Y and Z axes up to the number of pixels in each dimension (ML, DV, AP respectively). **It was not designed as a targeting coordinate system.** Using some transformations the CCF can be roughly aligned to the stereotactic atlas, however, since it was not it’s intended purpose one should take caution when using the CCF for targeting, even after applying these transformations. In the image below the CCF space in 25 μm voxels is depicted.

![CCF](https://canada1.discourse-cdn.com/flex027/uploads/brainobservatory/original/1X/09ce7ad427df8fb4ecad3aee9e5390f0d2ac07b8.jpeg)

There are several transformations necessary to align the Allen brain atlas to the stereotactic framework: (1) there is an estimated 5 degree tilt in the sagittal plane and (2) the CCF is stretched in the DV direction, estimated at 94.3%. Note that the position of Bregma and the above mentioned transformation values are estimations.

**Step 1: center the CCF on Bregma**  
The coordinates of Bregma depend on the resolution of the CCF space you are using. For a 10 μm resolution Bregma is estimated at (x,y,z) (540, 44, 570). For 25 μm this would be: (216, 18, 228). We’ll use the 10 μm resolution in the example below:  
x = x - 540  
y = y - 44  
z = z - 570

**Step 2: Rotate the CCF**  
The CCF is rotated 5 degrees in the sagittal plane compared to the stereotactic atlas; the anterior part of the CCF is tilted in the ventral direction.  
X = x \* cos(0.0873) - y \* sin(0.0873)  
Y = x \* sin(0.0873) + y \* cos(0.0873)  
Note that 0.0873 is 5 degrees in radians.

**Step 3: squeeze the DV axis**  
Y = Y \* 0.9434

**Step 4: transform into micrometers**  
X,Y,Z = X,Y,Z / resolution

Disclaimers:

- The transformation values are estimates I obtained from work by the International Brain Laboratory and conversations with Andrew Peters, developer of the Neuropixel trajectory explorer ([GitHub - petersaj/neuropixels\_trajectory\_explorer: Neuropixels trajectory explorer with the Allen CCF mouse atlas](https://github.com/petersaj/neuropixels_trajectory_explorer)), these estimates have variance associated to them.
- This transformation is based on a C57Bl6 mouse brain and might not be accurate for other mouse strains.

---

<div class="post-metadata">

**Author:** ![lydian](https://yyz1.discourse-cdn.com/flex027/user_avatar/community.brain-map.org/lydian/32/174_2.png) [@lydian](https://community.brain-map.org/u/lydian)\
**Post date:** [September 26, 2022, 10:06pm UTC](https://community.brain-map.org/t/how-to-transform-ccf-x-y-z-coordinates-into-stereotactic-coordinates/1858/2 "2022-09-26T22:06:43Z")

</div>

Thank you @GTMeijer for your informative post!

---

<div class="post-metadata">

**Author:** ![NicoKiaru](https://yyz1.discourse-cdn.com/flex027/user_avatar/community.brain-map.org/nicokiaru/32/285_2.png) [@NicoKiaru](https://community.brain-map.org/u/NicoKiaru)\
**Post date:** [November 30, 2022, 3:22pm UTC](https://community.brain-map.org/t/how-to-transform-ccf-x-y-z-coordinates-into-stereotactic-coordinates/1858/3 "2022-11-30T15:22:30Z")

</div>

Thank you @GTMeijer for this very informative post and tweet ([https://twitter.com/guido\_meijer/status/1573296562574626823](https://twitter.com/guido_meijer/status/1573296562574626823))!

I’ve had a similar request in here: [Getting AP position (bregma coordinate) from ABBA to QuPath - Usage & Issues - Image.sc Forum](https://forum.image.sc/t/getting-ap-position-bregma-coordinate-from-abba-to-qupath/74500), and I’ll use your formula (warning included).

Just FYI, I’ve always found it weird, but according to the CCFv3 documentation, the axes of the CCFv3 is not like displayed on your image, but like this:

![image](https://canada1.discourse-cdn.com/flex027/uploads/brainobservatory/original/1X/b4aff026df089573e6a3464c323e511a6cc0c989.png)

Does this change something to your formula ? I think that (540, 44, 570) makes more sense with the image I’ve posted than yours. I’d be tempted to think that the formula is correct, but your image is wrong. Is there something I missed ?

Thanks,

Nicolas

EDIT: Can you write a few corresponding coordinates between both systems ? I just want to make sure that I did not correct the rotation angle the wrong way 😓

---

<div class="post-metadata">

**Author:** ![GTMeijer](https://yyz1.discourse-cdn.com/flex027/user_avatar/community.brain-map.org/gtmeijer/32/687_2.png) [@GTMeijer](https://community.brain-map.org/u/GTMeijer)\
**Post date:** [November 30, 2022, 4:32pm UTC](https://community.brain-map.org/t/how-to-transform-ccf-x-y-z-coordinates-into-stereotactic-coordinates/1858/4 "2022-11-30T16:32:42Z")

</div>

I’m also very confused by this. When you download the CCFv3 atlas and just plot it in 3D it’s clear that the origin is at the posterior-left hand corner (like in my figure) so I really don’t know why the CCFv3 documentation says otherwise. Maybe somebody from the Allen can chip in about this?

---

<div class="post-metadata">

**Author:** ![adamltyson](https://yyz1.discourse-cdn.com/flex027/user_avatar/community.brain-map.org/adamltyson/32/1711_2.png) [@adamltyson](https://community.brain-map.org/u/adamltyson)\
**Post date:** [November 30, 2022, 4:38pm UTC](https://community.brain-map.org/t/how-to-transform-ccf-x-y-z-coordinates-into-stereotactic-coordinates/1858/5 "2022-11-30T16:38:38Z")

</div>

I think the Allen docs are correct, it’s consistent with their data e.g. in the [3D viewer](https://connectivity.brain-map.org/3d-viewer).

@GTMeijer did you plot their image data (i.e. not the meshes) in 3D? It may be that the first plane of the image is at the back of the brain, but they define their coordinate system separately.

---

<div class="post-metadata">

**Author:** ![ndefrancesco](https://yyz1.discourse-cdn.com/flex027/user_avatar/community.brain-map.org/ndefrancesco/32/395_2.png) [@ndefrancesco](https://community.brain-map.org/u/ndefrancesco)\
**Post date:** [November 30, 2022, 5:40pm UTC](https://community.brain-map.org/t/how-to-transform-ccf-x-y-z-coordinates-into-stereotactic-coordinates/1858/6 "2022-11-30T17:40:43Z")

</div>

Hi! The orientation described in the Allen docs is also consistent with the average template and annotation volumes available [here](http://download.alleninstitute.org/informatics-archive/current-release/mouse_ccf/average_template/) and [here](http://download.alleninstitute.org/informatics-archive/current-release/mouse_ccf/annotation/ccf_2017/)

---

<div class="post-metadata">

**Author:** ![aaronbwong](https://yyz1.discourse-cdn.com/flex027/user_avatar/community.brain-map.org/aaronbwong/32/783_2.png) [@aaronbwong](https://community.brain-map.org/u/aaronbwong)\
**Post date:** [February 23, 2023, 1:41pm UTC](https://community.brain-map.org/t/how-to-transform-ccf-x-y-z-coordinates-into-stereotactic-coordinates/1858/7 "2023-02-23T13:41:14Z")

</div>

Thanks Guido for the informative post!  
I think all the confusion about coordinate system came from the fact that Guido was probably using the converted CCFv3 data from the UCL cortexlab, as described in the neuropixels\_trajectory\_explorer readme:

> Mouse: download the Allen CCF mouse atlas (all files at [http://data.cortexlab.net/allenCCF/](http://data.cortexlab.net/allenCCF/)) (note on where these files came from: they are a re-formatted version of the original atlas, which has been [processed with this script](https://github.com/cortex-lab/allenCCF/blob/master/setup_utils.m))

---

<div class="post-metadata">

**Author:** ![terrenceM](https://yyz1.discourse-cdn.com/flex027/user_avatar/community.brain-map.org/terrencem/32/2338_2.png) [@terrenceM](https://community.brain-map.org/u/terrenceM)\
**Post date:** [March 31, 2023, 11:34pm UTC](https://community.brain-map.org/t/how-to-transform-ccf-x-y-z-coordinates-into-stereotactic-coordinates/1858/8 "2023-03-31T23:34:20Z")

</div>

Hi @GTMeijer ,

Thankyou for this wonderful clarification. I was wondering if you could clarify one step further for us.

From what I understand, here you describe how to get from **an element in the annotated volume (AV)**, to a distance from bregma in microns. E.g. for your x coordinate in the 10um volume, skipping steps 2-3 …

X coord in microns = (X element in AV - 540) \* 10

However, the element in the annotated volume does not seem to be the same as in the **‘CCF Coordinate’** , at least in terms of how the latter is often defined; e.g. the CCF coordinates used in the ‘Spatial search’ in the mouse connectivity data here -

[http://connectivity.brain-map.org/?searchMode=spatial&sourceDomain=184&primaryStructureOnly=true&isi=false&targetCoordinates=12800,3050,7850&initImage=TWO\_PHOTON&experimentCoordinates=12800,3050,7850&experiment=286299886](http://connectivity.brain-map.org/?searchMode=spatial&sourceDomain=184&primaryStructureOnly=true&isi=false&targetCoordinates=12800,3050,7850&initImage=TWO_PHOTON&experimentCoordinates=12800,3050,7850&experiment=286299886)

To go from the CCF coordinate to a distance from bregma in microns, Takatoh et al., 2021 recommend us to do the following -

X coord in microns = (X coord in CCF - 5400) \* -1

So…

X element in AV \* 10 = X coord in CCF

Suggesting that the coord in the CCF is actually in terms of microns, rather in terms of elements in the annotated volume.

Is that right?

Thanks

---

<div class="post-metadata">

**Author:** ![GTMeijer](https://yyz1.discourse-cdn.com/flex027/user_avatar/community.brain-map.org/gtmeijer/32/687_2.png) [@GTMeijer](https://community.brain-map.org/u/GTMeijer)\
**Post date:** [April 4, 2023, 12:36pm UTC](https://community.brain-map.org/t/how-to-transform-ccf-x-y-z-coordinates-into-stereotactic-coordinates/1858/9 "2023-04-04T12:36:29Z")

</div>

Hi @terrenceM,

That’s correct. My original post describes how to transform the entire CCF atlas into stereotactic coordinates. When dealing with the full atlas, you have to pick a resolution because the atlas is voxel based. However, if you have a single coordinate you don’t use the voxels and perform the transform directly on the coordinates.

X coord in microns = (X coord in CCF - 5400) \* -1

Looks right to me but bear in mind that this is only step 1, you still have to correct for the tilt and squeeze (step 2 & 3).

---

<div class="post-metadata">

**Author:** ![akriebs](https://avatars.discourse-cdn.com/v4/letter/a/8491ac/32.png) [@akriebs](https://community.brain-map.org/u/akriebs)\
**Post date:** [August 8, 2024, 5:26pm UTC](https://community.brain-map.org/t/how-to-transform-ccf-x-y-z-coordinates-into-stereotactic-coordinates/1858/10 "2024-08-08T17:26:47Z")

</div>

> [@GTMeijer](#):
>
> X coord in microns = (X coord in CCF - 5400) \* -1

Hi @GTMeijer,  
I still seem to be missing a step somewhere. From the connectivity atlas, we find injection sites within the SSp-m (WT), and for each of these injections, we have CCF coordinates and Bregma coordinates, 3 of which I list below:  
InjectionID CCF Bregma  
180717881 [4620, 3340, 9380] 0.74, 3.3,1.63  
157654817 [4370, 3460, 9310] 1.1, 3.3,1.15  
112936582 [4470, 2700, 9140] 0.74, 3.25,0.75  
If I follow the suggestions of Takatoh et al., 2021 (i.e. AP in CCF = –1 × AP coordinates × 1000 + 5400; DV in CCF = DV coordinates × 1000; ML in CCF = ML coordinates × 1000 + 5700.)  
InjectionID Proposed CCF Bregma  
180717881 [4660, 3300, 7330] 0.74, 3.3,1.63  
157654817 [4300, 3300, 6850] 1.1, 3.3,1.15  
112936582 [4660, 3250, 6450] 0.74, 3.25,0.75  
I understand from your previous post that we need to accommodate for rotation and squeezing, i.e.  
X = x \* cos(0.0873) - y \* sin(0.0873)  
Y = x \* sin(0.0873) + y \* cos(0.0873)  
Y = Y \* 0.9434, which yields  
InjectionID Proposed CCF Bregma  
180717881 [4354, 3484, 7330] 0.74, 3.3,1.63  
157654817 [3996, 3455, 6850] 1.1, 3.3,1.15  
112936582 [4359, 3438, 6450] 0.74, 3.25,0.75  
Clearly, the proposed CCF does not match the actual CCF. I need to understand what I am doing wrong, because I aim to transform points from CCF to Bregma for which I have no Allen Institute provided ground truth. Can we only convert from CCF to Bregma, not Bregma to CCF? And, if so, what would the conversion from CCF to Bregma be, since the Z position is dramatically incorrect. Any advice you have would be tremendously appreciated.

---

<div class="post-metadata">

**Author:** ![GTMeijer](https://yyz1.discourse-cdn.com/flex027/user_avatar/community.brain-map.org/gtmeijer/32/687_2.png) [@GTMeijer](https://community.brain-map.org/u/GTMeijer)\
**Post date:** [August 9, 2024, 6:35am UTC](https://community.brain-map.org/t/how-to-transform-ccf-x-y-z-coordinates-into-stereotactic-coordinates/1858/11 "2024-08-09T06:35:18Z")

</div>

Hi @akriebs,  
Let me be clear: there is no ground truth conversion between CCF and Bregma coordinates. The CCF atlas is an atlas which was constructed from histological slices, therefore it is an imperfect reflection of how the brain is actually positioned and shaped in the skull of a live animal. How did you get the original CCF and Bregma coordinates that you listed at the top? How do you know that these are “correct”? One possibility is to inject at a Bregma coordinate, slice the brain, register it to the Allen CCF and then determine the CCF coordinate of where your injection ended up. However, you have to do this many times to get an accurate estimation of the Bregma-to-CCF conversion. This is because each mouse brain/skull is different and there is also targeting error when you use Bregma coordinates. The equations I provide above are based on an estimation. In the end the only thing you can do to know for sure that you are using the right coordinates is to do some pilot injections, slice the brain, register to CCF, and see if you were in the right place.

If you aim to do injections in SSp-m I can also recommend to use Pinpoint ([Pinpoint](https://data.virtualbrainlab.org/Pinpoint/)), when you click “Click to add new probe” you can choose injections pipettes. With this tool you can then position the pipette in your target area and it will provide you with the Bregma coordinates to hit that target. Pinpoint already does the transform for you.

---

<div class="post-metadata">

**Author:** ![adamltyson](https://yyz1.discourse-cdn.com/flex027/user_avatar/community.brain-map.org/adamltyson/32/1711_2.png) [@adamltyson](https://community.brain-map.org/u/adamltyson)\
**Post date:** [August 12, 2024, 10:54am UTC](https://community.brain-map.org/t/how-to-transform-ccf-x-y-z-coordinates-into-stereotactic-coordinates/1858/12 "2024-08-12T10:54:37Z")

</div>

To map the CCF to skull coordinates, [this publication](https://doi.org/10.1007/s12021-023-09623-9) may be of use.

---

<div class="post-metadata">

**Author:** ![SivanSchwartz](https://yyz1.discourse-cdn.com/flex027/user_avatar/community.brain-map.org/sivanschwartz/32/1039_2.png) [@SivanSchwartz](https://community.brain-map.org/u/SivanSchwartz)\
**Post date:** [November 28, 2024, 11:51am UTC](https://community.brain-map.org/t/how-to-transform-ccf-x-y-z-coordinates-into-stereotactic-coordinates/1858/13 "2024-11-28T11:51:53Z")

</div>

Do you have any instights of how to move from Ox, Oy, Oz, Vx, Vy, Vz, Ux, Uy, Uz into Bregama(mm) as presented in the quickNII, and vis-a-versa?

I am having hard time to understand how to transform from the output of the program back to Bregma (mm) and will appritiate any help.

Thanks  
Sivan

 ![image](https://canada1.discourse-cdn.com/flex027/uploads/brainobservatory/original/2X/d/d4b839a632f7f276f73f807183e3eeacb04076f2.png)

---

<div class="post-metadata">

**Author:** ![terrenceM](https://yyz1.discourse-cdn.com/flex027/user_avatar/community.brain-map.org/terrencem/32/2338_2.png) [@terrenceM](https://community.brain-map.org/u/terrenceM)\
**Post date:** [December 13, 2024, 11:46pm UTC](https://community.brain-map.org/t/how-to-transform-ccf-x-y-z-coordinates-into-stereotactic-coordinates/1858/14 "2024-12-13T23:46:42Z")

</div>

@GTMeijer I believe there is a typo in your rotation instructions. If xyz are ML, DV, AP respectively, then surely a rotation in the sagittal plane means adjusting the y and z coordinates, rather than the x and y?

> [@GTMeijer](#):
>
> X, Y and Z axes up to the number of pixels in each dimension (ML, DV, AP respectively)

> [@GTMeijer](#):
>
> **Step 2: Rotate the CCF**  
> The CCF is rotated 5 degrees in the sagittal plane compared to the stereotactic atlas; the anterior part of the CCF is tilted in the ventral direction.  
> X = x \* cos(0.0873) - y \* sin(0.0873)  
> Y = x \* sin(0.0873) + y \* cos(0.0873)  
> Note that 0.0873 is 5 degrees in radians.
