Helper function to reject outliers based on mean amplitude

def _rm_outlier_by_amp(self, params, model, signal, ii):
        """
        Helper function to reject outliers based on mean amplitude
        """
        maxamps = np.nanmax(np.abs(model),0)
        z_score = (maxamps - np.nanmean(maxamps,0))/np.nanstd(maxamps,0)
        with warnings.catch_warnings():
            warnings.simplefilter("ignore")
            outlier_idx = np.where(np.abs(z_score)>2.0)[0]
            nan_idx = np.where(np.isnan(params))[0]
            outlier_idx = np.unique(np.hstack([nan_idx, outlier_idx]))
            ii[outlier_idx] = 0
            model[outlier_idx] = np.nan
            signal[outlier_idx] = np.nan
            params[outlier_idx] = np.nan

        return model, signal, params, ii