This toolkit provides all code described in the paper SegEM: Efficient Image Analysis for High-Resolution connectomics. (Berning, Boergens & Helmstaedter, Neuron, 2015)
There are two main use cases:
- De-novo training of (or the use of the pretrained) CNNs for the analysis of a novel EM dataset
- Connectomic analysis of a volume-segmented data set based on skeleton reconstructions in retina dataset
The Matlab jobmanager has to be operational. If no compute cluster with a Matlab jobmanager is available, the jobmanager ‘local’ will usually work by default. Furthermore the Matlab-mex compiler has to be configured. This can be done done by typing:
at the Matlab command prompt. In case your system does not have a compiler installed please follow the instructions by Mathworks. This is required to compile some of the routines for the user’s computer. In case this does not work you can try to use the precompiled versions.
This code was tested on Matlab R2014b.
Set the Matlab working directory to the root folder of the SegEM repository.
Execute initalSettings.m and provide the requested information in the small GUI:
- Data Directory = Please mount the webdav directory as indicated in the Data Repository
- Name of jobmanager = Name of operational Matlab job manager (‘local’ in case no cluster is available)
- Output Directory = Directory to store data and figures generated by SegEM scripts
- Code version = for use case 1 choose SegEM for de-novo analyses; for use case 2 choose legacy version for analysis of retina dataset ek563
Press OK. Then, the relevant scripts will be opened in the Matlab editor.
Use case overview
The scripts are conveniently executed using the cell mode in Matlab (pressing Ctrl+Enter executes the current script section; see ‘cell mode’ help in Matlab). Inline comments explain what the code is doing in each cell.
For use case 1: start with cnnStart.m, then proceed to cnnParameterSelection.m, mainSeg.m, wholeDatsetFwdPass.m and skeletonsToContacts.m; these scripts will be opened in the matlab editor automatically for you.
For use case 2: start with skeletonsToContacts.m. When working with the retina dataset ek563, use legacy version skeletonsToContacts_legacy.m, instead.
Use Case 1
Brief description of the most relevant SegEM code files:
- cnnStart.m: load training data, train convolutional neuronal networks (parallel network training on multiple GPUs)
- cnnParameterSelection.m: Automated hyper-parameter selection and variation of learning rates for each CNN layer
- mainSeg.m: Contains steps from classification result by CNN to segmentation (grid parameter search for watershed segmentation) including skeleton based split-merger metrics
- (Optional) - visSeg.m: visualize a given segmentation, e.g. object collected along skeletons in dense skeletonization, movies of segmentation and similar
- wholeDatasetFwdPass.m: Apply trained CNN classifier (trained in step 1 or 2) and watershed segmentation steps (with parameters optimized in step 3) to whole dataset
- skeletonsToContacts.m: Volume reconstruction and contact detection based on skeleton reconstructions. This requires volume segmentation (either via step 4 or via the segmentations provided at www.segEM.io)
Use Case 2
To further analyze the retina dataset ek563, the following SegEM legacy code is provided:
- main_legacy.m: Load training data, train a convolutional neuronal network, parallel network training
- mainSeg_legacy.m: Contains steps from classification result by CNN to segmentation (grid parameter search for watershed segmentation) including skeleton based split-merger metrics
- visSeg_legacy.m: Visualize a given segmentation, e.g. object chains, segMovies, errorMovies = detected merger errors etc.
- skeletonsToContacts_legacy.m: Use segmentation of whole dataset (provided) and human skeleton reconstructions for volume reconstructions or contact detection between cell pairs