Beispiel #1
0
    def upsample(self, target, target_type='hz', **kwargs):
        """ Upsample Fex columns. Relies on nltools.stats.upsample,
            but ensures that returned object is a Fex object.

        Args:
            target(float): upsampling target, default 'hz' (also 'samples',
                           'seconds')
            kwargs: additional inputs to nltools.stats.upsample

        """

        df_us = upsample(self,
                         sampling_freq=self.sampling_freq,
                         target=target,
                         target_type=target_type,
                         **kwargs)
        if self.features is not None:
            us_features = upsample(self.features,
                                   sampling_freq=self.sampling_freq,
                                   target=target,
                                   target_type=target_type,
                                   **kwargs)
        else:
            us_features = self.features
        return self.__class__(df_us,
                              sampling_freq=target,
                              features=us_features)
def test_upsample():
    dat = pd.DataFrame()
    dat["x"] = range(0, 100)
    dat["y"] = np.repeat(range(1, 11), 10)
    fs = 2
    us = upsample(dat, sampling_freq=1, target=fs, target_type="hz")
    assert dat.shape[0] * fs - fs == us.shape[0]
    fs = 3
    us = upsample(dat, sampling_freq=1, target=fs, target_type="hz")
    assert dat.shape[0] * fs - fs == us.shape[0]
Beispiel #3
0
def test_upsample():
    dat = pd.DataFrame()
    dat['x'] = range(0, 100)
    dat['y'] = np.repeat(range(1, 11), 10)
    fs = 2
    us = upsample(dat, sampling_freq=1, target=fs, target_type='hz')
    assert (dat.shape[0] * fs - fs == us.shape[0])
    fs = 3
    us = upsample(dat, sampling_freq=1, target=fs, target_type='hz')
    assert (dat.shape[0] * fs - fs == us.shape[0])
Beispiel #4
0
    def upsample(self, target, **kwargs):
        """Upsample columns of design matrix. Relies on
            nltools.stats.upsample, but ensures that returned object is a
            design matrix.

        Args:
            target(float): desired frequence in hz
            kwargs: additional inputs to nltools.stats.downsample

        """
        if target < self.sampling_freq:
            raise ValueError(
                "Target must be shorter than current sampling rate")

        df = Design_Matrix(
            upsample(self,
                     sampling_freq=self.sampling_freq,
                     target=target,
                     target_type='hz',
                     **kwargs))

        # convert df to a design matrix
        newMat = self._inherit_attributes(df)
        newMat.sampling_freq = target
        return newMat