This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| """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() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # 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]"' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| for (std::vector<int>::const_iterator i = vecName.begin(); i != vecName.end(); ++i) | |
| std::cout << *i << std::endl; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import os | |
| file_names = os.listdir("file_path") | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| n_columns_ndarray = long_audio_vector.reshape((-1, num_of_channels)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ## Session Management | |
| Sessions are useful for completely separating work environments. I have a ‘Work’ session and a ‘Play’ session; in ‘Work’, I keep everything open that I need during my day-to-day development, while in ‘Play’, I keep open current open-source gems or other work I hack on at home. | |
| tmux new -s session_name | |
| creates a new tmux session named session_name | |
| tmux attach -t session_name | |
| attaches to an existing tmux session named session_name | |
| tmux switch -t session_name | |
| switches to an existing session named session_name |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import 'package:flutter/material.dart'; | |
| void main() => runApp(MaterialApp( | |
| home: MyApp(), | |
| )); | |
| class MyApp extends StatefulWidget { | |
| @override | |
| _MyAppState createState() => new _MyAppState(); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| a = np.arange(10) # (10, ) | |
| a.reshape(-1, 1) # (10, 1) |