getResult() ouput from TrackMate error

imagej
macro
trackmate

#1

I run TrackMate, export the tracks, reload them as Results table which returns a TRACK_ID column that contains either a number limited to [0…nResults-1] or “None”. According to the manual getResult returns a string. Expecting I can compare two strings with the == operator, I have these macro steps:

for(i=0;i<nResults;i++){
	trackID=getResult("TRACK_ID",i);
	if(trackID == "None"){trackID=-1;}
    handle(trackID);
}

With a certain i, when trackID contains 13 according to the debug window, I get an error

Number or numeric function expected  in line 104
if(trackID == <"None">){trackID=-1;}

which I don’t understand if getResult returns a string type. I’d expect a type cast to if(string == string) which shouldn’t pose a problem. Example code also shows the use of string comparison.
Do I overlook the obvious?


#2

@eljonco

So… I’m not sure the definitive answer in this case… but I suppose you can always add toString(trackID) within the if statement to be sure this error does not pop up.

But of course - this is just a hacky-workaround and doesn’t get to why this is happening…

eta


#3

Thanks, I’m off testing.

[a little later] Closer inspection shows that TRACK_ID contains ‘None’ in the column, but the VALUE of TRACK_ID is NaN. Wonder how I missed that. Testing for isNaN is the obvious solution then.

If I do not follow up on this post, consider it solved. Ehr, worked around.