
LoadWave with .ibw files

pawel.wzietek
I'm using LoadWave to import .ibw files. The name of the wave is stored in the file and as far as I could see the /A or /N flags apparently don't work for this format, I can only use /O to force overwriting the existing wave if any. But what if I don't remember what the wave name was when the file was created ? (I'm dealing with lots of different 4D waves created by other experiments). I guess there should be a programmatic way to know it (apart from parsing somehow the history record after loading) or change the destination wave name but I don't find it.
I'm still using Igor 8, my apologies if this was addressed in a newer version, anyway I will upgrade soon :)
Perhaps one of these options might solve your problem.
* Load into a temporary folder, find the name, and process?
* Parse the .ibw file in a line-by-line manner to obtain the name before loading?
April 16, 2025 at 09:50 am - Permalink
Yes, this is an option to explore
Well, then I could as well define my own binary format without relying on .ibw ... :) Actually the reason I want to stick to .ibw is that the loading is fast (my files are several Gb), apparently faster than other formats (hdf5, raw binary). For me .ibw is a good format, the problem of wave name handling by LoadWave appears as a minor shortcoming that could be easily corrected by WM. At the moment I'm rewriting all my old code so as to save all .ibw with the same wave name but it's stupid.
April 16, 2025 at 10:38 am - Permalink
So the idea is to read the wave name without actually loading the file? As a little exercise, I went ahead and did the bit peeking. This script should be able to read the wave names of all ibw file versions (see also the attached file):
Use via e.g.:
print readIBWname("pathToAFileOnDisk")
April 16, 2025 at 09:13 pm - Permalink
Wow, thanks! And my apologies to jjweimer for not having taken seriously his second suggestion, I didn't have the courage to try reverse engineering of the ibw structure.
Where did you get the info about different versions ?
I'm now using it like this:
April 17, 2025 at 12:17 am - Permalink
You can get all the details about the structure of ibw files from the technical note #003 and the file-write header. See here:
So you are loading the wave anyway in your code? If you use LoadWave, why don't you grab the loaded wave name from S_waveNames then? Like this:
EDIT: I also strongly advise against code like this:
This is destined to fail if $destname is, e.g., plotted in a graph. What you want instead is:
Duplicate/O $ibwname, $destname
April 17, 2025 at 04:37 am - Permalink
I created a few more functions for a few other aspects of waves which might be of interest (mainly to me). See here:
https://www.wavemetrics.com/code-snippet/load-wave-details-ibw-files-directly-binary-without-loading-data
April 17, 2025 at 04:47 am - Permalink
Oops, apparently I did not read the manual to the end :(, now I did:
Sorry for having bothered you all with this apparently trivial question, maybe my formulation wasn't clear enough so you did not point out the solution immediately. That said your functions will be very useful for me, on other occasions.
Yes I agree, I also started with duplicate then modified it this way when started to handle huge (several Gb) waves, worrying that making another copy it might sometime run out of RAM space...
So the final (and safe) code would be like:
April 17, 2025 at 05:38 am - Permalink
Good that this has been solved. If anything, this exercise should give you a good starting point for parsing npy files in your other thread. You just would need to follow the format definition and attack the header via FBinRead. Then, when you have all the dimensions and data types at hand, load the core data via GBLaodWave from the npy file. I could give it a try, but I don't have an useful example and also already had my fix of bit hacking for today.
April 17, 2025 at 06:23 am - Permalink
No worry, I also love hacking (when I have time - teaching already takes more than half of it ...) but at this time I'm happy to have a working solution to the file handling problem and can finally get to do some physics with the data.
I've got tens of thousands of X-ray images and have to think how to process them and what information can be extracted (some modelling but the models I had tried so far are not quite good yet, also look at inter-image correlations etc.). I'm sure I will need some hacking to optimize the code (e.g. some parts can be much faster on GPU) so as to have my codes running in reasonable time.
Thanks again for your help.
April 17, 2025 at 08:18 am - Permalink
And I will reiterate- if you have Python code generating a npyArrays, you might like to try the Igor 10 beta with Python integration. It includes an easy conversion between waves an npyArrays.
https://www.wavemetrics.com/forum/news-and-announcements/igor-pro-10-be…
April 17, 2025 at 09:29 am - Permalink