Merge branch 'master' of github.com:Pezz89/BPLabs
This commit is contained in:
@@ -49,7 +49,7 @@ plt.semilogy(f, Pxx_den)
|
||||
f, Pxx_den = signal.welch(da_x[:, 1], da_fs, nperseg=1024)
|
||||
plt.semilogy(f, Pxx_den)
|
||||
plt.xlabel('frequency [Hz]')
|
||||
plt.ylabel('PSD [V**2/Hz]')
|
||||
plt.ylabel('PSD [I**2/Hz]')
|
||||
plt.xlim([0, 10000])
|
||||
plt.legend(['Pink noise', 'Speech shaped noise', 'Da'])
|
||||
plt.savefig('./test.png')
|
||||
|
||||
Executable
+55
@@ -0,0 +1,55 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
import dill
|
||||
import numpy as np
|
||||
import argparse
|
||||
from pathtype import PathType
|
||||
import sys
|
||||
import os
|
||||
from loggerops import create_logger
|
||||
|
||||
def main(args):
|
||||
file = args.data_file
|
||||
with open(file, 'rb') as pkl:
|
||||
a = dill.load(pkl)
|
||||
del a['participant']
|
||||
np.save(os.path.basename(file)+'-new.npy', a)
|
||||
|
||||
if __name__ == '__main__':
|
||||
#peak_pick_test()
|
||||
parser = argparse.ArgumentParser(
|
||||
description='Script for removing BPLabs sepcific objects from participant data'
|
||||
)
|
||||
parser.add_argument(
|
||||
dest='data_file', type=PathType(),
|
||||
help='Configuration file for processing BDF', metavar='CONFIGFILE'
|
||||
)
|
||||
parser.add_argument(
|
||||
'--verbose',
|
||||
'-v',
|
||||
action='count',
|
||||
help='Specifies level of verbosity in output. For example: \'-vvvvv\' '
|
||||
'will output all information. \'-v\' will output minimal information. '
|
||||
)
|
||||
args = parser.parse_args()
|
||||
|
||||
# Set verbosity of logger output based on argument
|
||||
if not args.verbose:
|
||||
args.verbose = 10
|
||||
else:
|
||||
levels = [50, 40, 30, 20, 10]
|
||||
if args.verbose > 5:
|
||||
args.verbose = 5
|
||||
args.verbose -= 1
|
||||
args.verbose = levels[args.verbose]
|
||||
|
||||
# Define path to module for storing log files
|
||||
modpath = sys.argv[0]
|
||||
modpath = os.path.splitext(modpath)[0]+'.log'
|
||||
|
||||
logger = create_logger(
|
||||
logger_streamlevel=args.verbose,
|
||||
log_filename=modpath,
|
||||
logger_filelevel=args.verbose
|
||||
)
|
||||
main(args)
|
||||
@@ -1,8 +1,8 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
import sys
|
||||
sys.path.insert(0, "../helper_modules")
|
||||
sys.path.insert(0, "../matrix_test/helper_modules/")
|
||||
#sys.path.insert(0, "../helper_modules")
|
||||
#sys.path.insert(0, "../matrix_test/helper_modules/")
|
||||
|
||||
import argparse
|
||||
import os
|
||||
@@ -18,25 +18,15 @@ from pysndfile import PySndfile, sndio
|
||||
import matplotlib.pyplot as plt
|
||||
|
||||
from pathops import dir_must_exist
|
||||
try:
|
||||
from signalops import rolling_window_lastaxis, calc_rms, block_process_wav
|
||||
except ImportError:
|
||||
from .signalops import rolling_window_lastaxis, block_lfilter, calc_rms, block_process_wav
|
||||
from signalops import rolling_window_lastaxis, block_lfilter, calc_rms, block_process_wav
|
||||
|
||||
import scipy.signal as sgnl
|
||||
from scipy.stats import pearsonr
|
||||
|
||||
from pyswarm import pso
|
||||
|
||||
try:
|
||||
from lpc import lpc
|
||||
except ImportError:
|
||||
from .lpc import lpc
|
||||
from lpc import lpc
|
||||
|
||||
try:
|
||||
from filesystem import globDir, organiseWavs, prepareOutDir
|
||||
except ImportError:
|
||||
from .filesystem import globDir, organiseWavs, prepareOutDir
|
||||
from filesystem import globDir, organiseWavs, prepareOutDir
|
||||
|
||||
|
||||
def block_lfilter_wav(b, a, x, outfile, fmt, fs, blocksize=8192):
|
||||
@@ -204,7 +194,7 @@ def calc_spectrum(files, silences, fs=44100, plot=False):
|
||||
def gen_noise(OutDir, b, fs, s_rms):
|
||||
print("Generating noise...")
|
||||
# Generate 10 minutes of white noise
|
||||
x = np.random.randn(int(fs*60.*20.))
|
||||
x = np.random.randn(int(fs*60.*5.))
|
||||
x /= x.max()
|
||||
noiseDir = os.path.join(OutDir, 'wav')
|
||||
noiseRMSDir = os.path.join(OutDir, 'rms')
|
||||
@@ -212,7 +202,7 @@ def gen_noise(OutDir, b, fs, s_rms):
|
||||
noiseDir = os.path.join(noiseDir, 'noise')
|
||||
dir_must_exist(noiseDir)
|
||||
y, y_max = block_lfilter_wav(b, [1.0], x, os.path.join(noiseDir, 'noise.wav'), 65538, 44100)
|
||||
block_process_wav(os.path.join(noiseDir, 'noise.wav'), os.path.join(noiseDir, 'noise_norm.wav'), lambda x: x / (y_max * 0.95))
|
||||
block_process_wav(os.path.join(noiseDir, 'noise.wav'), os.path.join(noiseDir, 'noise_norm.wav'), lambda x: x / (y_max * 1.05))
|
||||
noise_rms_path = os.path.join(noiseRMSDir, 'noise_rms.npy')
|
||||
y = y/(np.abs(y).max() * 0.95)
|
||||
rms = np.sqrt(np.mean(y**2))
|
||||
|
||||
@@ -45,7 +45,6 @@ def gen_indexes(list_dir, speech_dir):
|
||||
component_map = json.loads(json_data)
|
||||
|
||||
column_names = ['a', 'b', 'c', 'd', 'e']
|
||||
list_indexes = np.array([])
|
||||
sentence_lists = {}
|
||||
for list_file in list_files:
|
||||
with open(list_file, 'r') as lfile:
|
||||
|
||||
Reference in New Issue
Block a user