User Tools

Site Tools


documents:101029imagej_cui_lifconversion

This is an old revision of the document!


Command Line: LIF to Tiff conversion

LIF is a grouped-stack file format containing multiple stacks. One could access each stack by LOCI Bio-Format plugin installed to ImageJ, but when file size is huge and data is in data server, data transfer rate becomes a bottle neck for the progress of work.

TO avoid this, one could do the file conversion via command line. This could be done by "bfconvert" command line tool available from Bio-format web site. Following command will do the job, converting all.

sh /g/almf/software/bftools/bfconvert <filename.lif>   converted_%s_%n_C%c.tiff

One missing function with this CL tool is that physical scales in x, y and z are not read out from LIF so that resulting Tiff stacks are devoid of these parameters. In addition, dimensional values such as number of slices per time point, and number of time points are not converted.

For this reason, following shell script was created to transfer physical scales in together with conversion.

sh /g/almf/software/ij/lifcon.sh </full/path/to/file.lif>

This script will extract metadata from LIF, convert each stack to Tiff stack, and set the physical parameters of the image by extracting these values from metadata. Tiff stack will be saved under a newly created directly where the LIF is located. Name of the directory will be

<file.lif>_tifStack

A text file named

<filename.lif>.meta.txt

is also generated, where extracted metadata is stored.

How Metadata is Extracted

Bioformat commandline tool “showinf” is used to save metadata as a text file. Then During the extraction of tiff stacks, physical scales and dimensionality information is extracted from the text and applied to the tiff stack.

Since macro command run(“Properties…”, arg1, arg2) does not work when IJ is headless since Properties command uses AWT. To avoid this, a small plugin (that does not appear in the menu) was created for setting image properties. This plugin is called from macro to set physical scales.

Link for the Image Property setter.

Shell Script lifcon.sh

#!/bin/sh
#script for converting Lif file to tif, and set physical scale.  
#
imgfullpath=$1

# path to IJ jar file
IJJARS="/g/almf/software/ij"

# path to image 
IMGFILE="${imgfullpath##*/}"
IMGPATH="${imgfullpath%/*}"
METAFULLPATH="${imgfullpath}.meta.txt"
echo ${METAFULLPATH}

# Lif converting IJ macro name
IJMACRONAME="LifOpenerCUI.ijm"

#timer
jobstart=$(date +%s)

sh /g/almf/software/bftools/showinf -nopix -nocore ${imgfullpath}>${METAFULLPATH}

chmod ugo+x ${METAFULLPATH}

/usr/struct/bin/java -cp ${IJJARS}/headless.jar:${IJJARS}/ij-1.44h.jar -Djava.awt.headless=true ij.ImageJ -ijpath ${IJ
JARS} -batch ${IJJARS}/${IJMACRONAME} ${imgfullpath}

# timer
jobend=$(date +%s)
echo "Time: $((jobend-jobstart)) secs."

documents/101029imagej_cui_lifconversion.1288366501.txt.gz · Last modified: 2016/05/24 12:46 (external edit)

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki