Commit fdde367c authored by Andrew Quinn's avatar Andrew Quinn
Browse files

log_psd updates and glm-irasa fixes

parent 8e5b57d7
Loading
Loading
Loading
Loading
+10 −4
Original line number Diff line number Diff line
@@ -480,6 +480,8 @@ def _proc_spectrum_mode(pxx, mode, axis=-1):
        pxx = np.abs(pxx)
    elif mode == 'psd':
        pxx = (np.conjugate(pxx) * pxx).real
    elif mode == 'log_psd':
        pxx = np.log((np.conjugate(pxx) * pxx).real)
    elif mode in ['angle', 'phase']:
        pxx = np.angle(pxx)
        if mode == 'phase':
@@ -821,7 +823,7 @@ def _set_mode(mode):
        If non-valid mode is specified

    """
    modelist = ['psd', 'complex', 'magnitude', 'angle', 'phase']
    modelist = ['psd', 'log_psd', 'complex', 'magnitude', 'angle', 'phase']
    if mode not in modelist:
        raise ValueError("Invalid value ('{}') for mode, must be one of {}"
                         .format(mode, modelist))
@@ -1691,7 +1693,8 @@ def _glm_fit_glmtools(pxx, reg_categorical, reg_ztrans, reg_unitmax,
        DC.add_regressor(name='Constant', rtype='Constant')
    for key in reg_categorical.keys():
        logging.debug('Adding Condition : {0}'.format(key))
        DC.add_regressor(name=key, rtype='Categorical', datainfo=key, codes=[1])
        #DC.add_regressor(name=key, rtype='Categorical', datainfo=key, codes=[1])
        DC.add_regressor(name=key, rtype='Parametric', datainfo=key, preproc=None)
    for key in reg_ztrans.keys():
        logging.debug('Adding Covariate : {0}'.format(key))
        DC.add_regressor(name=key, rtype='Parametric', datainfo=key, preproc='z')
@@ -2194,7 +2197,10 @@ def glm_irasa(x,
    model.copes = model.copes - model_aperiodic.copes
    model.varcopes = model.varcopes - model_aperiodic.varcopes

    return model_aperiodic, model
    glmaper = GLMSpectrumResult(config.freqvals, model_aperiodic, des, data, config=config)
    glmosc = GLMSpectrumResult(config.freqvals, model, des, data, config=config)

    return glmaper, glmosc


def _irasa_core(x, up, down, config, return_unaveraged=False):
@@ -2250,7 +2256,7 @@ def _glm_irasa_core(x, up, down, config, return_unaveraged=False):
        _description_

    """
    y = signal.resample_poly(x, down, up, axis=config.axis)
    y = signal.resample_poly(x, up, down, axis=config.axis)

    rs_categorical = config.reg_categorical.copy()
    for key, val in config.reg_categorical.items():