ShuTu was one of the two ways initially experimented for the BioImage 2019 brightfield challenge. This notebook demonstrates how to use ShuTu to generate SWC files, running on Colab. This notebook essentially recreates the SWC generating part of the ShuTu tutorial, on Colab.
This notebook uses ShuTu's sample data; it does not use Allen Institute data. This just proves that ShuTu can run on Colab.
ShuTu documentation
- ShuTu home page, essentially a well-done short tutorial
- ShuTu pre-print overview on biorxiv, & the PDF
- ShuTu on Github, licensed GPL
ShuTu is two tools in one
ShuTu has two separately usable components.
- ShuTu SWC generator is a CLI tool, which makes SWC files.
- ShuTu SWC editor is a cross-platform GUI desktop application.
The SWC generator can be deployed on Colab. The SWC editor cannot; the editor is desktop application, not a Jupyter component.
%%shell
# Get the Linux distro of ShuTu (took less than a minute to DL)
wget https://psu.box.com/shared/static/wszpq3r6hwgoxo8eq0vb1k82fwrabycl.zip
unzip wszpq3r6hwgoxo8eq0vb1k82fwrabycl.zip # creates ShuTuUbuntu directory
#set -m # needed to avoid error: bash: no job control in this shell
cd ShuTuUbuntu
##########
# This next part is from build.sh.
#
#export PATH=$downloadDir/local/bin:$PATH
cd mylib
make
cd ..
make
Install test data from ShuTu tutorial
The real goal is to use ShuTu on the BioImage challenge dataset from The Allen. But a good sanity checker is to use the granule cell example data from the ShuTu tutorial, as described in section, "Image processing and automated reconstruction", quoting:
Download the image files from Granule Cell 63X Start. Unzip in the home directory, which should create a directory granuleCell63XStart.
Specifically, the link behind "Granule Cell 63X Start" is: https://psu.box.com/shared/static/f4gs13fs0y9ckrjjo78oid7hkv61k2wq.zip
It takes about a minute to download the 1.3G granule cell sample data.
# This is a 1.3GB image stack for use in skeletonization (make a SWC file).
# Downloads in less than 2 minutes
!wget https://psu.box.com/shared/static/f4gs13fs0y9ckrjjo78oid7hkv61k2wq.zip
!unzip f4gs13fs0y9ckrjjo78oid7hkv61k2wq.zip
Seems there are 520 *.tif files in the sample data set.
!ls /content/granuleCell63XStart/slides/*.tif | wc -l
%%shell
cd ShuTuUbuntu
mpirun --allow-run-as-root -n 1 ./createTiffStacksZeiss /content/granuleCell63XStart/ granule
mpirun --allow-run-as-root -n 1 processImages /content/granuleCell63XStart/
mpirun --allow-run-as-root -n 1 ./stitchTiles /content/granuleCell63XStart/
mpirun --allow-run-as-root -n 1 ./ShuTuAutoTrace /content/granuleCell63XStart/ ShuTu.Parameters.granule63XTest.dat # creates *.swc file
The above cell should eventually end in:
Creating swc file...
Deleting small branches of length 1...Deleting connections to the deleted points...Deleting points...Deleted 125 points. npoints=3064
Deleting small branches of length 2...Deleting connections to the deleted points...Deleting points...Deleted 36 points. npoints=3028
Deleting small branches of length 3...Deleting connections to the deleted points...Deleting points...Deleted 21 points. npoints=3007
Deleting small branches of length 4...Deleting connections to the deleted points...Deleting points...Deleted 22 points. npoints=2985
Deleting small branches of length 5...Deleting connections to the deleted points...Deleting points...Deleted 11 points. npoints=2974
Removing connected points if the total length is smaller than 20.000000 micron...Deleted 223 noisy points.
Delete isolated branches with length smaller than 20.000000 and leaf branch smaller than 5
Saving SWC to /content/granuleCell63XStart/granule-.auto.swc
There 48 segments 4 trees
!pwd
!ls -l
!echo ------------
!ls /content/granuleCell63XStart/granule*
# Optionally, download that newly created SWC before it gets thrown away after a max of 12 hours.
from google.colab import files
files.download('/content/granuleCell63XStart/granule-.auto.swc')