From: Ravi Rastogi on
"Ravi Rastogi" <raviras(a)gmail.com> wrote in message <hrs61p$mjp$1(a)fred.mathworks.com>...
> Hi guys,
>
> In my 1D data for my application i need to determine the start and stop time of the bursts. currently i am using using 'ginput' to manually select the points of changes.
> Here is what i am doing:
>
> %Loading the Data
> load DX.mat
> load DY.mat
> %Determining the starting and stopping points of Bursts,
> figure;
> plot(Dx20);
> title('1D plot of the data');
> %Input how many bursts are there, looking at the data.
> nobst=input('Please enter the no of bursts in the signal: ');
> %Use Ginput to get the values of the start and stop: first is always start and next is %stop point.
> [rxx,~]=ginput(nobst*2);
> %Read the burst points:
> tmp=1;
> for h=1:2:nobst*2,
> startx(tmp)=round(rxx(h));
> stopx(tmp)=round(rxx(h+1));
> tmp=tmp+1;
> end;
> clear nobst rxx h tmp;
> %%Repeat the same for DY20:
>
> PS:: is there a way to attach the data file in the post??
>
> Can someone suggest a better way to do this automatically rather than me selecting the start and stop points manually as i am doing right now??
> I looked at determining the threshold based on the amplitude of the signal, but in the data (sinusoidal) there are many times the signal crosses that threshold before coming to the resting amplitude and the code keeps picking those times also when it crosses. I am interested in detecting the point in time just before the burst starts from the resting amplitude and when it ends in time before coming to resting amplitude again, nothing between these two values.
> If you can think of any way please suggest!!
>
> Ravi

I thought i will share with everyone what i ended up doing for this problem.

stepx= DX>0.0008; % threshold = 0.0008
% Looking for Stoping location of bursts
tstop=1;
for h=1:length(stepx)-res,
count=0;
for t=1:res
if(stepx(h)==1 && stepx(h+t)==0) % Stop condition
count=count+1;
end;
end;
if count==res,
stopx(tstop)= h+20;
tstop=tstop+1;
end;
end;

Here i am looking at the condition where, if the next 10 points after the point having 1 amp are equal to zero. If yes then thats a stoping point of the burst and similarly for the start point previous 10 points have to be zero after reading 1 in the data points. This works with decent accuracy. In the code above: res=10;

Thanks.