How to normalize the baseline of multiple Differential Pulse Voltammetry Curves?

I have a few DPV curves for different concentration that I plotted in the same graph. But the baselines of the DPV curves do not match. So I want to normalize the baseline using Matlab. (So that the baseline is 0) My DPV curves looks like the following: Can someone please help me with this? I also added the excel file with the data here.
Thank you!

 Accepted Answer

Without actually having the data to work with, my first approach would be to use the detrend function on each curve.

6 Comments

Hi, Thank you for your answer. I have added the data to the description of the question. I will try the detrend function and see how it goes.
My pleasure!
Using detrend did not work the way I wanted it to, so I created my own detrending approach. It calculates the slope and intercept (columns of the ‘B’ matrix) of the baseline (assumed to be linear) from the first and last elements of the vectors (and experimented with the 10th and last elements), and then creates a linear fit to the entire ‘Voltage’ variable and subtracts that from the original variable for each the ‘Current’ variables. That works better than detrend for these data, however it may be necessary to experiment further, depending on the result you want.
I am not certain that it is possible to perfectly detrend the baselline without distorting the curves themselves.
Try this —
T1 = readtable('DPV.xlsx','VariableNamingRule','preserve')
T1 = 61x8 table
Voltage Current (0.1)Current (0.3) Var3 Current (0.5) Current (0.7) Current (1) Current (2) Current (3) _______ __________________________ _______ _____________ _____________ ___________ ___________ ___________ -300 0.88631 0.14617 0.26339 0.52428 0.61456 0.51742 0.4885 -290 1.2188 0.14004 0.4203 0.6438 0.66459 0.55903 0.52387 -280 1.4655 0.17436 0.55381 0.62123 0.63863 0.55029 0.51182 -270 1.7461 0.35175 0.67868 0.62086 0.65448 0.54676 0.50542 -260 1.655 0.547 0.69532 0.62473 0.61814 0.53223 0.47636 -250 1.6687 0.78629 0.71277 0.63484 0.64034 0.54321 0.48141 -240 1.6236 0.97004 0.71882 0.63707 0.65091 0.55595 0.48179 -230 1.5832 1.115 0.72875 0.6572 0.66627 0.58214 0.49861 -220 1.6755 1.137 0.7347 0.65705 0.68499 0.58991 0.50568 -210 1.7379 1.1966 0.75801 0.69857 0.70984 0.63047 0.52962 -200 1.715 1.2094 0.77933 0.72121 0.74034 0.6553 0.55002 -190 1.7591 1.2586 0.85322 0.76694 0.79021 0.69411 0.58604 -180 1.8078 1.2954 0.84447 0.79708 0.81889 0.72845 0.59764 -170 1.8551 1.3269 0.88539 0.8395 0.8516 0.77739 0.63474 -160 1.9023 1.3562 0.91233 0.86336 0.87275 0.80403 0.67134 -150 1.9921 1.4461 0.97145 0.9101 0.91852 0.85444 0.72822
VN = T1.Properties.VariableNames;
figure
plot(T1.Voltage, T1{:,2:end})
grid
xlabel('Voltage (mV)')
ylabel('Current (\muA)')
title('Original')
legend(VN{2:end}, 'Location','best')
for k = 1:size(T1,2)-1
B(:,k) = [T1{[1 end],1} ones(2,1)] \ T1{[1 end],k+1};
% Q = [T1{:,1} ones(size(T1{:,1}))] * B(:,k)
Idt(:,k) = T1{:,k+1} - [T1{:,1} ones(size(T1{:,1}))] * B(:,k);
end
figure
plot(T1.Voltage, Idt)
grid
xlabel('Voltage (mV)')
ylabel('Current (\muA)')
title('Linear Detrending: [1 end]')
legend(VN{2:end}, 'Location','best')
for k = 1:size(T1,2)-1
B(:,k) = [T1{[10 end],1} ones(2,1)] \ T1{[10 end],k+1};
% Q = [T1{:,1} ones(size(T1{:,1}))] * B(:,k)
Idt(:,k) = T1{:,k+1} - [T1{:,1} ones(size(T1{:,1}))] * B(:,k);
end
figure
plot(T1.Voltage, Idt)
grid
xlabel('Voltage (mV)')
ylabel('Current (\muA)')
title('Linear Detrending: [10 end]')
legend(VN{2:end}, 'Location','best')
Most of the problems are in the region of the lowest voltages. It might be possible to simply use:
Idt(:,k) = max([zeros(size(Idt(:,k))) Idt(:,k)], [], 2);
to even out the baseline (delete the negative values) if the current response at the lowest voltages are not requred to be retained. If so, put this after the initial ‘Idt(:,k)’ calculation in any loop that begins with an index larger than 1 (for example, in the second loop here that begins with 10). That provides an even baselilne at the expense of eliminating any negative current values that may result from the detrending process.
.
Hi! Thank you so much! This works for these specific data and similar graphs. But what do I do if the baseline is not linear? Is there a way to subtract it? For example for the graph attached here, is there a way to make the baseline linear and then subtract it?
This approach works for all except the first set (‘I1’), and I cannot devise an appropriate integer-order polynomial that works correctly with it. The others detrend well with a 5th-order polynomial.
Try this —
T1 = readtable('DPV_old.xlsx','VariableNamingRule','preserve')
T1 = 81x4 table
Voltage I1 I2 I3 _______ _________ _________ ________ -300 1.2998 2.6418 0.92055 -290 0.17632 0.20264 3.5631 -280 0.14736 0.15839 3.4154 -270 0.1227 0.14206 0.82172 -260 0.12101 0.12943 0.23768 -250 0.063406 0.094923 0.14846 -240 0.066088 0.075111 0.14889 -230 0.076057 0.064936 0.11877 -220 0.041663 0.049986 0.073133 -210 0.023613 0.029505 0.08501 -200 0.017722 0.028476 0.049472 -190 0.02553 0.025718 0.04199 -180 0.032825 0.028149 0.053867 -170 0.030347 0.0060319 0.038857 -160 0.0075581 0.02 0.013637 -150 0.032135 0.013491 0.027272
VN = T1.Properties.VariableNames;
figure
plot(T1.Voltage, T1{:,2:end})
% plot(T1{:,1}, T1{:,2})
grid
xlabel('Voltage (mV)')
ylabel('Current (\muA)')
title('Original')
legend(VN{2:end}, 'Location','best')
% hold on
% for k = 1:size(T1,2)-1
% % plot(T1{Lv,1}, T1{Lv,k+1}, 's');
% Lv1 = (T1{:,2} <= mean(T1{:,2})+3);
% Lv2 = ischange(T1{:,2}, 'linear', 'Threshold',1E-9);
% Lv = Lv1 & Lv2;
% Nv = find(Lv);
% Nv = Nv(3:end);
% plot(T1{Nv,1}, T1{Nv,k+1}, 's');
% Bv = polyfit(T1{Nv,1}, T1{Nv,k+1}, 5);
% rline = polyval(Bv, T1{:,1});
% plot(T1{:,1}, rline, '-r')
% end
% hold off
for k = 1:size(T1,2)-1
Lv1 = (T1{:,k+1} <= mean(T1{:,k})+3);
Lv2 = ischange(T1{:,k+1}, 'mean', 'Threshold',1E-11);
Lv = Lv1 & Lv2;
Nv = find(Lv);
Nv = Nv(3:end);
op = 5;
if k == 1
op = 2;
end
[B,S,mu] = polyfit(T1{Nv,1}, T1{Nv,k+1}, op);
dtv = polyval(B, T1{:,1}, S, mu);
Idt(:,k) = T1{:,k+1} - dtv;
end
figure
plot(T1.Voltage, Idt)
grid
xlabel('Voltage (mV)')
ylabel('Current (\muA)')
title('Polynimial Detrending')
legend(VN{2:end}, 'Location','best')
.
Thank you so much! This was really helpful.

Sign in to comment.

More Answers (0)

Categories

Community Treasure Hunt

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

Start Hunting!