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

Transform the probe_ccf.trajectory_coords into the coordinates under res = 25um #22

Closed
PathwayinGithub opened this issue Mar 17, 2023 · 6 comments

Comments

@PathwayinGithub
Copy link

image

@petersaj
Copy link
Owner

Good catch if the issue is the 10um vs 25um resolution - if that's the case, I think it should work if you just re-scale the CCF coordinates by 1/2.5.

From the other thread you mentioned (#17), you could save the NPY file in matlab with an extra scaling operation:

% (First, load in your probe_ccf file)

% Pick filename to write coordinates into IBL format
filename = uiputfile('*.npy');

% Re-scale  coordinates from 10um (histology pipeline) to 25um (IBL pipeline) atlas resolution
trajectory_coordinates_25um = probe_ccf.trajectory_coords./2.5;

% Write probe_ccf coordinates as NPY file
writeNPY(trajectory_coordinates_25um ,filename)

Do you want to try that and let me know how it goes?

@PathwayinGithub
Copy link
Author

@petersaj
I tried again but failed.

The output xyz_picks.json data still be a little wired. see below:
image
If the output order is mlapdv in bregma coordinates, why are the dv positive and the ml and ap looks too large?

The xyz_picks.json in the sample data is:
image

When I use this obtained xyz_picks.json to run the gui, the error:
(base) C:\Users\Administrator>conda activate iblenv
(iblenv) C:\Users\Administrator>python C:\Users\Administrator\iblapps\atlaselectrophysiology\ephys_atlas_gui.py -o True
Traceback (most recent call last):
File "C:\Users\Administrator\iblapps\atlaselectrophysiology\ephys_atlas_gui.py", line 1263, in data_button_pressed
self.ephysalign = EphysAlignment(self.xyz_picks, self.chn_depths,
File "G:\ProgramFiles\Anaconda3\envs\iblenv\lib\site-packages\ibllib\pipes\ephys_alignment.py", line 22, in init
self.xyz_track, self.track_extent = self.get_insertion_track(xyz_picks, speedy=speedy)
File "G:\ProgramFiles\Anaconda3\envs\iblenv\lib\site-packages\ibllib\pipes\ephys_alignment.py", line 71, in get_insertion_track
exit = atlas.Insertion.get_brain_exit(traj_exit, self.brain_atlas)
File "G:\ProgramFiles\Anaconda3\envs\iblenv\lib\site-packages\ibllib\atlas\atlas.py", line 913, in get_brain_exit
return Insertion._get_surface_intersection(traj, brain_atlas, surface='bottom')
File "G:\ProgramFiles\Anaconda3\envs\iblenv\lib\site-packages\ibllib\atlas\atlas.py", line 896, in _get_surface_intersection
ma = np.argmin(z_val)
File "<array_function internals>", line 180, in argmin
File "G:\ProgramFiles\Anaconda3\envs\iblenv\lib\site-packages\numpy\core\fromnumeric.py", line 1312, in argmin
return _wrapfunc(a, 'argmin', axis=axis, out=out, **kwds)
File "G:\ProgramFiles\Anaconda3\envs\iblenv\lib\site-packages\numpy\core\fromnumeric.py", line 57, in _wrapfunc
return bound(*args, **kwds)
ValueError: attempt to get argmin of an empty sequence

@petersaj
Copy link
Owner

It looks like the ccf2xyz command is actually looking for microns in CCF space (see the comments in the second code block here: https://github.com/int-brain-lab/iblapps/wiki/4.-Preparing-data-for-ephys-GUI)

In that case, the line to scale the coordinates above would be:

% Convert 10um resolution CCF coordinates into um
trajectory_coordinates_um = probe_ccf.trajectory_coords.*10;

I'm not sure about the DV being positive - sometimes positive DV indicates downward, maybe that's the case in the IBL conventions?

@PathwayinGithub
Copy link
Author

Failed again, but thanks .... I have another question:what‘s the meaning of probe_ccf.trajectory_areas?

@PathwayinGithub
Copy link
Author

PathwayinGithub commented Mar 18, 2023

Hi,Andy. I finally succeeded. The problem was indeed the resolution and unit. I misunderstood your meaning and did ./2.5 *10, so I failed again 4h ago. When I just mutiply 10 to probe_ccf.trajectory_coords. and then transfer it into xyz_picks.json, the ibl application worked well (also see the #83 issue in the github page of iblapps int-brain-lab/iblapps#83). Thanks very much. @petersaj

@petersaj
Copy link
Owner

Great - for your other question, probe_ccf.trajectory_areas is the annotated volume value (the row index of the structure tree) for each corresponding coordinate in probe_ccf.trajectory_coords

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