IgorBinary Manual

An Example Notebook

Arnd Roth
Abteilung Zellphysiologie
Max-Planck-Institut fuer Medizinische Forschung
Postfach 10 38 20, D-69028 Heidelberg, Germany
roth@sunny.mpimf-heidelberg.mpg.de

How it works

Here is a little trick that speeds up certain kinds of list processing in old releases of Mathematica 2.2. You don't need it if you are working with version 2.2.2 or 2.2.3.

SetAttributes[N, Listable];

This loads the package.

<<Utilities`IgorBinary`

?IgorBinary

?SaveIgorBinary

Make a trial wave in Mathematica:

trialwave = Table[Random[], {100}]

Save trialwave in Igor binary file format, without special option settings:

SaveIgorBinary["test1.bwav", trialwave]

These are the default option settings which we just used,

Options[SaveIgorBinary]

?WaveUnits

?XScalingFunction

?YFullScale

?WaveNote

Here, the same wave is saved with different option settings.

SaveIgorBinary["test2.bwav", trialwave,
               WaveUnits -> {"x", "y"},
               XScalingFunction -> (2.5 # + 1.5 &),
               YFullScale -> {0, 1},
               WaveNote -> "Uniformly distributed \
               random numbers."]

The following function reads waves from Igor binary files into Mathematica:

?ReadIgorBinary

?IgorBinaryWave

For simplicity, we just read test1.bwav and test2.bwav back into Mathematica.

ibw1 = ReadIgorBinary["test1.bwav"]

ibw2 = ReadIgorBinary["test2.bwav"]

The full internal representation is, e.g.,

InputForm[ibw2]

These functions give easy access to the parts of an IgorBinaryWave object:

?WaveName

?RawWaveData

?ScaledWaveData

?WaveInformation

ListPlot[ScaledWaveData[ibw2], AxesLabel ->
         WaveUnits /. WaveInformation[ibw2]]

Known problems

This package is not self-contained. It needs a MathLink program called FastBinaryFiles, written by Todd Gayley (mathsource.wri.com, item number 0206-783). IgorBinary.m will automatically install the FastBinaryFiles package if it can be found in ":Mathematica 2.2:Packages:binary" or an analogous location on Unix systems. The autoload mechanism will fail if the package is not there, or if the setting of $Path is not as expected. It may be necessary to change the code portion responsible for autoloading,

(* ... *)
Which[$OperatingSystem === "Unix",
      SetDirectory[Last[$Path]]; (* ../Packages *)
      SetDirectory["Utilities"];
      link = Install["binary"];
      ResetDirectory[];
      ResetDirectory[],
      $OperatingSystem === "MacOS",
      SetDirectory[First[$Path]]; (* ..:Packages *)
      SetDirectory["Utilities"];
      link = Install["binary"];
      ResetDirectory[];
      ResetDirectory[],
(* ... *)

in order to reflect such changes. Alternatively, you can install the MathLink program manually before loading the IgorBinary.m package.

Warning: At the moment, this package is not useful on the PC. The reason is that the current version of the FastBinaryFiles package just mentioned, 1.0, addresses the issue of coverting between little-endian and big-endian format for integers only, not for float and double. This problem does not, of course, affect the use of this package on the Macintosh and most Unix workstations (Sun SPARC etc.) since they are big-endian machines.

Limitation: This package reads single and double precision Igor waves but writes only double precision waves. This may be reasonable since machine arithmetic in Mathematica is done in double precision.

Important: You need ResEdit to make Igor recognize the .bwav files generated by SaveIgorBinary as Igor binary files. Go to the File menu of the ResEdit application, and select the Get File/Folder Info... item. Locate the .bwav file, and hit the Get Info button. In the Info window that appears, insert IGBW in the Type field and IGR0 (zero!) in the Creator field. Close the Info window and click Yes for Save.