Thanks for your answers, I am using the scripting interface. Another issue I encountered was, that I couln't use a windowing function, because calling it with a string like (e.g. 'hanning) triggers an error (
AttributeError: 'str' object has no attribute 'value'
).
This are the relevant bits of code, I think (or should I post the entire script?):
sim = simulator.Simulator(coupling = coupl,
integrator = integ,
connectivity = SC,
conduction_speed = 4,
simulation_length = 10000,
model = mod,
monitors = [mon_EEG]
)
results = sim.run()
.
.
.
from tvb.analyzers.fft import compute_fast_fourier_transform
from tvb.datatypes.time_series import TimeSeriesEEG
from tvb.simulator.lab import *
# Example data loading
# data should have shape (10667, 4, 61, 1)
# eeg_data should then be (10667, 61) when extracting the first state variable
eeg_data = results[0][1] # This simplifies the data to (10667, 61)
# Create TimeSeriesEEG with all required configurations
time_series_eeg = TimeSeriesEEG()
time_series_eeg.data = eeg_data
time_series_eeg.time = time
time_series_eeg.sensors = sensorsEEG
time_series_eeg.title = "EEG Time Series Data"
time_series_eeg.labels_ordering = ['Time', 'State Variables', 'EEG Sensors', 'Mode']
time_series_eeg.sample_period = 1.0 / 1024 # Sample period in seconds
time_series_eeg.sample_period_unit = 's' # Unit of sample period
time_series_eeg.start_time = time[0] # Assuming time[0] is the start time, adjust if necessary
time_series_eeg.labels_dimensions = {
'State Variables': ['Variable1'], # Adjust according to actual variables
'EEG Sensors': list(sensorsEEG.labels),
'Mode': ['Default'] # Adjust if there are multiple modes
}
time_series_eeg.configure()
.
.
.
# FFT Parameters
from tvb.datatypes.spectral import FourierSpectrum
#WindowingFunctionsEnum.HAMMING
segment_length = 2.0 # 2 seconds for a 0.5 Hz frequency resolution
window_function = None # No window due to bug
detrend = True # Typically you might detrend, but depends on your data preprocessing
# Compute FFT
fourier_spectrum = compute_fast_fourier_transform(time_series_eeg,
segment_length,
window_function,
detrend)
.
.
.
fourier_spectrum.compute_power()
print(power.shape)
OUTOUT:
(1024, 4, 61, 1, 6)
Best regards,
Simon