petersaj / AP_histology

Histology processing
64 stars 22 forks source link

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

Closed PathwayinGithub closed 1 year ago

PathwayinGithub commented 1 year ago

image

petersaj commented 1 year ago

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 (https://github.com/petersaj/AP_histology/issues/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 commented 1 year ago

@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 commented 1 year ago

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 commented 1 year ago

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

PathwayinGithub commented 1 year ago

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 https://github.com/int-brain-lab/iblapps/issues/83). Thanks very much. @petersaj

petersaj commented 1 year ago

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