}12      !"#$%&'()*+,-./01,(c) Alexander Vivian Hugh McPhail 2010, 2014BSD3+haskell.vivian.mcphail <at> gmail <dot> com provisionaluses ConcurrencyNone The method is briefly descirbed in Lennon, J.L. "Red-shifts and red herrings in geographical ecology", Ecography, Vol. 23, p101-113 (2000)MMatlab version Written by Jon Yearsley 1 May 2004 j.yearsley@macaulay.ac.uk)Creates 1/f scale invariant spatial noise1/f scale invariant noise$generate noise from a power spectrumS: spectral distribution 0: White noise -1: Pink noise -2: Brownian noisematrix dimensions random seedY: spectral distribution 0: White noise -1: Pink noise -2: Brownian (red) noisesamples random seedthe power spectrum random seed,(c) Alexander Vivian Hugh McPhail 2010, 2014BSD3+haskell.vivian.mcphail <at> gmail <dot> com provisionaluses FFINone 234=K2conver from Vector Double3filter a signal47the difference between consecutive elements of a vector5@unwrap the phase of signal (input expected to be within (-pi,pi)6<evaluate a real coefficient polynomial for complex argumentsSconvolve two containers, output is the size of the second argument, no zero padding7filters the signal8filters the signal9NHilbert transform with original vector as real value, transformed as imaginary:@Welch (1967) power spectrum density using periodogram/FFT method; coefficients of a Hamming window< coefficients of a Hamming window=,determine the frequency response of a filter><evaluate a real coefficient polynomial for complex arguments?'the complex power : real $ v * (conj v)@'the complex power : real $ v * (conj v)A9resample, take one sample every n samples in the originalB9resample, take one sample every n samples in the originalC7the difference between consecutive elements of a vectorD7the difference between consecutive elements of a vectorE@unwrap the phase of signal (input expected to be within (-pi,pi)F@unwrap the phase of signal (input expected to be within (-pi,pi)G+compute the cross covariance of two signalsH+compute the cross covariance of two signalsD23zero coefficientspole coefficients input signal1output signal | coefficients of a Hamming windowIlengthCthe Hamming coeffficents | the complex power : real $ v * (conj v)JinputCoutput | resample, take one sample every n samples in the originalK456the real coefficients#the points at which to be evaluated1the values | the cross covariance of two signalsL maximum delay time series time series>(sd_x,sd_y,cross_covariance) | the cumulative sum of a signalM time seriesresultNOPQRSTUVWXYZ[\]^_`abcdefghi7zero coefficientspole coefficients input signal output signal8zero coefficientspole coefficients input signal output signal9:window size (multiple of 2) input signalpower density ;lengththe Hamming coeffficents<lengththe Hamming coeffficents=zero coefficientspole coefficientspoints (between 0 and 2*pi)responsej>the real coefficients#the points at which to be evaluated the values?inputoutput@inputoutputABCDEFGHklmnopqr23IJK456LM9:=9 23IJK456LMNOPQRSTUVWXYZ[\]^_`abcdefghi789:;<=j>?@ABCDEFGHklmnopqr,(c) Alexander Vivian Hugh McPhail 2010, 2014BSD3+haskell.vivian.mcphail <at> gmail <dot> com provisionaluses FFINone 3=Kfilters the signal@Welch (1967) power spectrum density using periodogram/FFT methoda broadband FIR a broadband filter qstandard FIR filter | FIR filter with grid a power of 2 greater than the order, ramp = grid/16, hamming window produce an FIR filter Kdetermine the frequency response of a filter, given a vector of frequencies Xdetermine the frequency response of a filter, given a number of points and sampling rate`an analytic signal is the original signal with Hilbert-transformed signal as imaginary component<the power (amplitude^2 = v * (conj c)) of an analytic signalthe phase of an analytic signalremove a linear trend from data+resize the vector to length n by resamplingcross covariance of two signals the cross correlation is computed by dividing the result by the product of the two standard deviations cross correlation of two signalscompute the cross spectrumpauto covariance of two signals the auto correlation is computed by dividing the result by the varianceauto correlation of two signals coefficients of a Hamming window9resample, take one sample every n samples in the original7the difference between consecutive elements of a vectorcumulative sum of a seriesAunwrap the phase of signal (input expected to be within (-pi,pi))zero coefficientspole coefficients sampling rate input signal output signal sampling rate window size input signal!(frequency index,power density)  sampling rate(lower,upper) frequency cutofffilter coefficients  sampling rate(lower,upper) frequency cutoff input signal output signal s .order (one less than the length of the filter)Rband edge frequency, nondecreasing, [0, f1, ..., f(n-1), 1] ^ band edge magnitude grid spacingtransition width$smoothing window (size is order + 1)the filter coefficientstuvwxy zero coefficientspole coefficientssampling rate  frequenciesfrequency response zero coefficientspole coefficients sampling ratenumber of points(frequencies,response) window sizedata to be detrendeddetrended data maximum delay time series time series(sd_x,sd_y,cov_xy) maximum delay time series time seriesresult maximum delay time series time seriesresult maximum delay time series (var,cov_xx) maximum delay time seriesresultlengththe Hamming coeffficents     s tuvwxy ,(c) Alexander Vivian Hugh McPhail 2010, 2014BSD3+haskell.vivian.mcphail <at> gmail <dot> com provisionaluses ConcurrencyNone  234=KM data type with multiple channelsz sampling rate{bits of precision|number of channels}length in samples~was the data detrended?if filtered the passbanddata create a multichannel data type!the sampling rate"the bits of precision#the number of channels$the length, in samples%extract one channel&extract all channels'2convert the data to a matrix with channels as rows(was the data detrended?)was the data filtered?$map a function executed concurrently*$map a function executed concurrentlymap a function+-detrend the data with a specified window size,'filter the data with the given passband-extract a slice of the data.calculate histograms/dcalculate the entropy of the phase difference between pairs of channels (fills upper half of matrix)0dcalculate the mutual information of the phase between pairs of channels (fills upper half of matrix)"z{|}~  sampling ratebits of precisiondatadatatype!"#$%&'()function to mapinputoutput*the function to be mapped  input data output datathe function to be mapped  input data output data+,-starting sample numberlength.bins and ranges/ input data0 input data !"#$%&'()*+,-./0 !"#$()%&'*+,-./0z{|}~ !"#$%&'()*+,-./0-(c) Alexander Vivian Hugh McPhail 2010, 2014 BSD3 ,haskell.vivian.mcphail <at> gmail <dot> com  provisional EEG BDF data file functions None >BDF datatype. NOTE: data has already been converted to Float MLoad a BDF data structure NOTE: data has already been converted to Float 3111-(c) Alexander Vivian Hugh McPhail 2010, 2014 BSD3 ,haskell.vivian.mcphail <at> gmail <dot> com  provisional EEG functions None 11      !"#$%&'()*+,-./01 23456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~*+ hsignal-0.2.7Numeric.Signal.NoiseNumeric.SignalNumeric.Signal.MultichannelNumeric.Signal.EEGNumeric.Signal.InternalNumeric.Signal.EEG.BDF spatialNoise pinkNoise powerNoise Filterable Convolvableconvolvefilterpwelch broadband_firbroadband_filter standard_firfirfreqzFfreqzNanalytic_signalanalytic_poweranalytic_phasedetrendresizecross_covariancecross_correlationcross_spectrumauto_covarianceauto_correlationhamming downsamplederivcumulative_sumunwrap MultichannelreadMultichannelwriteMultichannelcreateMultichannel sampling_rate precisionchannelssamples getChannel getChannelstoMatrix detrendedfilteredmapConcurrentlyslice histogramsentropy_delta_phasemi_phaseloadBDF fromDoublefilter_deriv_unwrap_ polyEval_filterDfilterFhilberthammingDhammingFfreqzpolyEvalcomplex_powerDcomplex_powerF downsampleD downsampleFderivDderivFunwrapDunwrapFcrossCovarianceDcrossCovarianceFhamming_complex_power_ downsample_cross_covariance_cumulative_sum_PFPCPDsignal_cum_sum_floatsignal_cum_sum_doublesignal_cross_covariance_floatsignal_cross_covariance_doublesignal_unwrap_floatsignal_unwrap_doublesignal_diff_floatsignal_diff_doublesignal_downsample_floatsignal_downsample_doublesignal_complex_power_floatsignal_complex_power_doublesignal_real_poly_complex_evalsignal_hamming_floatsignal_hamming_double signal_pwelchsignal_hilbertsignal_filter_floatsignal_filter_doublesignal_vector_complex_convolvesignal_vector_float_convolvesignal_vector_double_convolveconvolve_vector_doubleconvolve_vector_floatconvolve_vector_complexpostpadcumSumDcumSumF$fFilterableFloat$fFilterableDouble$fConvolvableVector$fConvolvableVector0$fConvolvableVector1$fConvolvableVector2 calc_grid floor_zeroceil_onediff interpolate interpolate' interpolate''_sampling_rate _precision _channels_length _detrended _filtered_datamapArrayConcurrentlymapMCMC$fBinaryMultichannel$fBinaryMultichannel0$fBinaryMultichannel1$fBinaryMultichannel2BDF loadBDFRawid_type_subject recordingdatetime head_bytes data_version num_recordsduration chan_labels tran_type dimensionsphys_minphys_maxdig_mindig_max prefilterreserveddata_TimehourminutesecondDatedaymonthyearBSMgetN getStringgetIntgetDate strToDate'getTime strToTime' reverseBitsget24Bit readRecordreadRecordBlockconvertreadDatareadBDF