w6      !"#$%&'()*+,-./0123452(c) Alexander Vivian Hugh McPhail 2010, 2014, 2015BSD3+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 seed8(c) Alexander Vivian Hugh McPhail 2010, 2014, 2015, 2016BSD3+haskell.vivian.mcphail <at> gmail <dot> com provisionaluses FFINone 9:;DR6convert from Vector Double7filter a signal87the difference between consecutive elements of a vector9@unwrap the phase of signal (input expected to be within (-pi,pi):<evaluate a real coefficient polynomial for complex argumentsSconvolve two containers, output is the size of the second argument, no zero padding;filters the signal<filters the signal=NHilbert 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 windowA,determine the frequency response of a filterB<evaluate a real coefficient polynomial for complex argumentsC'the complex power : real $ v * (conj v)D'the complex power : real $ v * (conj v)E9resample, take one sample every n samples in the originalF9resample, take one sample every n samples in the originalG7the difference between consecutive elements of a vectorH7the difference between consecutive elements of a vectorI@unwrap the phase of signal (input expected to be within (-pi,pi)J@unwrap the phase of signal (input expected to be within (-pi,pi)K+compute the cross covariance of two signalsL+compute the cross covariance of two signalsE67MNO89:PQRSTUVWXYZ[\]^_`abcdefghijklmn;zero coefficientspole coefficients input signal output signal<zero coefficientspole coefficients input signal output signal=>window size (multiple of 2) input signalpower density ?lengththe Hamming coeffficents@lengththe Hamming coeffficentsAzero coefficientspole coefficientspoints (between 0 and 2*pi)responseoBthe real coefficients#the points at which to be evaluated the valuesCinputoutputDinputoutputEFGHIJKLpqrstuvw67MNO89:PQ=>A: 67MNO89:PQRSTUVWXYZ[\]^_`abcdefghijklmn;<=>?@AoBCDEFGHIJKLpqrstuvwk18(c) Alexander Vivian Hugh McPhail 2010, 2014, 2015, 2016BSD3+haskell.vivian.mcphail <at> gmail <dot> com provisionaluses FFINone :DRfilters 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 x .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 coefficientsyz{|}~ 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     x yz{|}~ 8(c) Alexander Vivian Hugh McPhail 2010, 2014, 2015, 2016BSD3+haskell.vivian.mcphail <at> gmail <dot> com provisionaluses ConcurrencyNone  9:;DRT data type with multiple channels sampling ratebits of precisionnumber of channelslength in sampleswas 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)"  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 data1234 !"#$%&'()*+,-./0 !"#$()%&'*+,-./0 !"#$%&'()*+,-./012343(c) Alexander Vivian Hugh McPhail 2010, 2014, 2015 BSD3 ,haskell.vivian.mcphail <at> gmail <dot> com  provisional EEG BDF data file functions None =BDF datatype. NOTE: data has already been converted to FloatKLoad a BDF data structure NOTE: data has already been converted to Float3555-(c) Alexander Vivian Hugh McPhail 2010, 2014 BSD3 ,haskell.vivian.mcphail <at> gmail <dot> com  provisional EEG functions None 55      !"#$%&'()*+,-./01 23456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~*+&hsignal-0.2.7.5-HU3hFFChbIM9sIcaf5HkwvNumeric.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_phase$fBinaryMultichannel$fBinaryMultichannel0$fBinaryMultichannel1$fBinaryMultichannel2loadBDF 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_convolve#convolve_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_datamapArrayConcurrentlymapMCMCBDF 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