GithubHelp home page GithubHelp logo

ap_histology's Introduction

This pipeline aligns histology images to the Allen CCF.

Requires

This was made with inspiration from SHARP-Track by Philip Shamash (https://github.com/cortex-lab/allenCCF, https://www.biorxiv.org/content/10.1101/447995v1). It mostly serves the same goals, but has different interfaces (most notably in the histology/CCF matching step) and saves some extra information (like the full CCF coordinates for each CCF slice), which was easier to build new compared to modifying the old.

All functions are listed in the 'demo_histology_pipeline.m' file.

Histology preprocessing

AP_process_histology

AP_process_histology(im_path); % If size information in the OME-TIFF metadata, resize to CCF scale
AP_process_histology(im_path,resize_factor); % For user-specified resizing
  1. Downsample and white-balance slides

Colors will be automatically white-balanced, user indicates color of each channel

test image

  1. Extract slice images from slides

Select slices to extract and save:

  • slices will be automatically detected, left-clicking will select that slice
  • right-clicking will draw a manual region to extract
  • left-clicking on an existing selected region will unselect it
  • spacebar moves to the next slide. test image

AP_rotate_histology

AP_rotate_histology(slice_path);

Draw reference line (midline) to center and rotate slices. test image

Histology CCF alignment

AP_grab_histology_ccf

AP_grab_histology_ccf(tv,av,st,slice_path);

This function is to match histology slices to their corresponding CCF slices. The left plot is the histology slices (scrollable by 1/2), the right plot is the 3D CCF atlas which is rotatable with the arrow keys and scrollable in/out of the plane with the mouse wheel. Typical use would be:

  • Match the rotation of the histology slices with the rotation of the CCF using the arrow keys. This is usually easiest using a slice with landmarks sensitive to asymmetries, e.g. the hippocampus or anterior commisure.
  • Once the angle is set, the CCF slice location can be set with the scroll wheel. For each histology slice, scroll to the matching CCF slice and hit 'Enter' to set that slices' location.
  • Once all histology slices are set, hit 'Escape' to save and quit

test image

AP_auto_align_histology_ccf

AP_auto_align_histology_ccf(tv,av,st,slice_path);

This function auto-aligns each corresponding histology and CCF slice by slice outline only

test image

AP_manual_align_histology_ccf

AP_manual_align_histology_ccf(tv,av,st,slice_path);

If the auto-alignment didn't work on some slices, they can be manually fixed with this function. Placing > 3 corresponding points on the histology and CCF slices creates a new alignment using those control points, and 'Escape' saves and quits.

From auto-alignment: test image

After manual control-point alignment: test image

Aligned histology usage

After the above steps, each histology slice is associated with a CCF slice, a transform between slices, and the location in CCF space for each slice. Some current uses for this:

AP_view_aligned_histology

AP_view_aligned_histology(st,slice_path);

Display the histology slices with overlaid boundaries, hover over region to display name

AP_view_aligned_histology_volume

AP_view_aligned_histology_volume(tv,av,st,slice_path,1);

Threshold and display histology channel in 3D CCF space

test image

AP_get_probe_histology

AP_get_probe_histology(tv,av,st,slice_path);

Get trajectory of dyed probe in CCF coordinates and areas.

Enter the number of probes, draw lines on slices with visible tract marks corresponding to the probe (select the relevant probe by number, e.g. '1' to draw a line for probe 1), 'Escape' to save and quit

test image

This will draw a line of best fit through the points and extract all brain areas along that trajectory. NOTE: it is unusual that the exact end of the probe can be visualized and accurately established from histology alone, so this step saves the entire trajectory and the next step aligns it to electrophysiology. test image

AP_align_probe_histology

AP_align_probe_histology(st,slice_path,spike_times,spike_templates,template_depths);

This is a first-pass attempt at this function.

Match the trajectory of the probe through the CCF with electrophysiological signatures. This currently relies on kilosort-convention of variables: 'spike_times' n spikes x 1 vector of all spike times, 'spike_templates' n spikes x 1 vector of the templates corresponding to each spike time, and 'template_depths' n templates x 1 vector of the depth of each template.

This will plot the template depth vs spike rate (left), the multiunit correlation (center), and the CCF areas from the trajectory (right). Press (shift) up/down to scroll the CCF areas and match to electrophysiology landmarks. 'Escape' will save and quit.

The final useful output of this is a file/structure 'probe_ccf' which contains:

  • probe_ccf.trajectory_coords: the 3D CCF coordinates of the probe trajectory
  • probe_ccf.trajectory_areas: the annotated CCF areas for each point
  • probe_ccf.probe_depths: the relative depth of the probe to that point (e.g. 0 is the top of the probe and ~3840 is the end)

test image

ap_histology's People

Contributors

petersaj avatar ryaoki avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.