Image registration package for python
The goal of this image processing pipeline is to be able to efficiently process 3D light-sheet images of mouse brains with a set of cell bodies lit up via fluorescent tags from FisTRAP mice and immunohistochemically based.
- preprocesing and quality control (destriping)
- stitching data for atlas alignment (terastitcher e.g. reference: https://github.com/abria/TeraStitcher/wiki/Demo-and-batch-scripts)
- terastitcher --import --volin=/data/channel --volin_plugin="TiledXY|3Dseries" --imin_plugin="tiff3D" --imout_plugin="tiff3D" --ref1=1 --ref2=2 --ref3=3 --vxl1=1 --vxl2=1 --vxl3=1 --projout=xml_import
- terastitcher --displcompute --projin="/data/channel/xml_import.xml"
- terastitcher --displproj --projin="/data/channel/xml_displcomp.xml"
- terastitcher --displthres --projin="/data/chanel/xml_displproj.xml" --projout="/data/channel/xml_displthres.xml" --threshold=0.7
- terastitcher --placetiles --projin="data/channel/xml_displthres.xml" --projout="/data/channel/xml_placetiles.xml" --algorithm=MIPNCC
- terastitcher --merge --projin="data/channel/xml_placetiles.xml" --volout="/data/channel" --imout_depth=16 --resolutions=012345
- registering to a standard mouse atlas The Allen CCF v3 or Enhanced and Unified Anatomical Labeling for a Common Mouse Brain Atlas
- visualization (Vaa3d, Imaris, Arivis 4D, and FuJI)
- segmenation and cell counting U-Net: deep learning for cell counting, detection, and morphometry
Mounting the shared server as a normal drive on a linux machine. This line needs to be added the /etc/fstab
file
sudo nano /etc/fstab
Then paste this line at the end
//quetzalcoatl.local/workspace/ /media/gray/quetzspace cifs user=gray,pass=lablab,file_mode=0777,dir_mode=0777,noperm 0 0
Read and write speed test for linux ssd, quetzalcoatl server, and window raid storage. Test was performed with this code:
import os
import timeit
data = dict()
def read_all(path):
data.clear()
for root, dirs, files in os.walk(path):
for f in files:
with open(os.path.join(root,f), "rb") as fh:
data[(root.replace(path,''),f)] = fh.read()
def write(path):
for (root,f),content in data.items():
# print(path,root)
os.makedirs(os.path.join(path,root),exist_ok=True)
with open(os.path.join(path,root,f), 'wb') as fh:
fh.write(content)
print(timeit.timeit(setup="from __main__ import read_all", stmt="read_all('/home/gray/Desktop/LOC00001/')",number=1))
print(timeit.timeit(setup="from __main__ import read_all", stmt="read_all('/media/gray/quetzspace/Yu Lab Brain Data/Raw Data/deconvolution_input/VW0/CHN00/LOC00001/')",number=1))
print(timeit.timeit(setup="from __main__ import read_all", stmt="read_all('/raid/docker_data/LOC00001/')",number=1))
print(timeit.timeit(setup="from __main__ import write", stmt="write('/home/gray/Desktop/LOC00001-copy/')",number=1))
print(timeit.timeit(setup="from __main__ import write", stmt="write('/media/gray/quetzspace/Yu Lab Brain Data/Raw Data/deconvolution_input/VW0/CHN00/LOC00001-copy')",number=1))
print(timeit.timeit(setup="from __main__ import write", stmt="write('/raid/docker_data/LOC00001-copy')",number=1))
Results of two runs
RUN 1
~read~
ssd - 3.722733586007962
server - 9.70251502499741
raid - 3.9086415830097394
~write~
ssd - 4.040428158012219
server - 12.09031660000619
raid - 46.34526721299335
RUN 2
~read~
ssd - 3.83814213599544
server - 9.04114085699257
raid - 3.9069085770024685
~write~
ssd - 4.039209708003909
server - 11.972381725994637
raid - 47.36286968400236
-
Download elastix from Github elastix repo.
wget https://github.com/SuperElastix/elastix/releases/download/5.0.1/elastix-5.0.1-linux.tar.bz2
-
Extract and move the desigired location.
tar -xvf /elastix-5.0.1-linux.tar.bz2 sudo mv elastix-5.0.1-linux /usr/bin/
-
Add the following to .bashrc file
export PATH=/usr/bin/elastix-5.0.1-linux/bin:$PATH export LD_LIBRARY_PATH=/usr/bin/elastix-5.0.1-linux/lib:$LD_LIBRARY_PATH
-
In a terminal window, test as follows.
elastix --help
elastix version: 5.0.1
elastix registers a moving image to a fixed image. The registration-process is specified in the parameter file. --help, -h displays this message and exit --version output version information and exit --extended-version output extended version information and exit
Call elastix from the command line with mandatory arguments: -f fixed image -m moving image -out output directory -p parameter file, elastix handles 1 or more "-p"
Optional extra commands: -fMask mask for fixed image -mMask mask for moving image -t0 parameter file for initial transform -priority set the process priority to high, abovenormal, normal (default), belownormal, or idle (Windows only option) -threads set the maximum number of threads of elastix
The parameter-file must contain all the information necessary for elastix to run properly. That includes which metric to use, which optimizer, which transform, etc. It must also contain information specific for the metric, optimizer, transform, etc. For a usable parameter-file, see the website.
Need further help? Check the website http://elastix.isi.uu.nl, or mail [email protected].