Skip to content

Latest commit

 

History

History

segmentation

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 

Training and running our baseline for segmentation.

Install dependencies

pip install -r requirements.txt

SQLite3

You may get an error like below:

In file included from src/blob.c:1:0:
src/blob.h:4:10: fatal error: sqlite3.h: No such file or directory
#include "sqlite3.h"
        ^~~~~~~~~~~
compilation terminated.
error: command '/usr/bin/x86_64-linux-gnu-gcc' failed with exit code 1
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
ERROR: Failed building wheel for pysqlite3

To resolve this, in Ubuntu first install: sudo apt-get install libsqlite3-dev, then rerun pip install -r requirements.txt

Training

First, see network/ for directions on preparing the dataset for training. Finish training then come back here to use this model for segmentation.

Using our baseline pre-trained model

We're providing our pre-trained model which achieves a validation ERL+Rand XPRESS score of 0.75424 and test score of TBD. Download it here. To use this model, simply download it to networks/reference_setup/ and continue the following segmentation steps.

Run segmentation

We'll use segway, a package as developed in Nguyen et al to run the segmentation pipeline. The pipeline utilizes Daisy to run tasks in small blocks in parallel, and chain tasks together in one single command.

Predict affs

To run affs on the validation dataset, first run inference using GPU device 0:

CUDA_VISIBLE_DEVICES=0 python segway/tasks/segmentation/task_01_predict.py configs/segment_validation_reference.json

segment_validation_reference.json assumes the reference model is trained in networks/ at least to 320,000 iterations. To run the affs model on train and test sets, see the other configs in configs/.

Note that for the validation volume, we segment only the inner 23um^3 while for the test volume we segment 33um^3 because these are the ROIs of the ground-truth skeletons.

Using pre-computed affs of the baseline model

To help participants who may only want to work on optimizing watershed+agglomeration, we provide the following affs outputs from the baseline for:

Please note that since the checkpoint used is optimized by the final segmentation score and not the intrinsic quality of the affs, these outputs are not necessarily optimal for other watershed+agglomeration parameters/methods.

To use these provided affs, download the .h5 file and use the convert_to_zarr_h5.py script to convert and place it in the output folder. For example:

python3 convert_to_zarr_h5.py baseline_affs_validation.h5 volumes/affs outputs/validation/setup03/320000/output.zarr volumes/affs

Run watershed and agglomeration

Then the rest of the pipeline:

python segway/tasks/segmentation/task_06a_extract_segments.py configs/segment_validation_reference.json

The output for this config will be in outputs/validation/reference/320000/output.zarr.

Example segmentation from the baseline

Here we are providing the segmentation of the baseline model at 0.55 agglomeration threshold (the threshold that had the highest XPRESS score):

Conversion example:

python3 convert_to_zarr_h5.py baseline_seg_validation.h5 volumes/segmentation_0.550 outputs/validation/setup03/320000/output.zarr volumes/segmentation_0.550

Visualize

Here we use the neuroglancer in the data/ folder to check the resulting affs and segmentation outputs.

../data/neuroglancer --file ../xpress-challenge.zarr --datasets volumes/validation_raw --file outputs/validation/reference/320000/output.zarr --datasets volumes/affs volumes/segmentation_0.550