TFR Analysis from CSV File

I’m having trouble doing TFR analysis, I’m not understanding clearly what I need to do, my data contains only the time and amplitude of 8 eeg channels. I tried specifing EPOCHS but I cannot understand how is done. Can someone help me to do a TFR Morlet please.

import mne
import numpy as np
import matplotlib.pyplot as plt
import pandas as pd

# Cargar los datos EEG desde el archivo CSV
data= pd.read_csv("Estimulo/AURA_FFT___2023-09-11___11;42;36.csv", usecols=[*range(1,9)], skiprows=3, delimiter=',') 
data = data.transpose().to_numpy()
# Crear un objeto RawArray a partir de los datos
info = mne.create_info(ch_names=['Canal1', 'Canal2', 'Canal3', 'Canal4', 'Canal5', 'Canal6', 'Canal7', 'Canal8'],
                       sfreq=256, ch_types='eeg')  # Ajusta sfreq según tu tasa de muestreo

raw = mne.io.RawArray(data, info)


# Configurar parámetros para el análisis de TFR
freqs = np.arange(4, 40, 2)  # Frecuencias a analizar
n_cycles = freqs / 2  # Ciclos de onda por frecuencia

# Realizar el análisis de TFR
tfr_multitaper = mne.time_frequency.tfr_array_morlet(raw, freqs=freqs, sfreq=255, n_cycles=n_cycles)

# Graficar el análisis de TFR para los 8 canales


Hola!

I suggest to provide a bit more information, so we can help you.
What is the shape of your raw data? How long is your time series?
Most importantly, at what point in your code do you get an error message?

Best,

Carina

1 Like