Renaming TIFF series

At the current state the Huygens Software supports a couple of widespread TIFF series naming conventions (see File Formats ) for Fluorescence Microscopes , but there are so many alternatives that we are planning to develop a more flexible approach. In the meantime you can try to use the current capabilities as explained below.

You can for example import simple Numbered Tiff series for different channels, and then combine all them by Joining Channels to build a single multidimensional image.

Remember that you can always rearrange the way Huygens interprets a loaded series, see Convert The Data Set .

You can rename your series to change its name scheme to the supported conventions. An example follows.

Rename Olympus OIF series


This is an email from a customer:

> I have some 4D datasets saved in Olympus OIF format (16-bit TIFF).

> Each image for a channel at each z-plane is saved as a 16-bit tiff:

> filename_C00nZ00nT00n.tif

> When I select the first image of the first time point

> (filename_C001Z001T001), Huygens will open the the first image plane

> for as a stack of 4 timepoints:

> C001Z001T001,C001Z001T002,C001Z001T003,C001Z001T004.

Huygens does not specifically support this name convention. They are TIFF files thus the file format is not the problem, but the program will not be able to read the whole series in a single multidimensional dataset. Because this is not a Leica Tiff series it is understood as a simple Numbered Tiff series considering the last index only, which is definetely not the intended behavior.


One approach by now would be to rename all files to follow the supported Leica Tiff series name conventions. In unix systems (including Mac OS X) this can be achieved with a simple shell script like this:

 for file in *_C*.tif
    head=`echo $file |sed -e 's/_.*tif//'`
    plane=`echo $file |sed -e 's/.*Z\([0-9]\{1,\}\).*/\1/'`
    channel=`echo $file |sed -e 's/.*C\([0-9]\{1,\}\).*/\1/'`
    time=`echo $file |sed -e 's/.*T\([0-9]\{1,\}\).*/\1/'`


    echo $file: t $time z $plane ch $channel
    mv "$file" "$newname"

Create a new file (e.g. renameOIF) with your favourite text editor and paste the code above. (Don't use a word processor like MS-Word, just a simple text editor like vi or emacs). Do it verbatim, all the quotes are necesssary. Save the file in the same directory where your series is.

> I used Apple's TextEdit, set its preferences to create new documents in

> 'plain text' format rather than in the default rich text. When

> saving, I used the default Western (Mac OS Roman) plain text encoding.

Then open a shell (terminal), give the saved script execution permissions (-+chmod 744 renameOIF+-) and run it by commanding ./renameOIF.


The script uses the stream editor sed to parse the file name using regular expressions and take out the relevant indexes. The syntax looks obscure but it is quite standard:

echo $file |sed -e 's/.*Z\(\[0-9\]\{1,\}\).*/\1/'

The first part, echo $file |, pipes the file name to the sed editor, which executes (-+-e+-) a substitution (-+s+-). The string that matches the pattern between the first pair of slashes (-+.*Z\(0-9\{1,\}\).*+-) is replaced by the string between the last pair of slashes (-+\1+-).

The search pattern .*Z(0-9{1,}).* (parenthesis and curly braces are escaped by using a backslash: this difficults the reading but is syntactically necessary) means: any string of characters (-+.*+-) followed by a Z and a string of digits of at least one character 0-9{1,} and finally again any string of characters (-+.*+-). Notice that the index part is actually enclosed in parenthesis (0-9{1,}). These brackets do not affect the global matching pattern, but serve to identify an interesting part of it to be used later in the replacement pattern. The search pattern actually matches the whole file name, but we used it to "mark" the interesting part.

The replacement pattern \1 (backslash-one) means: the string that matches the first block between parenthesis in the search pattern. In our case this is the Z index value.

The final effect is that from the input stream (the original file name) the file name itself is replaced by the interesting index only. sed returns this string and it is asigned to the variable plane, which we will use later to rename the file (-+mv+-).

This is done for all the present files ending in tif but also with the string _C in the file name, to avoid renaming of the results if the script is accidentaly run again. This works because the reported OIF name convention begins the index part with such a string, you must change this if the scheme is different.

Rename Huygens output

Another example, that renames the Huygens output filename_TimeChannel.pic (time has three figures, channel has two), to filename_ChannelTime.pic:

 for file in *.pic
    head=`echo $file |sed -e 's/_.*pic//'`

    # match (three figures)(two figures)
    # and assign them to time and channel respectively
    time=`echo $file |sed -e 's/.*\([0-9]\{3,3\}\)\([0-9]\{2,2\}\).*/\1/'`
    channel=`echo $file |sed -e 's/.*\([0-9]\{3,3\}\)\([0-9]\{2,2\}\).*/\2/'`

    # invert the index order

    echo $file: t $time $channel
    echo mv "$file" "$newname"