Skip to content

Slice pixel to CCF transformation depends on axes at initialization #38

@aaronbwong

Description

@aaronbwong

I am programmatically using abba-python to convert some coordinates in a slice image to Allen CCF coordinates. I noticed the output seems wrong, and realized it's a strange behavior of getSlicePixToCCFRealTransform() depending on how Abba is being initiated.
Looks like the x_axis of the .abba file was not taken into account. We have been aligning in ABBA with x_axis set to LR, instead of the default RL.

# try default opening
abba = Abba('Adult Mouse Brain - Allen Brain Atlas V3p1')
print(f"X_axis: {abba.x_axis}\nY_axis: {abba.y_axis}\nZ_axis: {abba.z_axis}")
abba_axis_1 = abba.x_axis

The output is

X_axis: RL
Y_axis: SI
Z_axis: AP

abba.state_load(abba_file) # full absolute path needed
print(f"X_axis: {abba.x_axis}\nY_axis: {abba.y_axis}\nZ_axis: {abba.z_axis}")
abba_axis_2 = abba.x_axis

The output is

X_axis: RL
Y_axis: SI
Z_axis: AP

# repeat with x_axis='LR'
abba = Abba('Adult Mouse Brain - Allen Brain Atlas V3p1',x_axis='LR')
print(f"X_axis: {abba.x_axis}\nY_axis: {abba.y_axis}\nZ_axis: {abba.z_axis}")
abba_axis_3 = abba.x_axis

The output is

X_axis: LR
Y_axis: SI
Z_axis: AP

abba.state_load(abba_file) # full absolute path needed
print(f"X_axis: {abba.x_axis}\nY_axis: {abba.y_axis}\nZ_axis: {abba.z_axis}")
abba_axis_4 = abba.x_axis

The output is

X_axis: LR
Y_axis: SI
Z_axis: AP

I tried transforming in both cases with coordInImage [100,100,0].

mp = abba.mp
transform_pix_to_atlas = mp.getSlices().get(0).getSlicePixToCCFRealTransform()
transform_pix_to_atlas.inverse().apply(coordInImage, coordInCCF)
print(f"coordInImage: {coordInImage}\ncoordInCCF: {coordInCCF}")

Here are the results. First run:

coordInImage: [100.0, 100.0, 0.0]
coordInCCF: [7.353574035872652, -0.5013995496068988, -0.1447920757930703]
Second run:

coordInImage: [100.0, 100.0, 0.0]
coordInCCF2: [9.882429330755478, -0.5013995496068988, 11.544792075793072]

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions