def gaussian_filter(data, sigma=4., truncate = 4., normalize=True, res_g=None):
    """
    blurs data with a gaussian kernel of given sigmas
    
    Parameters
    ----------
    data: ndarray
        2 or 3 dimensional array 
    sigma: scalar or tuple
        the sigma of the gaussian  
    truncate: float 
        truncate the kernel after truncate*sigma  
    normalize: bool
        uses a normalized kernel is true
    res_g: OCLArray
        used to store result if given  

    Returns
    -------
        blurred array 
    """

    if not len(data.shape) in [1, 2, 3]:
        raise ValueError("dim = %s not supported" % (len(data.shape)))

    if np.isscalar(sigma):
        sigma = [sigma] * data.ndim

    if any(tuple(s <= 0 for s in sigma)):
        raise ValueError("sigma = %s : all sigmas have to be positive!" % str(sigma))

    if isinstance(data, OCLArray):
        return _gaussian_buf(data, sigma, res_g, normalize=normalize,truncate = truncate)
    elif isinstance(data, np.ndarray):
        return _gaussian_np(data, sigma,  normalize=normalize,truncate = truncate)

    else:
        raise TypeError("unknown type (%s)" % (type(data)))