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

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.


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



Thank you @GTMeijer for your informative post!