Igor print function working strangely
DJackson
Here is my question: is there some hidden functionality of the print function in Igor which makes it print repeatedly in some circumstances? Below is the code for reference, I've annotated in all caps relevant portions.
Function Curves(sublist, wName)//doesnt return anything, just adds values.
String sublist
wave wName
variable i, numNeg = 5
String label
//THIS IS THE FOR LOOP WHERE, FOR EACH VALUE i, THERE SHOULD BE ONE THING PRINTED, BUT PRINTS i * some constant TIMES INSTEAD
for(i = 0; i < numNeg; i+=1)
wave current = $stringfromlist(i, sublist, "\r")
label = num2str((i - 5) * 10)
InsertPoints/M=1 DimSize(wName, 1), 1, wName
InsertPoints/M=2 DimSize(wName, 2), 1, wName
print "%%%%\r" + num2str(DimSize(wName, 0)) + "%%%%\r"
//FUNCTION CALLED HERE
wName[DimSize(wName, 0) - 1][i][]= FI(label, current)
endfor
end
Function FI(label, current)
String label
wave current
variable spikes, currentInjected, FI
variable level = 0
findLevels/DEST=levels/Q current, level
spikes = numpnts(levels) / 2
currentInjected = str2num(label)
FI = spikes / currentInjected
//CALLS PRINT HERE, BUT IT PRINTS REPEATEDLY, UP TO ~17 TIMES.
print ("*********************\r" + nameofwave(current) + "- " + "\rFI: " + num2str(FI) + "\rspikes: " + num2str(spikes) + "\rcurrent injected: " + num2str(currentInjected))
return FI
end
String sublist
wave wName
variable i, numNeg = 5
String label
//THIS IS THE FOR LOOP WHERE, FOR EACH VALUE i, THERE SHOULD BE ONE THING PRINTED, BUT PRINTS i * some constant TIMES INSTEAD
for(i = 0; i < numNeg; i+=1)
wave current = $stringfromlist(i, sublist, "\r")
label = num2str((i - 5) * 10)
InsertPoints/M=1 DimSize(wName, 1), 1, wName
InsertPoints/M=2 DimSize(wName, 2), 1, wName
print "%%%%\r" + num2str(DimSize(wName, 0)) + "%%%%\r"
//FUNCTION CALLED HERE
wName[DimSize(wName, 0) - 1][i][]= FI(label, current)
endfor
end
Function FI(label, current)
String label
wave current
variable spikes, currentInjected, FI
variable level = 0
findLevels/DEST=levels/Q current, level
spikes = numpnts(levels) / 2
currentInjected = str2num(label)
FI = spikes / currentInjected
//CALLS PRINT HERE, BUT IT PRINTS REPEATEDLY, UP TO ~17 TIMES.
print ("*********************\r" + nameofwave(current) + "- " + "\rFI: " + num2str(FI) + "\rspikes: " + num2str(spikes) + "\rcurrent injected: " + num2str(currentInjected))
return FI
end
Thank you all so much for your input.
evaluates the righthand side once for each element of the destination range. Thus, in this example, FI is called once for each element in the layers dimension (because of [] at the end on the right) and prints each time it is called.
If you need further help, try creating a self-contained, simplified procedure that illustrates the problem and which we can execute.
December 24, 2015 at 12:25 pm - Permalink
wName[DimSize(wName, 0) - 1][i][]= FI(label, current)
to this:wName[DimSize(wName, 0) - 1][i][0]= FI(label, current)
and now it prints once per for loop iteration, which is what I wanted.Thanks for your help!
December 24, 2015 at 02:05 pm - Permalink