def compute_fcd(con, bold_data,parameter_monitor,wind_len=180e3,wind_sp=4e3): bold_period = parameter_monitor['parameter_Bold']['period'] # Build the time series object tsr = TimeSeriesRegion(connectivity=con, data=bold_data, sample_period=bold_period) tsr.configure() # Create and evaluate the analysis fcd_analyser = fcd.FcdCalculator(time_series=tsr, sw=wind_len, sp=wind_sp) fcd_data = fcd_analyser.evaluate() # Store the results FCD=fcd_data[0][:,:,0,0] return FCD
def compute_fc(con, bold_data, parameter_monitor): import tvb.analyzers.correlation_coefficient as corr_coeff from tvb.datatypes.time_series import TimeSeriesRegion bold_period = parameter_monitor['parameter_Bold']['period'] # Remove transient bold_data = bold_data[10:, :, :] tsr = TimeSeriesRegion(connectivity=con, data=bold_data, sample_period=bold_period) tsr.configure() # Compute FC corrcoeff_analyser = corr_coeff.CorrelationCoefficient(time_series=tsr) corrcoeff_data = corrcoeff_analyser.evaluate() corrcoeff_data.configure() FC = corrcoeff_data.array_data[..., 0, 0] return FC
LOG.info("Finished simulation.") ##----------------------------------------------------------------------------## ##- Plot pretty pictures of what we just did -## ##----------------------------------------------------------------------------## #Make the lists numpy.arrays for easier use. LOG.info("Converting result to array...") TAVG_TIME = numpy.array(tavg_time) BOLD_TIME = numpy.array(bold_time) BOLD = numpy.array(bold_data) TAVG = numpy.array(tavg_data) #Create TimeSeries instance tsr = TimeSeriesRegion(data=TAVG, time=TAVG_TIME, sample_period=2.) tsr.configure() #Create and run the monitor/analyser bold_model = bold.BalloonModel(time_series=tsr) bold_data = bold_model.evaluate() bold_tsr = TimeSeriesRegion(connectivity=white_matter, data=bold_data.data, time=bold_data.time) #Prutty puctures... tsi = timeseries_interactive.TimeSeriesInteractive(time_series=bold_tsr) tsi.configure() tsi.show() ###EoF###
#Load the demo region timeseries dataset try: data = numpy.load("demo_data_region_16s_2048Hz.npy") except IOError: LOG.error("Can't load demo data. Run demos/generate_region_demo_data.py") raise period = 0.00048828125 #s #Put the data into a TimeSeriesRegion datatype white_matter = connectivity.Connectivity() tsr = TimeSeriesRegion(connectivity=white_matter, data=data, sample_period=period) tsr.configure() #Create and run the analyser pca_analyser = pca.PCA(time_series=tsr) pca_data = pca_analyser.evaluate() #Generate derived data, such as, compnent time series, etc. pca_data.configure() #Put the data into a TimeSeriesSurface datatype component_tsr = TimeSeriesRegion(connectivity=white_matter, data=pca_data.component_time_series, sample_period=period) component_tsr.configure() #Prutty puctures...
#Load the demo region timeseries dataset try: data = numpy.load("demo_data_region_16s_2048Hz.npy") except IOError: LOG.error("Can't load demo data. Run demos/generate_region_demo_data.py") raise period = 0.00048828125 #s #Put the data into a TimeSeriesRegion datatype white_matter = connectivity.Connectivity() tsr = TimeSeriesRegion(connectivity = white_matter, data = data, sample_period = period) tsr.configure() #Create and run the analyser pca_analyser = pca.PCA(time_series = tsr) pca_data = pca_analyser.evaluate() #Generate derived data, such as, compnent time series, etc. pca_data.configure() #Put the data into a TimeSeriesSurface datatype component_tsr = TimeSeriesRegion(connectivity = white_matter, data = pca_data.component_time_series, sample_period = period) component_tsr.configure() #Prutty puctures...
#Load the demo region timeseries dataset try: data = numpy.load("demo_data_region_16s_2048Hz.npy") except IOError: LOG.error("Can't load demo data. Run demos/generate_region_demo_data.py") raise period = 0.00048828125 # s #Put the data into a TimeSeriesRegion datatype white_matter = connectivity.Connectivity() tsr = TimeSeriesRegion(connectivity=white_matter, data=data, sample_period=period) tsr.configure() #Create and run the analyser corrcoeff_analyser = corr_coeff.CorrelationCoefficient(time_series=tsr) corrcoeff_data = corrcoeff_analyser.evaluate() #Generate derived data, if any... corrcoeff_data.configure() # Plot matrix with numbers # For visualization purposes, the diagonal is set to zero. FC = corrcoeff_data.array_data[:, :, 0, 0] numpy.fill_diagonal(FC, 0.) pyplot.matshow(FC, cmap='RdBu', vmin=-0.5, vmax=0.5, interpolation='nearest') pyplot.colorbar() pyplot.show()