TrackObjects Bug


Found three small bugs in TrackObjects: In case there’s only a single object, it crashes.
First bug:
In line 259:
InitialNumObjs = length(TrackObjInfo.Current.Locations{setBeingAnalyzed});

It should be changed to:
InitialNumObjs = size(TrackObjInfo.Current.Locations{setBeingAnalyzed}, 1);

Otherwise length takes the longer of the dimensions which is two (for x and y) even if you have only one object.

Second bug:
In line 531:
You have something like this:
Linearity(idx) = sqrt(sum((InitialObjectLocation(AbsentObjectsLabel,:)-PreviousLocations(idx,:)).^2,2))./SumDistance(AbsentObjectsLabel);

You can get dimension mismatch here if AbsentObjectsLabel is empty.

So I changed it to:
if (~isempty(AbsentObjectsLabel))
Linearity(idx) = sqrt(sum((InitialObjectLocation(AbsentObjectsLabel,:)-PreviousLocations(idx,:)).^2,2))./SumDistance(AbsentObjectsLabel);

I’m not sure about this fix, I just wanted it to stop crashing, and this seems like the correct behavior.

Third bug:
In ComputeTrackingStatistics, in the line:
SumDistance(NewLabels) = 0;
it should be changed into:
SumDistance(NewLabels, 1) = 0;

Otherwise, if you have 1 cell in a certain frame, and then a new cell is born, SumDistance new object in NewLabels is added, and you get a dimension of : 1,2. But it’s supposed to be 2,1 (if it’s 1,2 in the next image you get a dimension mismatch).


Thanks for reporting the bugs! We have noted these as well (with the exception of the 3rd one), and your solutions pretty much match our fixes. In any case, our upcoming Python-based release has corrected all of these issues, plus implemented a newer tracking algorithm, so stay tuned for that.