function smoothField = maskedCollapseZSmoothing(field,mask)
    field = single(field);
    mask = single(mask);
    smoothField = zeros(size(field,1),size(field,2),size(field,4));
    st = single(zeros(size(field,1),size(field,2),6));
    ch = 1;
    for u = 1:size(field,4)
        for v = u:size(field,4)
            st(:,:,ch) = single(maskedCollapseZFilter(squeeze(field(:,:,:,u).*field(:,:,:,v)),mask));
            ch = ch+1;
        end
    end
    [~,~,~,U,V,W,~,~,~,~,~,~] = EigenVectors3D(squeeze(st(:,:,1)),squeeze(st(:,:,2)),squeeze(st(:,:,3)),...
                                                squeeze(st(:,:,4)),squeeze(st(:,:,5)),squeeze(st(:,:,6)));
    smoothField(:,:,1) = U;
    smoothField(:,:,2) = V;
    smoothField(:,:,3) = W;
end

