erturklab / delivr_cfos

End-to-end light-sheet image analysis for mouse brains, with DL training data generated in VR
https://www.discotechnologies.org/DELiVR/
MIT License
27 stars 3 forks source link

DELiVR: A VR enabled, deep learning based cFos inference pipeline

DELIVR overview

Overview of the complete DELIVR protocol. This repository covers all the neccessary steps for inference.

Table of contents

Requirements

Python requirements

Python 3.8 on Linux for downsampling, masking, upsampling

Python 3.8 on Linux for inference

Python 3.8 on Windows for Atlas Alignment

Python 3.8 on Linux for Visualization

ILastik requirements

We recommend the latest beta version from the official website. We used 1.4.0b8.

TeraConverter requirements

We recommend the latest portable version from the offical website. We used 1.11.10.

File requirements

We assume that the files are a series of 16-bit TIFF files, one per z-plane. Our model is optimized for data acquired with approx. 1.62 x 1.62 x 6 µm (x/y/z/) voxel size.

Setup and execution

  1. Clone this repository using git clone https://github.com/erturklab/deliver_cfos.git
  2. Install the requirements using pip install -r requirements.txt (pip) conda install --file requirements.txt (anaconda)
  3. Set the location of your raw data and ilastik installation path in config.json
  4. Download and install mBrainAligner (Note that the pre-compiled swc registration only runs on Windows). Set the path in the config.json under mBrainAligner location
  5. Download and install Ilastik (latest beta). Set the path in the config.json under ilastik_location.
  6. (Optional: Download the test raw data from this dropbox link (50 Gb total) and extract the tiff files into /data/raw/)
  7. (If required, download the intermediate results and move them to into /data/)
  8. Run python __main__.py in the terminal

Expected installation time: ca 1h for local python install, ca 10 min if using the docker.

Config.json parameters

Pipeline overview

Pipeline overview

Overview of the DELIVR computational pipeline. Individual steps are explained below.

For a demo, please see Supplementary Video 5: https://www.discotechnologies.org/DELiVR/Supplementary_Video_5_DELiVR_Demo.mp4

Downsampling, Masking, Upsampling

Pseudocode:

Artifact Masking
load stack as stack
stack = downsample(stack)
foreach image in stack:
    image = randomForest_model(image)
    upscale(image)
save(stack)

Deep Learning inference

Pseudocode:

load stack as stack
load deepLearning_model as model
sliding_window_inferrer = Sliding_Window_Inferrer(model)
result = sliding_window_inferrer(stack)
save(result)

Atlas alignment

Here we convert the downsampled stack from tiff to Vaa3d's V3DRAW format. For this, use the most recent version of Vaa3d.

This step also requires mBrainAligner The pre-compiled swc registration only runs on Windows.

Pseudocode:

load downsampled_stack.V3DRAW as stack
preprocessed_cell_coordinates = preprocess_connected_component_output (cc_output)
transfomation_file = mBrainAligner_create_alignment (stack)
mBrainAligner_swc_transformation(preprocessed_cell_coordinates, transformation_file)

Region Assignment

DELiVR uses the Allen Brain Atlas CCF3 adult mouse brain atlas, as provided by the Scalable Brain Atlas This step loads the atlas-aligned cell coordinates, assigns a region (and parent region, atlas color, etc) to each of them. It also produces a per-area summary table (cells/ region) and a 3D heatmap in atlas space.

Pseudocode:

for brain in brains:
    cell_region_table = assign_regions_to_each_cell(brain)
    region_overview_table = summarize_cell_counts_per_region(cell_region_table)
    create_indivisual_brain_heatmap(brain)

summarize_overview_table(all_overview_tables)
summarize_heatmaps(all_heatmaps)

Visualization

This step requires BrainRender

Pseudocode:

load mBrainAligner_transformed_file as coords
filter coords (size max=104)
BrainRender.render(coords)