Closed shk44 closed 1 year ago
Hi @shk44, thank you for the report (especially with all the detail and the file).
I think the problem is with the tracking result XML file. If I do:
library(TrackMateR)
library(ggplot2)
xmlPath <- file.choose()
tmObj <- readTrackMateXML(XMLpath = xmlPath)
Units are: 0.1083333 micron and 1.318351 s
Collecting spot data. Using 20 cores
Matching track data...
Calculating distances...
# error here
reportDataset(tmObj)
Error in displacementXMat[a$frame, i] <- a$x :
number of items to replace is not a multiple of replacement length
# extract the data to data frame
tmDF <- tmobj[[1]]
View(tmDF)
Then I see that the first track (trace = "0") has three points at frame 0, three points at frame 1 etc. Other tracks also have multiple points in the same frame - each track should have only one point in each frame. I have checked the XML file and sure enough, TrackMate has made tracks with multiple points.
This is why TrackMateR is failing to process the file. It is reading the file correctly, but the error is in the file. So I think the solution will be to improve the tracking side.
Thank you for the quick response. I tried using TrackMate's advanced Kalman filter as my spots are mainly moving in linear directions. Are there specific Tracking algorithms that work better with TrackMateR, or is it something off with my trackmate settings that cause the multiple spots per frame per track issue? For novices like me, some initial guidelines to what would work well with TrackMateR would be very helpful, though I understand it may not be in the immediate purview of maintaining the package.
Edit: I simply changed the tracking algorithm to the simple Kalman's tracking one over the advanced one and that solved the issue. I am now able to analyze the files since I have only one spot per track per frame. Thank you!
TrackMateR is written with the assumption that there are single tracks. Looking at your file a bit more closely, I notice Allow Track Splitting and Allow Track Merging are set to TRUE. I suspect these settings could cause the multiple spots per frame per track issue. I don't know what you are tracking but if the spots are not dividing and merging, then probably unchecking these options is best and it might solve the problem.
The only other thing to try would be to update TrackMate as it is now on v 7.11.1 so the problem we're encountering here might be dealt with already.
There's no preferred tracking algorithms for TrackMateR. It's written to be able to take the TrackMate XML output (2D only) regardless of the detection and tracking. However, I haven't tested it with every possible output, so am prepared to fix any peculiarities that crop up.
As I was typing, I saw your edit. Glad that you have fixed it. Give a thumbs up if OK and I will close the issue.
Ultimately, having merge and splitting options available would be important for my downstream analysis. However, there are many other interesting questions in the mean time I can use the package for that disregard splitting and merging, so I think you've addressed my issue. Thanks again for your hard work!
After loading my TrackMate .xml that contains track and spot info, trackmateR properly detects the XY resolution and the time window. It collects spot data, matches track data, and calculates distance without error. However, doing any sort of analysis apart from plot_tm_allTracks returns the following error:
I have properly loaded the TrackMateR vignette data and generated the report, so I think it's something to do with my xml file, uploaded below. Any help in deciphering and fixing this issue would be much appreciated. Thank you! cell5.zip
TrackMate version 7.10.2, ImageJ 1.54f, data obtained using a spinning disk confocal imaging at roughly 0.10 micron / px and 1 sec / frame for a 60 sec recording. The tracks are fairly sparse and the track calling and definitely be optimized, but this was just an initial test.
Session Info: