Towards Frequency Domain Analysis and Phase Synchronization
This week we have been discussing further about the possibility of developing some frequency analysis tools to integrate in the package. Although CPAC already has some tools to work on the frequency domain, we are thinking in building up some valuable scripts that allow us to capture information using the frequency domain. Our intention is to develop measures such Phase Synchronization and identification of patterns based on frequency domain analysis, to be used as features for Fingerprint analysis. Specifically, as starting point, we are going to take as guide and example the methods described in the paper by Ponce et al. [1], with the intention of performing a similar analysis over fMRI. Our goal is to do so and extending them with measures like temporal power spectral density (PSDT).
Phase synchronization analysis
This kind of analysis needs of the extraction ef the phases of the fMRI timeseries. We can obtain the analytical signals using the Hilbert transform. This analytic signal represents a signal in the time domain as a rotating vector with an instantaneous phase, phi(t), and amplitude.
The global level of phase synchrony is given by the parameter R(t), taking values in the [0,1] range (being 0 completely asynchroneous and 1 completely synchronized, respectively):
For quantifying the pairwise phase relation between two given brain regions (timeseries) k and l, Phase-Locking Value (PLV) has to be calculated as:
Last week, I already deveveloped a simple filter and this week I have been practicing further with the numpy.signal package. Some example of code, partially changed from this excellent tutorial. Under each block of code, I have plotted an example over fMRI data (it is clear that the used data has been already preprocessed and filtered):
1234567891011121314151617
fromnumpyimport*fromscipyimport*# not a good practice, but just for the examples# Power Spectra calculation# construct signalt=linspace(0,1,1001)y=sin(2*pi*t*6)+sin(2*pi*t*10)+sin(2*pi*t*13)# compute FFT and the magnitude spectrumF=fft.fft(y)N=len(t)# number of samplesdt=0.001# inter-sample time differencew=fft.fftfreq(N,dt)# gives us a list of frequencies for the FFTipos=where(w>0)freqs=w[ipos]# only look at positive frequenciesmags=abs(F[ipos])# magnitude spectrumphase=imag(F[ipos])# phase component
1234567891011121314151617
# Inverse Fast Fourier transform (IFFT) (reconstruction from freq domain)# construct signalt=linspace(0,1,1001)y=sin(2*pi*t*6)+sin(2*pi*t*10)+sin(2*pi*t*13)# compute FFT and the magnitude spectrumF=fft.fft(y)N=len(t)# number of samplesdt=0.001# inter-sample time differencew=fft.fftfreq(N,dt)# gives us a list of frequencies for the FFTipos=where(w>0)freqs=w[ipos]# only look at positive frequenciesmags=abs(F[ipos])# magnitude componentphase=imag(F[ipos])# phase component# inverseyr=fft.ifft(F)
12345678910111213141516171819202122232425262728
## Filtering# construct signal t=linspace(0,1,1001)y=sin(2*pi*t*6)+sin(2*pi*t*10)+sin(2*pi*t*13)# compute FFT and the magnitude spectrumF=fft.fft(y)N=len(t)# number of samplesdt=0.001# inter-sample time differencew=fft.fftfreq(N,dt)# gives us a list of frequencies for the FFTipos=where(w>0)freqs=w[ipos]# only look at positive frequenciesmags=abs(F[ipos])# magnitude componentphase=imag(F[ipos])# phase componentip=where(F>5)[0]# find peaks in FFTFs=copy(F)# make a copy of the signal FFTFs[ip[[2,3]]]=0# set peaks corresponding to yf=fft.ifft(Fs)# reconstructip=where(F>5)[0]# find peaks in FFTFf=copy(F)# make a copy of the signal FFTFf[ip[[1,2,3,4]]]=0# set 10Hz and 13Hz peaks to zeromagsf=abs(Ff[ipos])# magnitude componentphasef=imag(Ff[ipos])# phase componentyf=fft.ifft(Ff)# reconstructyr=fft.ifft(F)