Borrar filtros
Borrar filtros

How do I cut data into segments?

15 visualizaciones (últimos 30 días)
Nikki Larsen
Nikki Larsen el 12 de Abr. de 2020
Comentada: Ameer Hamza el 13 de Abr. de 2020
I have eeg data in a .bdf file and I need to segment the data using the information in a .txt file.
The text file contains start and stop times in milliseconds .
I must cut fromt1 to t2 and then t2 to t3 and so on..
  7 comentarios
dpb
dpb el 12 de Abr. de 2020
Well, the only .bdf file extension I was aware of was the Adobe one that didn't seem to make any sense...looks as though this is a proprietary EEG file format using 24-bit/3-bytes per sample. That's going to take some processing to read...just a simple fread won't cut it.
There's a very simple and somewhat questionable for general use submittal at the FileExchange
How did you import the data into MATLAB?
As far as the time, there isn't a timestamp in the file; either the duration and number of samples is given or the duration is encoded as "1" in which case the number of samples is to be interpreted as the sample rate.
Either way, you'll need to determine that and then compute how many records are needed to match up. Easy enough if the two have common divisor; maybe not quite so much if time and sample rates don't match precisely.
Nikki Larsen
Nikki Larsen el 13 de Abr. de 2020
yes i basically modified the eeg-bdf-reader to read the bdf file.

Iniciar sesión para comentar.

Respuestas (1)

Ameer Hamza
Ameer Hamza el 12 de Abr. de 2020
try something like this
data = rand(80, 512); % random data, replace with data from bdf file
t_intervals = [50 100 300 500 700 900]; % values from your txt file in milliseconds
% solution
fs = 512; % sampling frequency
T = 1/fs*1000; % sampling time in milliseconds
t = 0:T:T*fs-1; % sample time instants
t_intervals = [0 t_intervals t(end)];
data_partition = splitapply(@(x) {x}, data, discretize(t, t_intervals));
  2 comentarios
Nikki Larsen
Nikki Larsen el 13 de Abr. de 2020
Thank you :)
Ameer Hamza
Ameer Hamza el 13 de Abr. de 2020
Glad to be of help.

Iniciar sesión para comentar.

Categorías

Más información sobre EEG/MEG/ECoG en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by