Storing the history of how a wave has been manipulated?

In a different post http://www.igorexchange.com/node/4519 ...

tkessler wrote:

By storing and retrieving the scaling factor using the highest significant digits I can, it eliminates this error and returns the scaled wave to its original values (or at least with a significance so precise that Igor does not show a difference even when using print/D to sample the stored values in the wave).


This got me thinking ...

What might be the different ways to store a history about how a specific wave has been manipulated? Is there a best way to do this? Is there any sense of a standard way to do it?
I've created the following "getnote" and "setnote" routines, which will save any output as a new tag to a note as a string, which can then be retrieved. Number values will need to be converted to numbers with str2num or similar:

Function SetNote(wavenm, notekey, newValueStr)
    WAVE wavenm
    string notekey
    string newValueStr
   
    if(stringmatch(newValueStr,""))
        note/k wavenm, removebykey(notekey,Note(wavenm),":","\r")
    else
        note/k wavenm, replacestringbykey(notekey,Note(wavenm)," "+newValueStr,":","\r")
    endif
end

Function/S GetNote(wavenm,notekey)
    WAVE wavenm
    string notekey
    return stringbykey(notekey,note(wavenm),":","\r")[1,inf]
end


For example, if I baseline a wave in a procedure, then I'll tack on this command:

SetNote(wavenm,"Baseline",num2str(baselineValue))

This will create a note entry of "Baseline: baselineValue" in the wave, that can then be retrieved with the following command:

baselineValue=str2num(GetNote(wavenm,"Baseline"))

To remove an entry, you simply have to set its value to an empty string, such as the following:

SetNote(wavenm,"Baseline","")

With this you can create a full construct of changes made to waves so they can be retrieved or undone, etc. Unfortunately you have to do this manually and keep track of the changes you make. However, you might be able to use this approach in a similar manner to append a revolving "recent history" of manipulations to the wave.
tkessler wrote:
I've created the following "getnote" and "setnote" routines, ...
With this you can create a full construct of changes made to waves so they can be retrieved or undone, etc. Unfortunately you have to do this manually and keep track of the changes you make. However, you might be able to use this approach in a similar manner to append a revolving "recent history" of manipulations to the wave.


I have used a similar approach to write to a wave note with XML Note Tools http://www.igorexchange.com/project/XMLNoteTools.

I wonder if a better approach exists than writing to the wave note? I think in particular of an interferometer system that I used that generated images in stages. One could go to any image, change the parameters associated with that image, and have the changes propagate throughout the entire steps afterward. This system clearly had a robust means to store history.

--
J. J. Weimer
Chemistry / Chemical & Materials Engineering, UAHuntsville
I think in this sense Igor would benefit from a more object-oriented approach to programming and storing data (variables, strings, waves, etc.); however, this may not be feasible. I've asked in the past about the use of global structures that could be used for similar features, but it just doesn't seem possible.

I agree it would be very nice to be able to augment some objects (particularly waves) with additional metadata besides notes, or create global user-defined objects that can include multiple waves, variables, and method code. To an extent folders can do this, but I've found dealing with them can be a bit of a burden. I think being able to create a simple structure pointer to a custom globally defined object would be far more straightforward.