Main script for running all modules of the synapse tracking pipeline. The modular layout below means that individual components of the pipeline can be easily replaced/improved. Currently, this includes the following sequentially:
- Timeseries registration with ITK-Elastix package. Volumetric affine registration is first performed, followed by slice-by-slice registration. Alternative non-rigid registration methods are also available.
- XTC image restoration. Loads trained 3D U-Net model for image enhancement. Requires GPU for optimal speed. If the input volume is acquired at a different voxel resolution, the volume is automatically rescaled (interpolated) to the resolution of the training data.
- ilastik synapse detection model. Voxel-based classification to identify XTC enhanced synapses across all timepoints in the timeseries.
- NON-FUNCTIONAL in Code Capsule environment Matlab-based watershed segmentation. Separates adjoining synapses. Currently unavailable due to licensing issues of installing Matlab in Code capsule environment.
- ilastik synapse tracking model. Runs ilastik headless and assigns unique integer to each synapse that is tracked across all timepoints
- Blood vessel detection for masking possibly obstructed synapses. Uses thresholding and some morphological operations to generate a binary segmentation of dark space (blood vessels). This masks out synapses that are likely to be obstructed by blood vessels.
Expected input:
/data/"__demo_crop_2.tif"
*Single multipage-TIFF file (uint8) used to demo the image restoration and tracking pipeline.
Contains a small cropped volume from a longitudinal in vivo imaging experiment
visualizing SEP-GluA2 labelled synapses.
Output:
/results/"__quick_reference_output.png"
* a pyplot PNG figure that contains a quick view of a small subvolume
of the demo dataset to show how the data looks before/after restoration
and after synapse tracking.
/results/"___RESCALED_adj.tif"
* single multipage-TIFF (uint8) with entire timeseries that has been
registered and rescaled to match the resolution of the training data.
/results/"___XTC_processed.tif"
* single multipage-TIFF (uint8) after registeration and processing with XTC.
/results/"___Tracking-Result.tif"
* single multipage-TIFF (uint32) with segmentation of all synapses.
Each tracked synapse has a unique assigned value that is consistent
across all timepoints. For optimal visualization, we suggest loading
this file into ImageJ/FIJI (https://imagej.net/software/fiji/) and
selecting the "glasbey on dark" LUT followed by adjusting the contrast
histogram (Image>>Adjust>>Brightness/Contrast) to see the full spectrum
of tracked synapses.
/results/"__blood_vessel_mask.tiff"
* single multipage-TIFF (uint8) with mask of blood vessels that is
used in the analysis to remove obstructed synapses after tracking.
This project requires a couple of core dependencies. Currently this has only been tested on a Linux system.
-
First install Anaconda: https://www.anaconda.com/products/distribution
-
Then create virtual environment
conda create -n XTCSynEnv python=3.7 anaconda source activate XTCSynEnv ### use this command to activate the virtual enviornment
-
Install Python dependencies within virtual environment
pip install natsort itk-elastix pysimplegui csbdeep matplotlib scipy scikit-image pillow numpy natsort tifffile
-
First install tensorflow, check version needed for specific GPUs (https://www.tensorflow.org/install/gpu). pip install tensorflow==2.6.0
-
Then install dependencies to enable Tensorflow communication with GPU. Follow instructions here: https://www.tensorflow.org/install/gpu. Note: CUDA 11.2 and cuDNN 8.1 work for tensorflow 2.6.0.
-
To install MATLAB engine, first figure out where matlab is installed by entering "matlabroot" in the MATLAB cmd, then:
cd /usr/local/MATLAB/R2021a/extern/engines/python python setup.py install
- Download checkpoint file, demo data, and ILASTIK models here: https://livejohnshopkins-my.sharepoint.com/:f:/g/personal/yxu130_jh_edu/EnSmiQYFidVMlwfUNDvCWgQB3_mv-CeusZ3dkolZw71hwQ?e=xtWTH3
- Then copy/paste the entire folders into the XTC main directory
-
Run the main function:
python ./Synapse_detection_and_tracking_FULL_NM.py
-
Follow directions of GUI and select demo folder. Enter in voxel resolution and press continue.