petersaj / AP_histology

Histology processing
60 stars 21 forks source link

integrate deepslice #14

Open chongtianyifa opened 2 years ago

chongtianyifa commented 2 years ago

Hi Andrew,

Sorry to bother you again. I am curious about whether it is possible to integrate the output of deepslice to initiate the atlas plane for the corresponding histology images in AP_grab_histology_ccf? I attached an example output from deepslice (https://www.deepslice.com.au/). results (1).zip

It saves the four edge points of each template slice in RAS coordinate system. I think I can convert them into Allen coordinates (a file with an example plane was attached, each column is the coordinate of an edge point in the standard Allen space). How can I use them to initialize the altas plane for corresponding histology images in the AP_grab_histology_ccf? points of edge in allen space.csv

Thanks advance for the help.

petersaj commented 2 years ago

I'll look into it - what order are your CCF coordinates in? Doesn't look like the native AP/DV/ML since the size is a little small:

image

chongtianyifa commented 2 years ago

Hi Andrew,

Thanks for the help. I think I successfully loaded the output of deepslice by transforming their four coordinates into CCF coordinates. Using these four coordinates, which determine the atlas slice plane, I got the norm and center of the plane for corresponding histology slice. Then I added these norms to gui_data (gui_data.Cam_Vector) as the camera view angle and center points to gui_data (gui_data.Cam_Target) as the camera target. In the 'update_histology_slice' function, two lines were added if no saved atlas position: view(gui_data.Cam_Vector(gui_data.curr_histology_slice,:)) % If there's no saved atlas position, loading atlas to plane found by deepslice gui_data.atlas_slice_point = gui_data.Cam_Target(gui_data.curr_histology_slice,:); Now the slice plane will switch to the plane found by deepslice.

petersaj commented 2 years ago

Great, sounds like it's working then? Does the deepslice alignment work well enough for you that you can essentially skip the step of manually finding the CCF slices?

If so, could you share the code you wrote to use it? Sounds like this is a modified version of AP_grab_histology_ccf, which loads/converts the deepslice output and initializes the CCF alignments for each slice?

chongtianyifa commented 2 years ago

It works for me now. I use the deepslice output to expedite the alignment, especially when individual slices were not continuously sectioned/imaged. For most cases, I still need to modify the angle and position a little.

Sure. I attached the modifed demo_histology_pipeline.m and AP_grab_histology_ccf.m and also a function to convert template plane in the xml file output from deepslice to allen CCF coordinate (xml2allenCam.m). Here is the modification: !!important: the order of images should be kept the same between deepslice output (a row for each image) and the .tiff images!! 1) set directory to use deepslice output (line 42-43 in demo_histology_pipeline) 2) initiate plane determined by deepslice (line 73-83 in AP_grab_histology_ccf) 3) update update_histology_slice function in AP_grab_histology_ccf AP_grab_histology_ccf.zip

petersaj commented 2 years ago

Thanks! The DeepSlice page is throwing errors for me (gave me one output on a test, but then started giving URL errors when I try to download subsequent alignments), I'll try it again another time