ModifyImage problem when writing a procedure.

Hi All,

I'm having, I think, a similar problem that was on this thread. http://www.igorexchange.com/node/6419

So I have written something that will go through every wave in a data folder and create an image.

I then wanted to try to do something similar to an image macro but found it wasn't working. (I tired Execute command but failed at that). So I rewrote my macro commands as a function so after igor makes the new image it(he?) can then go on and modify it.

But I am having problem with the ModifyImage command, I've read up on it and I think I'm using it appropriately but I am clearly missing something. Here is the general gist of what I am doing minus my graph formatting preferences.

Function MacRamalan2()
    Variable datafolder
    String/G list = Wavelist("*",";","") // creates a list of all waves in current "datafolder" separated by a ;
           
           
    Variable/G numItems = ItemsInList(list), i // counts how and indices the items(graph) broken by ;
    for (i = 0; i<numItems; i+=1) // starts a loop to go through each wave data
        String/G data   //creates a string of ith data
       
        data = StringFromList(i,list,";") //goes through list and extracts ith string
        wave w=$data
        newimage w
        String/G win=WinName (0,1)  //The name of the top visible graph
        ModifyImage win, ctab= {*,*,YellowHot,0}
        //Raman_IDIG()   the modified macro function where everything under newimage will live once working
    endfor
end


So for simplicity I left out some other bits of code that are working. I keep getting the error that ModifyImage should be "expecting the name of an image in the top graph". But shouldn't the WinName function pick up the name of the window just made?

If anyone can explain what i'm doing wrong and/or direct me to the bit in the manual that can explain it better that would be great.

Thanks in advance!
N
n.black wrote:
Hi All,

So for simplicity I left out some other bits of code that are working. I keep getting the error that ModifyImage should be "expecting the name of an image in the top graph". But shouldn't the WinName function pick up the name of the window just made?

If anyone can explain what i'm doing wrong and/or direct me to the bit in the manual that can explain it better that would be great.


You need to use
ModifyImage $(win), ctab= {*,*,YellowHot,0}


Also, there is probably no need to make your win string global. Just do String win = WinName(0,1) unless you actually need it to be global.

For more information, execute the following commands on the command line. Only the first applies to this particular situation, but once you know about the $ operator, you're likely to try to use it elsewhere, and that's covered by the other help topics.
DisplayHelpTopic "String Substitution Using $"
DisplayHelpTopic "Converting a String into a Reference Using $"
DisplayHelpTopic "Wave Accessed Via String Passed as Parameter"
DisplayHelpTopic "Wave Accessed Via String Calculated in Function"
Hi aclight,

Thank you so much for your speedy reply.
I used the $ as you said which upon reading essentially operates on the string and should return a name. But I still get the same error as before. Any idea how to proceed?

Also, I used the global string purely to find it easily in the databrowser and check the information in the string to make sure my function is doing what I think it's doing but yes I will remove it once function is working.
I'm still reading through the manual references which are very helpful!

Thanks,
N

It seems you are missing the "/W" flag:
ModifyImage [/W=winName ] imageInstance , keyword =value  [, keyword =value  ...]
-->
ModifyImage /W=$win, ctab= {*,*,YellowHot,0}

HJ
Hi HJ,

Thanks for the input. I tried this but again got the same error. I believe ModifyImage only needs /W flag when you need to specify an image that is not the top graph.

Thanks,
N
Sorry, didn't read precise enough: I was assuming "win" referred to a window but you want to use it as an imageinstance.
You should not use WinName at all in this case

Assuming your data waves have "nice" names, a change of
ModifyImage win, ctab= {*,*,YellowHot,0}
to
ModifyImage $data, ctab= {*,*,YellowHot,0}
should work.

HJ
Hi HJ,

Thanks that did the trick!
To just verify I understand conceptually what is happening.

data = StringFromList(i,list,";") //goes through list and extracts ith string
wave w=$data

Converts the name of ith string and turns it into a wave of data.

and

ModifyImage $data, ctab= {*,*,YellowHot,0}

Takes the name of data which should incidentally be the name of the image from above statement and plug the image name into the command.

Thank you very much for your help! =)

Best wishes,
N
Almost.
"$str" creates a reference to the "object" named by a string "str". It can be a wave, variable, window, image, trace, and even a function (in some cases).
I also recommend to read
DisplayHelpTopic "Converting a String into a Reference Using $"
since it is one of the powerful features Igor provides.

By default traces and images share the name of the wave they were created from. Thus "$data" also works in the second case.
HJ
n.black wrote:
Hi aclight,
Also, I used the global string purely to find it easily in the databrowser and check the information in the string to make sure my function is doing what I think it's doing but yes I will remove it once function is working.
I'm still reading through the manual references which are very helpful!

You're better off using Igor's debugger in this situation. For more information, execute DisplayHelpTopic "The Debugger"