def test_plot_xcorr(): xc = C.xcorr_norm fig02 = plot_xcorr(xc, ((0, 1), (2, 3)), line_labels=['a', 'b'])
reload(nitime.viz) from nitime.viz import plot_xcorr #This part is the same as before TR=1.89 data_rec = csv2rec('data/fmri_timeseries.csv') roi_names= np.array(data_rec.dtype.names) n_samples = data_rec.shape[0] data = np.zeros((len(roi_names),n_samples)) for n_idx, roi in enumerate(roi_names): data[n_idx] = data_rec[roi] data = percent_change(data) T = UniformTimeSeries(data,sampling_interval=TR) T.metadata['roi'] = roi_names C = CorrelationAnalyzer(T) #Extract the cross-correlation: xc = C.xcorr_norm idx_lcau = np.where(roi_names=='lcau')[0] idx_rcau = np.where(roi_names=='rcau')[0] idx_lput = np.where(roi_names=='lput')[0] plot_xcorr(xc,((idx_lcau,idx_rcau),(idx_lcau,idx_lput)), line_labels = ['rcau','lput'])
object, which contains the full time-series of the cross-correlation between any combination of time-series from the different channels in the time-series object. We can pass the resulting object, together with a list of indices to the viz.plot_xcorr function, which visualizes the chosen combinations of series: """ xc = C.xcorr_norm idx_lcau = np.where(roi_names == 'LCau')[0] idx_rcau = np.where(roi_names == 'RCau')[0] idx_lput = np.where(roi_names == 'LPut')[0] idx_rput = np.where(roi_names == 'RPut')[0] fig02 = plot_xcorr(xc, ((idx_lcau, idx_rcau), (idx_lcau, idx_lput)), line_labels=['RCau', 'LPut']) """ .. image:: fig/resting_state_fmri_02.png Note that the correlation is normalized, so that the the value of the cross-correlation functions at the zero-lag point (time = 0 sec) is equal to the Pearson correlation between the two time-series. We observe that there are correlations larger than the zero-lag correlation occurring at other time-points preceding and following the zero-lag. This could arise because of a more complex interplay of activity between two areas, which is not captured by the correlation and can also arise because of differences in the characteristics of the HRF in the two ROIs. One method of analysis which can mitigate these issues is analysis of coherency between time-series [Sun2005]_. This analysis computes an equivalent of the correlation in the
def test_plot_xcorr(): xc = C.xcorr_norm fig02 = plot_xcorr(xc, ((0, 1), (2, 3)), line_labels=["a", "b"])
any combination of time-series from the different channels in the time-series object. We can pass the resulting object, together with a list of indices to the viz.plot_xcorr function, which visualizes the chosen combinations of series: """ xc = C.xcorr_norm idx_lcau = np.where(roi_names == 'LCau')[0] idx_rcau = np.where(roi_names == 'RCau')[0] idx_lput = np.where(roi_names == 'LPut')[0] idx_rput = np.where(roi_names == 'RPut')[0] fig02 = plot_xcorr(xc, ((idx_lcau, idx_rcau), (idx_lcau, idx_lput)), line_labels=['RCau', 'LPut']) """ .. image:: fig/resting_state_fmri_02.png Note that the correlation is normalized, so that the the value of the cross-correlation functions at the zero-lag point (time = 0 sec) is equal to the Pearson correlation between the two time-series. We observe that there are correlations larger than the zero-lag correlation occurring at other time-points preceding and following the zero-lag. This could arise because of a more complex interplay of activity between two areas, which is not captured by the correlation and can also arise because of differences in the characteristics of the HRF in the two ROIs. One method of analysis which can