function [slice]  = mysmooth(slice,isslice)
%input slice nxnxtc, indicator of slice voxels isslice nxn
%output slice without large trend nxnxtc
%ind=0;%@

n = size(slice,1);
tc = size(slice,3);
myspan = round(2/3*tc);
if mod(myspan,2)==0
    myspan = myspan+1;
end

a=[tc:-1:1 1:tc tc:-1:1];
for i=1:n
    for j=1:n
        if isslice(i,j)==1
%ind = ind+1 %@            
            temp = squeeze(slice(i,j,:));
            rtemp = temp(a);
            ttemp = smooth(rtemp,myspan,'rloess',2);%only 2 iterations of robust lowess!
            ttemp = ttemp(tc+1:2*tc);
            slice(i,j,:) = temp-ttemp;
           slice(i,j,:) = slice(i,j,:) - mean(slice(i,j,:)) ; %NOT NECESSARY? CORRECT remove trimmed mean
        end
    end
end
% mean(slice(i,j,:)) 
% subplot(3,1,1); plot(temp)
% subplot(3,1,2);plot(ttemp)
% subplot(3,1,3);plot(temp-ttemp)
