%% To generate MSD distribution
clear;close all;clc

cd('/path/to/dataset')
fdir = ['/path/to/dataset/']
fdir = ['/home/mcm/Desktop/Fiji.app/test/'] % finishing by a /

%%

compute_spt = 1;
compute_D = 1;

expList = dir('Tracks/*-*');


%fname = '2018-11-06-60ms'; 
%%[]; Track_density = 0;

Int_min = 'percentage'; std_max = 3; maxDisplacement = 4;
%
peaknbs = []
jj = 0

for raw_th = 1.6 %[1.6, 1.65, 1.7, 1.75, 1.8, 2, 2.2, 2.4]%[1.6, 1.65, 1.7, 1.75, 1.8, 1.9, 2, 2.2, 2.4];%1.6:0.05:1.8
filter_th = 4

for Res_max = 0.15 %[0.3, 0.4, 0.6, 0.8, 0.1]
Int_min = 'percentage'; %[200, 400, 600, 800, 1000]

PathC_name = strcat('Res', string(Res_max),'_Int', string(Int_min), '_std', string(std_max), ...
'_MaxDisp',string(maxDisplacement), '_rawth', string(raw_th), '/')

%expList = dir(strcat('Tracks/', PathC_name, '*-*'));
for i = 1:length(expList)

clear Nall N L

expName = expList(i).name
%expPath = ['.' filesep 'Tracks' filesep expName filesep];
if compute_spt == 1
ToSave = 1; ImagingInterval = 60;
trackingInCells = 1;
peaknbs = [peaknbs, sptFromPosListCoord05c_fastImaging_peak_details(fdir,expName,PathC_name,trackingInCells,...
    ImagingInterval, maxDisplacement, ToSave, Res_max, Int_min, std_max,  raw_th, filter_th)];
end
end
end
end
