Converting Labbook IM_ files to tiffs


Image acquisition for the JEOL 5800-LV scanning electron microscope I'm using for my senior thesis is controlled by a software package called Link ISIS Labbook. Labbook saves image files in a nonstandard format, IM_, read by no other software; frustratingly, it has no batch conversion capability, so it can convert only one IM_ file at a time to more a more useful format like bmp or tiff. I generate hundreds of image files and converting them one-by-one would be tedious, so I've written a Python script to convert IM_ files into tiffs. In this page, I'll describe Link ISIS Labbook's folder structure, give some details about the IM_ file format, and then provide my script for download with instructions for its use.

Labbook stores IM_ files in C:\ISISData\USERS1\AC#\J#. "AC" is short for "analytical configuration", a certain set of analytical parameters: accelerating voltage, number of detector channels, etc. "J" is short for "job": every Labbook IM_ file belongs to a job. The number of your current job (and the complete file path to its IM_ files) is at the top of the main Labbook window. Besides IM_ files, each job folder contains a text file, JOBNOTES.txt, which can be accessed for editing in the main Link ISIS menu; low-resolution bmp files, which are generated upon demand to serve as image previews; and, finally, a number of files used in the Link ISIS database. The filenames of IM_ files are informative: the filenames of BSE or SE image (backscattered electron or secondary electron images) have the general format g#@0.IM_, where # is the image's number in the job; the filenames of X-ray maps and their corresponding BSE or SE images have the general format G#@%.IM_, where # is again the image's number in the job and % corresponds to the type of map or image (G20@3.IM_ might be an Mg K-alpha x-ray map; G20@0.IM_ would then be a BSE image of the same area).

The structure of IM_ files is fortunately pretty simple: there's a header containing the picture's name, job info, scale information, etc. Image data starts at the 2144th byte and runs to the end of the file. The image data runs backward, so that the first byte of image data actually corresponds to the farthest bottom right of the image. In BSE and SE (back-scattered electron and secondary electron) images, every byte of image data corresponds to a 256-valued grayscale pixel in the image file. In X-ray maps, every other byte of image data corresponds to a 256-valued grayscale pixel in the image file. However, these bytes only take 30 values: the recorded x-ray intensities must be binned somehow. Puzzlingly, alternate bytes in the X-ray map image data are blank. Maybe there was a plan to interleave X-ray maps and BSE images. Finally, IM_ files can come in five possible resolutions, all with a 4:3 aspect ratio: coarse, 64 x 48; medium, 128 x 94; 'fine', 256 x 192; 'ultrafine', 512 x 384; and high, 1024 x 768. X-ray maps are about twice as large as BSE or SE images of the same resolution (because of the alternate blank bytes).

im_-to-tiff.py (packed in a zip file)

Here's my script. You need Python and the Python Imaging Library module to run it. (I run it on Windows with Python 2.7 and Python Imaging Library 1.1.7.) The script takes a directory and a resolution, and converts all the IM_ files in that directory to tiffs. Here's a sample call of the script: "python im_-to-tiff.py C:\Users\wvaughan\Allende-Ca-maps ultrafine". X-ray maps and BSE/SE images can be mixed in the same directory, but IM_ files with different resolutions cannot. The script doesn't preserve IM_ metadata in the produced tiffs, so save a tiff with a scale bar and, if you did X-ray mapping, be sure to record which elements you mapped and in which order. The X-ray maps produced by this script will look very dark: this is because the bytes take only 30 (low) values. You can contrast-stretch the maps with ImageJ.



Back to wvaughan.org
Will Vaughan. Last revision November 11, 2010.