0

I would like to perform a frame based analysis on the following curve Which expresses the relation between time and concentration (x-axis: time in minutes; y-axis: concentration in Mbq):

original graph

For the above curve I would like to perform frame based sampling by splitting the curve into 19 frames:

19 frames:
 4 frames : Each of 15 seconds time interval
 2 frames : Each of 30 seconds time interval
 2 frames : Each of 60 seconds time interval
11 frames : Each of 200 seconds time interval

I have written the following interpolation function for the frame analysis. c_t is where my signal which was expressed in the figure above is stored:

function c_i = Frame_analysis(a1,a2,a3,b1,b2,b3,td,tmax,k1,k2,k3)


t= 0:6:3000; % The original sample time, in seconds
t_i =[0:15:60,90:30:120,180:60:240,440:200:2240];% The interpolated sample time for first 4 frames of 15 second interval

K_1   = (k1*k2)/(k2+k3);
K_2   = (k1*k3)/(k2+k3);
%DV_free= k1/(k2+k3);




c_t = zeros(size(t));

ind = (t > td) & (t < tmax);

c_t(ind)= conv(((t(ind) - td) ./ (tmax - td) * (a1 + a2 + a3)),(K_1*exp(-(k2+k3)*t(ind)+K_2)),'same');

% Y_i = interp1(t,c_t(ind), t_i); % Interpolation for first frame




ind = (t >= tmax);

c_t(ind)=conv((a1 * exp(-b1 * (t(ind) - tmax))+ a2 * exp(-b2 * (t(ind) - tmax))) + a3 * exp(-b3 * (t(ind) - tmax)),(K_1*exp(-(k2+k3)*t(ind)+K_2)),'same');

c_i = interp1(c_t(ind),t_i);% Interpolation for Next consequtive frames



figure;
plot(t_i,c_i);
axis([0 3000 -2000 80000]);
xlabel('Time[secs]');
ylabel('concentration [Mbq]');
title('My signal');

%plot(t,c_tnp);

end

When I run the code, I have obtained a curve without any interpolation as you can see from figure expressed below:

updated graph

Where have I made a mistake in my code and how can I possibly perform a better interpolation for obtaining different frames in my Output curve expressed in first figure?

Following are the input values which i have provided manually

Frame_analysis(2501,18500,65000,0.5,0.7,0.3,3,8,0.014,0.051,0.07)
DevanDev
  • 245
  • 2
  • 11
  • Could this just be a scaling issue? In the second plot, your x-axis ranges from 0 to 3000, while in the original figure, it is 0 to 50. Furthermore, at x=50, you are already at 0 - so for any x > 50 you can expect to be at 0 after any interpolation (which is what you see in the second figure). The meaningful portion of the plot may be a spike very close to x=0. – Schorsch Apr 08 '14 at 15:12
  • @Schorsch, I have resolved the scaling issues , but still i am incurring the same problem,Scaling can be done in either mins or seconds,Yes the spike will be at tmax time which is around 80 secs, If possible could you please let me know a way i can perform sampling of my curve into 19 frames. – DevanDev Apr 08 '14 at 15:24
  • When I copy/paste your example, I get this error: `Error using griddedInterpolant - Interpolation requires at least two sample points in each dimension.` In the line where you first calculate `Y_i`. The issue appears to be, that with what you provide, `c_t(ind)` is a scalar (and not a vector). – Schorsch Apr 08 '14 at 15:51
  • @Schorsch: I have re-edited the code, please check it and review it – DevanDev Apr 08 '14 at 15:55
  • When? As you can see, my previous comment is more recent than your last edit. Last chance ... – Schorsch Apr 08 '14 at 15:57
  • @Schorsch:Kindly review it, I made a slight mistake so i again re-edited the code, now please compile the code and you would incur the same error – DevanDev Apr 08 '14 at 16:00

1 Answers1

1

There are multiple issues here, and it will be up to you to decide how to address them.
This is what I can provide:

  1. You do not specify an x-coordinate for your plot command. That can be done, however, Matlab will use the index of the vector for the x-axis. Example: if you have

    y = 1:2:6;
    plot(y);
    hold on;
    y = 1:1:6;
    plot(y);
    

    you'll see the difference.
    How does this apply to your case? You specify a vector of higher resolution (t_i, compared to t), but in your plot command you do not provide this new vector for the x-coordinate.

  2. Your definition of c_t provides very very small values (on the order of 10^-77). And from t > 60, your output is indifferent from 0.
    How does that effect your interpolation?
    You specify that for the interval [0 60] you want step-sizes of 15 - that does not give you a lot of resolution:

    example

    You might want to change to something like:

    t_i =[0:0.5:60,90:30:120,180:60:240,440:200:2240];  
    

    Which will give you this plot:

    enter image description here

  3. In either case, I do not understand why you chose a data range above 60 (all the way until 3000) for the data you are trying to plot. This explains why you do not see anything with your axis limits axis([0 3000 -2000 80000]); that by far exceed the range of y-values and obscures the non-zero data entries for small x.

Schorsch
  • 7,761
  • 6
  • 39
  • 65
  • @DaryushSha Please consider accepting this answer or comment on what does not work for you. – Schorsch Apr 08 '14 at 17:56
  • Apologize for delayed response, i lost my user account so i could not respond to you, Concerning the question, I have chosen the time span of 3000 secs as this is the scan duration that patient undergoes in PET scan, The characteristics in the above figure chemical kinetics of tracer while performing PET scan, I am interested in analysing the characteristics of tracer by frame analysis ,so i need to sample the kinetic behavior of tracer into 19 frames and subsequently add noise to the data, You answer does not work for me – DevanDev Apr 14 '14 at 10:47
  • The answer which you have stated is not what i need,Precisely i need to sample the output curve into 19 frames each frame has certain time duration as expressed above and I have to plot the output characteristics with sampled data.. what i see in your answer is not exactly what i wish to achieve,I have performed interpolation at different time points to obtain sampled data, if you think i need to approach this problem differently kindly let me know how i can possibly sample the output curve into 19 different sampled frames – DevanDev Apr 14 '14 at 10:52
  • @DaryushShah I will not and cannot solve your specific problems. I attempted to answer the question you asked. You were showing a plot which seemed to show no interpolation. I provided an answer as to what the issue for the example you provided is. You can chose however many seconds you want - it doesn't change the fact that for the data you showed in the question, after 60 seconds nothing will happen. that leaves 2940 seconds of zeros. – Schorsch Apr 14 '14 at 11:21