To rename a tab where you are : $psise.CurrentPowerShellTab.DisplayName = 'Dev'
To rename a remote tab, you need to do that from a local one (where the first tab is [0] ): $psise.PowerShellTabs[1].DisplayName = 'Remote-Server01'
| def dbfft(x, fs, win=None, ref=32768): | |
| """ | |
| Calculate spectrum in dB scale | |
| Args: | |
| x: input signal | |
| fs: sampling frequency | |
| win: vector containing window samples (same length as x). | |
| If not provided, then rectangular window is used by default. | |
| ref: reference value used for dBFS scale. 32768 for int16 and 1 for float |
| def within_subject_errorbar(df, ci_r = 1.96): | |
| df["Subject average"] = df.mean(axis = 1) | |
| df_grand_avg = df["Subject average"].mean() | |
| df["New condition1"] = df["condition1"] - df["Subject average"] + df_grand_avg | |
| df["New condition2"] = df["condition2"] - df["Subject average"] + df_grand_avg | |
| std_vo, std_me = df["New condition1"].std(), df["New condition2"].std() |
| # This code covert formant bandwidth to q | |
| import sys | |
| f0 = map(float, sys.argv[1].strip('[]').split(',')) | |
| bw = map(float, sys.argv[2].strip('[]').split(',')) | |
| q = [] | |
| if (not len(f0)==len(bw)): | |
| print "Error: Two arguments need to have the same lenght. " | |
| print 'Usage: First argument list of fundamental frequency, e.g "[19, 299, 449]"' |
| """To get a new array by subsetting columns of different np.ndarray""" | |
| a = np.array([[1,2],[3,4],[5,6]]) | |
| b = np.array([[10,20],[30,40],[50,60]]) | |
| # Using zip | |
| [(a_s[0], b_s[0]) for a_s, b_s in zip(a,b)] | |
| # A faster way is to concat and ravel, use ('float, float') if float number. | |
| np.c_[a[:,0],b[:,0]].view('i,i').ravel() |
| """1: Peak Detection""" | |
| def envfol_peak_detection(sig, sr, chunk=4, order=6, lpfreq=150): | |
| """Envelope follower based on peak detection""" | |
| s = sig.shape[0] // chunk | |
| new_sig = np.array_split(np.abs(sig), s) | |
| result = [] | |
| for i in new_sig: | |
| result.append(np.max(i)) | |
| result = np.array(result) |
| def mse(imageA, imageB): | |
| # the 'Mean Squared Error' between the two images is the | |
| # sum of the squared difference between the two images; | |
| # NOTE: the two images must have the same dimension | |
| err = np.sum((imageA - imageB) ** 2) | |
| err /= float(imageA.shape[0] * imageA.shape[1]) | |
| # return the MSE, the lower the error, the more "similar" | |
| # the two images are | |
| return err |
To rename a tab where you are : $psise.CurrentPowerShellTab.DisplayName = 'Dev'
To rename a remote tab, you need to do that from a local one (where the first tab is [0] ): $psise.PowerShellTabs[1].DisplayName = 'Remote-Server01'
| from PyQt5.QtGui import QPainter, QPen, QFont | |
| from PyQt5.QtWidgets import QAbstractButton, QSlider, QWidget, QVBoxLayout, QHBoxLayout,\ | |
| QStyleOptionSlider, QStyle | |
| from PyQt5.QtCore import Qt, QRect, QPoint | |
| import numpy as np | |
| class LabeledSlider(QWidget): | |
| def __init__(self, minimum, maximum, interval=1, orientation=Qt.Horizontal, | |
| labels=None, p0=0, parent=None): |
| def get_all_data(fp): | |
| l = os.listdir(fp) | |
| try: l.remove(".DS_Store") | |
| except: pass | |
| for i, fname in enumerate(l): | |
| temp_df = pd.read_csv(fp + fname) | |
| if (i == 0): | |
| r = temp_df | |
| else: | |
| r = r.append(temp_df) |
| import time | |
| def timeit(method): | |
| def timed(*args, **kw): | |
| ts = time.time() | |
| result = method(*args, **kw) | |
| te = time.time() | |
| if 'log_time' in kw: | |
| name = kw.get('log_name', method.__name__.upper()) | |
| kw['log_time'][name] = int((te - ts) * 1000) |