def normalize(self, method='percentile', window=None, perc=20, offset=0.1):
        """
        Normalize by subtracting and dividing by a baseline.

        Baseline can be derived from a global mean or percentile,
        or a smoothed percentile estimated within a rolling window.
        Windowed baselines may only be well-defined for
        temporal series data.

        Parameters
        ----------
        baseline : str, optional, default = 'percentile'
            Quantity to use as the baseline, options are 'mean', 'percentile',
            'window', or 'window-exact'.

        window : int, optional, default = 6
            Size of window for baseline estimation,
            for 'window' and 'window-exact' baseline only.

        perc : int, optional, default = 20
            Percentile value to use, for 'percentile',
            'window', or 'window-exact' baseline only.

        offset : float, optional, default = 0.1
             Scalar added to baseline during division to avoid division by 0.
        """

        check_options(method, ['mean', 'percentile', 'window', 'window-exact'])

        from warnings import warn
        if not (method == 'window' or method == 'window-exact') and window is not None:
            warn('Setting window without using method "window" has no effect')

        if method == 'mean':
            baseFunc = mean

        if method == 'percentile':
            baseFunc = lambda x: percentile(x, perc)

        if method == 'window':
            from scipy.ndimage.filters import percentile_filter
            baseFunc = lambda x: percentile_filter(x.astype(float64), perc, window, mode='nearest')

        if method == 'window-exact':
            if window & 0x1:
                left, right = (ceil(window/2), ceil(window/2) + 1)
            else:
                left, right = (window/2, window/2)

            n = len(self.index)
            baseFunc = lambda x: asarray([percentile(x[max(ix-left, 0):min(ix+right+1, n)], perc)
                                          for ix in arange(0, n)])

        def get(y):
            b = baseFunc(y)
            return (y - b) / (b + offset)

        return self.map(get)
def normalize ( self , method = 'percentile' , window = None , perc = 20 , offset = 0.1 ) : check_options ( method , [ 'mean' , 'percentile' , 'window' , 'window-exact' ] ) from warnings import warn if not ( method == 'window' or method == 'window-exact' ) and window is not None : warn ( 'Setting window without using method "window" has no effect' ) if method == 'mean' : baseFunc = mean if method == 'percentile' : baseFunc = lambda x : percentile ( x , perc ) if method == 'window' : from scipy . ndimage . filters import percentile_filter baseFunc = lambda x : percentile_filter ( x . astype ( float64 ) , perc , window , mode = 'nearest' ) if method == 'window-exact' : if window & 0x1 : left , right = ( ceil ( window / 2 ) , ceil ( window / 2 ) + 1 ) else : left , right = ( window / 2 , window / 2 ) n = len ( self . index ) baseFunc = lambda x : asarray ( [ percentile ( x [ max ( ix - left , 0 ) : min ( ix + right + 1 , n ) ] , perc ) for ix in arange ( 0 , n ) ] ) def get ( y ) : b = baseFunc ( y ) return ( y - b ) / ( b + offset ) return self . map ( get )
Normalize by subtracting and dividing by a baseline.

        Baseline can be derived from a global mean or percentile,
        or a smoothed percentile estimated within a rolling window.
        Windowed baselines may only be well-defined for
        temporal series data.

        Parameters
        ----------
        baseline : str, optional, default = 'percentile'
            Quantity to use as the baseline, options are 'mean', 'percentile',
            'window', or 'window-exact'.

        window : int, optional, default = 6
            Size of window for baseline estimation,
            for 'window' and 'window-exact' baseline only.

        perc : int, optional, default = 20
            Percentile value to use, for 'percentile',
            'window', or 'window-exact' baseline only.

        offset : float, optional, default = 0.1
             Scalar added to baseline during division to avoid division by 0.