Can I derive the Respiratory Modulator signal (from an ECG) with the function interp2

8 visualizaciones (últimos 30 días)
hello everyone,
I was able to create the heart modulator, phi_card shown as follows, where their min. & max. values are +-pi. This was done with the function interp1 (aka linear interpolation of 1st order). The x-coordinates are Samples.
The frequency of this is directly proportional to the RR interval from the ECG signal. Now, the next task is a bit trickier, as the phi_resp is not linear, but rather of second order (or thats my initial guess). The result should look similar to the following image, but as well as for the phi_card, the frequencies for each period should vary.
So my question is, can I achieve this using the function interp2 ? are there any similar examples to catch up (i feel a bit confused atm) ? any other suggestions are also welcome.
PS: I did create the breathing rate signal (see below), but for some reason I can not make the connection with the phi_resp. Any ideas?
Thanks,
David
  3 comentarios
Karim
Karim el 20 de Jun. de 2022
Hello, it is quite difficult to understand your question. "the heart modulator, phi_card, RR rate" etc are unknown concepts. To make it clearer (without using more medical(?) terms) it would be easier to attach the code you currently have and indicate where it goes wrong.
Anyhow, if the goal is to use a different method for the interpolation, you can still use the "interp1" function, however change the method to cubic or spline:
vq = interp1(x, v, xq, method)
Also, for the best result I would unwrap the data before the interpolation, and afterwards wrap it again.
David De Querol
David De Querol el 20 de Jun. de 2022
Editada: David De Querol el 20 de Jun. de 2022
Thank you @KASR for your honest comment and suggestion. I will try to make it clearer.
The top figure (signal called phi_card) has the following code, which works as expected (although the code itself can be optimised):
function [phi_card_new] = interpolation(locs_Rwave)
% We define the constants X and absPi for the linear interpolation
X = [0:100];
absPi = ([0:0.01:1]*2*pi)-pi; %absPi must have the same length as X
array = [];
%for-loop -> interpolation
for i = 1:length(locs_Rwave)
if i==length(locs_Rwave)
break;
end
%length
len = (locs_Rwave(i+1)-(locs_Rwave(i)+1));
%parameter frame for the interp1 function
frame = [0:len]/len*100;
%linear Interpolation
linearInterpolation = interp1(X , absPi , frame , 'linear');
%save result
array{i} = linearInterpolation;
end
%% loop through all array values
figure;
hold on;
t=0;
phi_card_new = [length(locs_Rwave)];
for i = 1:length(locs_Rwave)
if i==length(locs_Rwave)
break;
end
%we plot each interpolated line
plot(t:(t+length(array{i})-1), array{i});
%and then we add the corresponding conexion line
plot([(t+length(array{i})-1) (t+length(array{i}))] , [3.14159 -3.14159]);
%increased time for every loop
t = length(array{i}) + t;
%save the result on our output parameter
phi_card_new =[phi_card_new, array{i}];
end
disp('Interpolation done')
end
Important here is the length of the phi_card value (= 1997899x1 double), as phi_resp should match its length.
So now, my struggle is related to the phi_resp_new signal, in which the interpolation should not be done only with the locs_Rwave, but rather also on the RRinterval parameter (that´s why I thought initially of a second degree interpolation, function interp2(...) ).
For a clear understanding, the new phi_resp signal should look similar to the phi_card, but with a lower frequency rate (estimated: for each 10 periods of the phi_card signal, the phi_resp is 1 or 2 periods long). But again, the length of phi_resp should also be 1997899x1 double. The code I am asking for help is the following:
function [phi_resp_new] = Cubic_interpolation(locs_Rwave, RRinterval)
% We define the constants X and absPi for the cubic interpolation
X = [0:100];
absPi = ([0:0.01:1]*2*pi)-pi; %absPi must have the same length as X
array = [];
%for-loop -> interpolation
% Here is where I believe my struggle is. I should make the signal as long
% as locs_Rwave, but with a lower frequency rate, following the new
% parameter RRinterval instead of the previous locs_Rwave
for i = 1:length(locs_Rwave)
if i==length(RRinterval)
break;
end
%length
len = (RRinterval(i+1)-(RRinterval(i)+1));
%parameter frame for the interp1 function
frame = [0:len]/len*100;
%cubic Interpolation
cubicInterpolation = interp1(X , absPi , frame , 'cubic');
%save result
array{i} = cubicInterpolation;
end
% I did not change anything on this second part of the code, as I believe
% this plots only the result
figure;
hold on;
t=0;
phi_resp_new = [length(locs_Rwave)];
for i = 1:length(locs_Rwave)
if i==length(array)
break;
end
%we plot each interpolated line
plot(t:(t+length(array{i})-1), array{i});
%and then we add the corresponding conexion line
plot([(t+length(array{i})-1) (t+length(array{i}))] , [3.14159 -3.14159]);
%increased time for every loop
t = length(array{i}) + t;
%save the result on our output parameter
phi_resp_new =[phi_resp_new, array{i}];
end
disp('Interpolation done')
end
Thank you in advance,
David

Iniciar sesión para comentar.

Respuestas (0)

Categorías

Más información sobre Spectral Measurements en Help Center y File Exchange.

Productos


Versión

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by