tiffsplit formats the TIF with the image data first (after an 8-byte header), followed by the full "header" meta-information. "unu make" is used to extract the raw data and stitch the images into a 3-D volume.mkdir dorDiI; (cd dorDiI; tiffsplit ../picMt1DX40DiI.tif) mkdir dorDiO; (cd dorDiO; tiffsplit ../picMt1DX40DiO.tif) mkdir latDiI; (cd latDiI; tiffsplit ../picMt1LX40DiI.tif) mkdir latDiO; (cd latDiO; tiffsplit ../picMt1LX40DiO.tif)
This tells unu that all the images are 512 by 512 pixels, pixels are unsigned short (16-bit) values, and the endianness is little, and we should skip 8 bytes in each image. Each dataset is written as two files: a detached header (".nhdr) which can be read or modified in any text editor, and a gzip-compressed raw data file (".raw.gz"). Gzip is an open-source lossless compression method, which in this case compressed the data by a factor of about 10. Once in NRRD format, the individual constituent TIF slices are erased.foreach data ( dorDiI dorDiO latDiI latDiO ) echo ${data} unu make -i ${data}/x??.tif -s 512 512 `echo ${data}/x??.tif | wc -w` \ -t ushort -e raw -en little -bs 8 \ | unu save -f nrrd -e gzip -o ${data}.nhdr rm -rf ${data} end
foreach data ( dorDiI dorDiO latDiI latDiO ) echo ${data} unu project -i ${data}.nhdr -a 2 -m max \ | unu quantize -b 8 -o ${data}-zmax.png end unu 2op x 0 ${data}-zmax.png -o black.png unu join -i dorDiI-zmax.png dorDiO-zmax.png black.png \ -a 0 -incr -o web/dor-zmax.png unu join -i latDiI-zmax.png latDiO-zmax.png black.png \ -a 0 -incr -o web/lat-zmax.png rm -rf *.png
![]() | ![]() |
dor-zmax.png: dorsal projection | lat-zmax.png: lateral projection |
unu project -i latDiI.nhdr -a 1 -m max \ | unu resample -s = x10.0 -k box \ | unu quantize -b 8 -o latDiI-ymax.png unu project -i latDiO.nhdr -a 1 -m max \ | unu resample -s = x10.0 -k box \ | unu quantize -b 8 -o latDiO-ymax.png unu 2op x 0 latDiO-ymax.png -o black.png unu join -i latDiI-ymax.png latDiO-ymax.png black.png -a 0 -incr \ | unu flip -a 2 -o web/lat-ymax.png unu project -i dorDiI.nhdr -a 1 -m max \ | unu resample -s = x10.0 -k box \ | unu quantize -b 8 -o dorDiI-ymax.png unu project -i dorDiO.nhdr -a 1 -m max \ | unu resample -s = x10.0 -k box \ | unu quantize -b 8 -o dorDiO-ymax.png unu 2op x 0 dorDiO-ymax.png -o black.png unu join -i dorDiI-ymax.png dorDiO-ymax.png black.png \ -a 0 -incr -o web/dor-ymax.png rm -rf *.png
![]() | ![]() |
lat-zmax.png: Dorsal projection of lateral dataset | dor-ymax.png: Lateral projection of dorsal dataset |
And then the files are saved in VTK format (after converting to signed short, which makes no difference for 12-bit data):NRRD0001 type: unsigned short dimension: 3 sizes: 512 512 43 spacings: 1 1 10 data file: ./dorDiI.raw.gz endian: big encoding: gz
foreach data ( dorDiI dorDiO latDiI latDiO ) echo ${data} unu convert -t short -i ${data}.nhdr \ | unu save -f vtk -e raw -o ${data}.vtk end