Comments Blog About Development Research Sites

Converting binary data files
Going from Igor Pro to Matlab with ibw2mat

May 7, 2013
The lab I work with uses the WaveMetrics Igor Pro application to drive and record neuron traces. However, all my scripts for analyzing this data have been written in Matlab. The reason for this is quite simple: Matlab was designed almost specifically for analyzing and parsing scientific data. While you could do the same analysis in any language, and indeed many languages are much more powerful and even easier to write than Matlab code, the sheer amount of tools readily available make it the perfect choice for such analysis.

So far, so good.

However, by default, Igor Pro uses a binary data format to store its experiments in. You can export as, for example, CSV files, and import these in Matlab, but the process is arduous at best. There is also the risk that information is lost; CSV just isn't an ideal format for all purposes.

Luckily, there is an Igor Pro data file ANSI C library available. This enables me to read out IBW files, which are automatically generated if you save your Igor Pro experiment as unpacked experiment file (uxp). For the second part of the conversion process, I used Malcolm Mclean's portable ANSI C Matlab file exporter. This simple library allows me to store data as binary matlab .mat file. Even better: it also enables me to store multiple data traces in a single file.

Adding a bit of C to glue the two together gives us ibw2mat. When executed, it will look in the current working directory for IBW files, read out the data in each of these and add them with the correct trace name (read out from the file) to a wavedata.mat file. Essentially, it converts a directory of Igor Binary Waveform files into a single, easily loadable matlab .mat datafile.

Portability wise, the main obstacle is reading out the directory file listing: I am no C wizard, and getting a list of files in the current directory is tricky to do cross-platform. Thus, I used the dirent interface, which should take care of that; your mileage may vary though.

I should also note that I wrote this specifically for one type of Igor Pro files: 32 bit floating points. There are half a dozen other formats though, and proper conversion will require some modifications.

FragFrog out!

New comment

Your name:
Comment: