Ambra Ferrari - 2018-08-01

Hello,

while running median filtering via pspm_pp I have noticed that it may create an artefact at the beginning of the timecourse. Together with a colleague of mine, we have replaced the line

data{k}.data = medfilt1(data{k}.data, n);

with the following:

    % Sim wind
    wind=n/2;
    % Init clean data
    clean_data=data{k}.data;
    % Filter
    for i=wind+1:length(data{k}.data)-wind
        clean_data(i)=median(data{k}.data(i-wind:i+wind));
    end
    % Burn-in window
    cnt=1;
    for i=wind:-1:1
        start=wind-cnt;
        stop=wind+cnt;
        clean_data(i)=median(data{k}.data(i-start:i+stop));
        cnt=cnt+1;
    end
    % Burn-out window
    cnt=1;
    for i=length(data{k}.data)-wind+1:length(data{k}.data)
        start=wind+cnt;
        stop=wind-cnt;
        clean_data(i)=median(data{k}.data(i-start:i+stop));
        cnt=cnt+1;
    end           
    data{k}.data = clean_data;
 

Last edit: Ambra Ferrari 2018-08-01