function [ResultStruct] = CalculateNonLinearParametersFunc(ResultStruct,dataAccCut,WindowLen,FS,Lyap_m,Lyap_FitWinLen,Sen_m,Sen_r) %% Calculation non-linear parameters; % cut into windows of size WindowLen N_Windows = floor(size(dataAccCut,1)/WindowLen); N_SkipBegin = ceil((size(dataAccCut,1)-N_Windows*WindowLen)/2); LyapunovWolf = nan(N_Windows,3); LyapunovRosen = nan(N_Windows,3); SE= nan(N_Windows,3); for WinNr = 1:N_Windows; AccWin = dataAccCut(N_SkipBegin+(WinNr-1)*WindowLen+(1:WindowLen),:); for j=1:3 [LyapunovWolf(WinNr,j),~] = CalcMaxLyapWolfFixedEvolv(AccWin(:,j),FS,struct('m',Lyap_m)); [LyapunovRosen(WinNr,j),outpo] = CalcMaxLyapConvGait(AccWin(:,j),FS,struct('m',Lyap_m,'FitWinLen',Lyap_FitWinLen)); [SE(WinNr,j)] = funcSampleEntropy(AccWin(:,j), Sen_m, Sen_r); % no correction for FS; SE does increase with higher FS but effect is considered negligible as range is small (98-104HZ). Might consider updating r to account for larger ranges. end end LyapunovWolf = nanmean(LyapunovWolf,1); LyapunovRosen = nanmean(LyapunovRosen,1); SampleEntropy = nanmean(SE,1); ResultStruct.LyapunovWolf_V = LyapunovWolf(1); ResultStruct.LyapunovWolf_ML = LyapunovWolf(2); ResultStruct.LyapunovWolf_AP = LyapunovWolf(3); ResultStruct.LyapunovRosen_V = LyapunovRosen(1); ResultStruct.LyapunovRosen_ML = LyapunovRosen(2); ResultStruct.LyapunovRosen_AP = LyapunovRosen(3); ResultStruct.SampleEntropy_V = SampleEntropy(1); ResultStruct.SampleEntropy_ML = SampleEntropy(2); ResultStruct.SampleEntropy_AP = SampleEntropy(3); if isfield(ResultStruct,'StrideFrequency') LyapunovPerStrideWolf = LyapunovWolf/ResultStruct.StrideFrequency; LyapunovPerStrideRosen = LyapunovRosen/ResultStruct.StrideFrequency; end ResultStruct.LyapunovPerStrideWolf_V = LyapunovPerStrideWolf(1); ResultStruct.LyapunovPerStrideWolf_ML = LyapunovPerStrideWolf(2); ResultStruct.LyapunovPerStrideWolf_AP = LyapunovPerStrideWolf(3); ResultStruct.LyapunovPerStrideRosen_V = LyapunovPerStrideRosen(1); ResultStruct.LyapunovPerStrideRosen_ML = LyapunovPerStrideRosen(2); ResultStruct.LyapunovPerStrideRosen_AP = LyapunovPerStrideRosen(3); end