msdanalyzer icon indicating copy to clipboard operation
msdanalyzer copied to clipboard

FitMSD

Open nikos-95 opened this issue 7 years ago • 6 comments

Hello,

first of all great program! When fitting trajectories of shorter length (both simulated and actual measurements), however, I noticed a lot of negative diffusion coefficients and r² values (which both afaik shouldn't be possible) and dug into the code of fitMSD. If I interpret it correctly, the program determines how many time points correspond to 25% of the longest trajectory in the pool in terms of length, and than applies that to all other curves for their linear fit evaluation. This seems counter intuitive, as it includes very uncertain points from the shorter curves. The output even says "fitting the first 25% of EACH curve", but then the program doesn't take into account all the NaN points in the MSD data. This also leads to the following problem: when I have 100 tracks of length 8 each, the program will not fit any because they are all shortened to 1 point prior to fitting. If I add just one track of e.g. length 16 , then suddenly all tracks are properly fitted from point 2 to 16*0.25=4. See the issue? Edit: And yes, I realize that 25% of points of 8 is not 3, but this is beside the point here

Next, there is also another problem in regard to averaging the fits for a global diffusion coefficient. When I include ALL tracks, the estimate is about right (with a simulation of short tracks). However, when I include only the ones with r²>0.6 or so, a lot of the lower diffusion coefficients are discarded due to bad fit, causing an inflated estimate of total D. Maybe this will be solved with the problem above, when the fit can properly choose points and a correct r² is calculated for selection.

I think I came up with a coded solution for the point selection of each curve (not too hard) and can add it per request if you see the problem in the same way. However, I have no idea yet on how to deal with the negative D's or averaging in regards to low r2 so that the global mean is accurate, and what math says about the negative r2.

Thank you for reading.

nikos-95 avatar May 06 '17 14:05 nikos-95