Prof. Srin Manne's AFM lab

Digital Instrument's Nanoscope file format description
It is often useful to manipulate Nanoscope images or force curves outside of DI's software. This page is intended to provide information on how to read the values in the header, and provide a starting point for writing your own software for processing Nanoscope files.

If you have any file types not covered in this section, send them to me and I will try to add some more information about them.

How do I determine what version the file is captured in?

Take a look at the header. The first line of version 3.x and 4.x headers is '\*File list' If the second line in the file begins with '\Version:' then it is a version 4.x or newer.   If so, the version number is what follows '\Version:'.  For example \Version: 0x04310006 is from version 4.31.

If the second line starts with '\Date:' then the file is from version 3.x .  If the first line of the header is 'Data_File_Type 7', then it is a version 2.x header.

The Basics
The version 2 headers are very straight forward, and a brief discussion can be found here.
For information on V4.3x and later headers, look here.

Version 3.x and 4.x headers are divided into sections. These sections follow a line of the form '\*sectionname'. The ones I found in a V3.x header are:
\*File list
\*Afm list (or \*Stm list)
\*Microscope list
\*Controller list
\*AFM image list (one for each image + 1 extra in dual images(why?)

The first section is '\*File list'. In this section you can find the date the file was captured, the number of images (or force curves) contained in the file, and the length of the header in bytes. Version 4.x files also have the version number.

Here is an example \*File list section with explanations:

\*File list
\Version: 0x04310006 Version 4.31
\Date: 06:42:39 PM Thu Jul 02 1998  Date and Time image was captured - useful if file date is change by offline processing
\Start context: OL2 Dual image is OL2, single image is OL, triple image is OL3
\Data length: 20480; Length in bytes, of header
\Text: I've never seen \Text: or \History: with any info in it
\History:

The next section in V3.x and V4.x before V4.3 is '\*Afm list' for AFM images or '\*Stm list' for STM images. In this section you can find the image scan size, x and y offsets, rotation, and number of samples. I will talk about the V4.3x and later headers later. Here is an example '\*Afm list' section showing only the most important sections.
\*Stm list is \*Afm list for AFM images
\Scan size: 30 nm scan size with units. Units may also be µm
\X offset: -488.361 nm x and y offsets with units
\Y offset: -521.309 nm
\Rotate Ang.: 0 scan angle in degrees
\Samps/line: 512 number of samples - either 128,256 or 512
\Scan rate: 3.05176 scan rate in Hz
\Y disable: Enabled Slow scan axis enabled or disabled
\Feedback type: Log STM feedback type. Is "Lin" for AFM data
\Setpoint: 163.84 Bias current setpoint for STM, setpoint voltage for AFM (Unknown scaling at this time)

The next section is '\*Microscope list'. There is nothing useful info here for file processing, but you can look here to find out what .par (piezo calibration) file was used.

'\*Controller list' also does not have any useful data for file processing.

'\*AFM image list' (or '\*STM image list') contains the z scaling, scan size, number of samples, type of data (height, aux, deflection, etc), planefit information, and the number of bytes offset from the start of the file to the image described in that particular '\*AFM image list' section.

Here is an example '\*AFM image list' section showing only the most important sections.
\*AFM image list is \*STM image list for STM images
\Data offset: 8192 this image data starts 8192 bytes from start of file
\Data length: 131072 number of bytes for this image
\Start context: OL They all say this...
\Data type: AFM image is AFM data (STM data type is...STM)
\Plane fit: 1116 660 3489.5 2 Numbers you need to un-plane fit the data
\Frame direction: Up Image was the up direction scan
\Samps/line: 256 256 Data is 256x256
\Scan size: 400 nm scan size (again)
\Line direction: Trace Scan direction Trace (can be Retrace)
\Image data: Aux D This image is Aux D channel data
\Z magnify image: 1.11684 Used by Nanoscope software for display - you don't need this
\Z scale: 0.895386 V Z range of data
\Z scale height: 177.316 z scaling of height data (this data is Aux D though)
\Z scale auxc: 16384 doesn't matter, this section is for Aux D
\Z scale auxd: 2934 This is the scaling value for the Aux D data to convert back to volts

The most important fields in this section are the Z scale and the planefit. After you find out what type of data the section is about (e.g. \Image data: Aux D), and where it starts and how long it is (\Data offset: 8192 and \Data length: 131072), you can read in the data and scale it back to the proper units using the appropriate '\Z scale xxxx' section. To convert the raw data for this image, you multiply the value by 65536 and divide by the \Z scale number.

real value = raw data value * 65536 / Z scale

Version 3.x files have a parameter called '\Planefit: ' in the '\*Afm list' section. This describes the type of offline planefit performed on the data: None, Full or Offset. This information is also encoded in the '\Plane fit: ' parameter in this section (\*AFM image list). The plane fit parameters are as follows:
\Plane fit: x y offset type

the type parameter is:
1 offset removed
2 full plane fit
3 captured plane removed
5 no plane fit removed

If the type is 5 (no plane fit), then no plane fit or offset has been applied to the data. If the type is 1 (offset only), then you can recover the original raw data by the scaling as described above, then adding the offset. If the plane fit type is 2, then a 1st order plane fit has been removed from the data. To recover the original unfit data is a bit difficult to describe in words, so maybe some pseudo c code will make it clearer:

Assume your image file is Aux A data stored in a 1D array starting at the short pointer pdata.
x, y, offset are the \Plane fit: x y offset parameters
auxa is the Z scale auxa: value

ytemp = y / (scan size)
xtemp = x / (scan size)
for(i = 1 ; i < = size ; i++ )
   {
   yscale = ( -0.5 * y + ytemp * i );
   for( j = 1 ; j < = size ; pdata++, j++ )
      {
      newvalue = *pdata;
      newvalue *= auxa / 65535.;
      newvalue += offset;
      xscale = ( -0.5 * x + xtemp * j ); //remove planefit
      newvalue += xscale;
      newvalue += yscale;
      *pdata = (short) newvalue;
      }
   }

What you probably really want is to scale the data back to real units.
To convert Aux channel data back to volts, multiply the scaled data by 20V/65536. To convert height data back to nm, multiply by

Information about version 2 headers can be found here.
Information on V4.3x and later headers can be found here.

For questions, comments, corrections, etc, about any of the technical documents here, please mail them to: rworkman@u.arizona.edu

Contact info:
Srin Manne
Physics Dept
PAS 575
520-626-5305
smanne@physics.arizona.edu