Subtractive Baseline-correction

4 visualizzazioni (ultimi 30 giorni)
Camilla
Camilla il 14 Mag 2024
Commentato: Mathieu NOE il 14 Mag 2024
Hello All,
Im trying to do a subtractive baseline correction on pupil data. I wrote the skript already but when i plot the data, it seems like the baseline correction did not work. The graphs do not all start from the same point. Any ideas of what i could´ve done wrong?
Thank you in advance
%Verzeichnis
Verzeichnis = '/Users/eliebonin/Documents/MATLAB/edf_daten_elie/Datensatz eye tracking';
%Daten laden
load('testmat3.mat')
%Überprüfen der Größe der Matrix
[proben_anzahl, ~] = size (testmat3);
%Sicherstellen, dass die Anzahl der Proben größer oder gleich 10 ist
if proben_anzahl < 10
error ('Es gibt nicht genügend Proben für Baseline correction');
end
%Definieren des Zeitbereiches für die Baseline
baseline_zeitraum = 1:10; %Annahme: Die ersten zehn Samples entgsprechen dem Baseline-Zeitraum
%Berechnen des Mittelwerts während des baseline Zeitraums für jede Probe
baseline_groesse = mean(testmat3(:,baseline_zeitraum), 2);
%substraktion des Baseline-Mittelwerts von allen Pupillengrößen für jede
%Probe
baseline_corrected_daten = testmat3 - baseline_groesse;
save('baseline_correction.mat', 'baseline_corrected_daten');

Risposta accettata

Mathieu NOE
Mathieu NOE il 14 Mag 2024
hello
I was first a bit puzzled when you mention the baseline is made of the first 10 samples - but after several readings it seems to me you think "probes" and not samples
so the baseline is the mean(correct) but in the other dimension (along the "probe" dimension and not te time / samples dimension)
also , as your data conatin nan's it's good idea to use 'omitnan' in the mean computation parameters.
I suspect this is what you wanted to do
%Daten laden
load('testmat3.mat')
figure(1),plot(testmat3)
%Überprüfen der Größe der Matrix
[proben_anzahl, ~] = size (testmat3);
%Sicherstellen, dass die Anzahl der Proben größer oder gleich 10 ist
if proben_anzahl < 10
error ('Es gibt nicht genügend Proben für Baseline correction');
end
%Definieren des Zeitbereiches für die Baseline
baseline_zeitraum = 1:10; %Annahme: Die ersten zehn Samples entgsprechen dem Baseline-Zeitraum
%Berechnen des Mittelwerts während des baseline Zeitraums für jede Probe
% baseline_groesse = mean(testmat3(:,baseline_zeitraum), 2, 'omitnan');
baseline_groesse = mean(testmat3(baseline_zeitraum,:), 1, 'omitnan');
%substraktion des Baseline-Mittelwerts von allen Pupillengrößen für jede
%Probe
baseline_corrected_daten = testmat3 - ones(size(testmat3,1),1)*baseline_groesse;
figure(2),plot(baseline_corrected_daten)
save('baseline_correction.mat', 'baseline_corrected_daten');
  4 Commenti
Camilla
Camilla il 14 Mag 2024
Thank u so so much this worked perfectly for me!
Mathieu NOE
Mathieu NOE il 14 Mag 2024
as always, my pleasure !

Accedi per commentare.

Più risposte (1)

Joe Vinciguerra
Joe Vinciguerra il 14 Mag 2024
I suspect you want this:
baseline_groesse = mean(testmat3(baseline_zeitraum,:), 1);
instead of this:
baseline_groesse = mean(testmat3(:,baseline_zeitraum), 2);

Categorie

Scopri di più su Electrophysiology in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by