Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Output probe insertion coordinates from xyz tracks? #116

Open
jshaker6 opened this issue Mar 27, 2024 · 1 comment
Open

Output probe insertion coordinates from xyz tracks? #116

jshaker6 opened this issue Mar 27, 2024 · 1 comment

Comments

@jshaker6
Copy link

I was wondering whether it's possible to get the coordinates of a probe insertion from the xyz_tracks inputted into the ephys atlas GUI - essentially this would be the angles of the line that is fit to the tracked points in the slice plot and the xy coordinates of the insertion point from that line.

Thank you for the super helpful tool!

@mayofaulkner
Copy link
Contributor

Hello,

Yes that is possible, you can get it out in the following way

import json
from pathlib import Path
import numpy as np
from iblatlas.atlas import Insertion, AllenAtlas
output_path = Path(r'/Users/admin/Downloads/data')
with open(Path(output_path, 'xyz_picks.json'), "r") as f:
    xyz_picks = np.array(json.load(f)['xyz_picks']) / 1e6

ba = AllenAtlas()
ins = Insertion.from_track(xyz_picks, ba)

tip = ins.tip  # coordinate of tip of xyz_picks (relative to bregma)
entry = ins.entry  # coordinate of entry on surface of brain of xyz_picks (relative to bregma)
depth = ins.depth  # depth of xyz_picks relative to surface
theta = ins.theta  # phi angle of xyz_pixks
phi = ins.phi  # theta angle of xyz_pixks

# Display the insertion that has been fitted to the xyz_picks
import matplotlib.pyplot as plt
ax = ba.plot_tilted_slice(ins.xyz, 1, volume='annotation')
ax.plot(ins.xyz[:, 0] * 1e6, ins.xyz[:, 2] * 1e6, 'r')
plt.show()

Let me know if that helps. Our convention of theta and phi are explained here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants