def calc_signal_power(params):
for i, data_type in enumerate(['<STR_LIT>','<STR_LIT>','<STR_LIT>', '<STR_LIT>']):<EOL><INDENT>if i % SIZE == RANK:<EOL><INDENT>if data_type in ['<STR_LIT>','<STR_LIT>']:<EOL><INDENT>fname=os.path.join(params.savefolder, data_type+'<STR_LIT>')<EOL><DEDENT>else:<EOL><INDENT>fname=os.path.join(params.populations_path, '<STR_LIT>',<EOL>str.split(data_type,'<STR_LIT:_>')[<NUM_LIT:0>] + '<STR_LIT>' +<EOL>str.split(data_type,'<STR_LIT:_>')[<NUM_LIT:1>] + '<STR_LIT:_>' +<EOL>str.split(data_type,'<STR_LIT:_>')[<NUM_LIT:2>] + '<STR_LIT>')<EOL><DEDENT>f = h5py.File(fname)<EOL>data = f['<STR_LIT:data>'].value<EOL>srate = f['<STR_LIT>'].value <EOL>tvec = np.arange(data.shape[<NUM_LIT:1>]) * <NUM_LIT> / srate<EOL>slica = (tvec >= ana_params.transient)<EOL>data = data[:,slica]<EOL>dataT = data.T - data.mean(axis=<NUM_LIT:1>)<EOL>data = dataT.T<EOL>f.close()<EOL>PSD=[]<EOL>for i in np.arange(len(params.electrodeParams['<STR_LIT:z>'])):<EOL><INDENT>if ana_params.mlab:<EOL><INDENT>Pxx, freqs=plt.mlab.psd(data[i], NFFT=ana_params.NFFT,<EOL>Fs=srate, noverlap=ana_params.noverlap,<EOL>window=ana_params.window)<EOL><DEDENT>else:<EOL><INDENT>[freqs, Pxx] = hlp.powerspec([data[i]], tbin= <NUM_LIT:1.>,<EOL>Df=ana_params.Df, pointProcess=False)<EOL>mask = np.where(freqs >= <NUM_LIT:0.>)<EOL>freqs = freqs[mask]<EOL>Pxx = Pxx.flatten()<EOL>Pxx = Pxx[mask]<EOL>Pxx = Pxx/tvec[tvec >= ana_params.transient].size**<NUM_LIT:2><EOL><DEDENT>PSD +=[Pxx.flatten()]<EOL><DEDENT>PSD=np.array(PSD)<EOL>f = h5py.File(os.path.join(params.savefolder, ana_params.analysis_folder,<EOL>data_type + ana_params.fname_psd),'<STR_LIT:w>')<EOL>f['<STR_LIT>']=freqs<EOL>f['<STR_LIT>']=PSD<EOL>f['<STR_LIT>']=ana_params.transient<EOL>f['<STR_LIT>']=ana_params.mlab<EOL>f['<STR_LIT>']=ana_params.NFFT<EOL>f['<STR_LIT>']=ana_params.noverlap<EOL>f['<STR_LIT>']=str(ana_params.window)<EOL>f['<STR_LIT>']=str(ana_params.Df)<EOL>f.close()<EOL><DEDENT><DEDENT>return<EOL>
calculates power spectrum of sum signal for all channels