Sign in

username:

password:



Not a member?

Search matlab



Search tips

Subscribe to matlab



matlab by Keywords

Atanh | Autocorrelation | Bandpass Filter | C++ | Conv | Database | Deconv | Excel | FFT | Filter | Filtering | FIR | Fourier Transfrom | FSK | Gaussian Noise | Haykin | IFFT | Image | Java | LFSR | LMS | LPC | MEX | OFDM | QPSK | Radix | Random | Sampling | Segmentation | Simulink | Visual Basic | Waveform | Wavelet

Discussion Groups

Discussion Groups | Matlab DSP | RE: Break plot up into block intervals in different colours

Technical discussion about Matlab and issues related to Digital Signal Processing.

  

Post a new Thread

Break plot up into block intervals in different colours - chri...@gmail.com - Mar 8 13:16:00 2006



Hi, 

I have some EEG data. The 1st 45seconds of data is rest data, followed by some stimulation data
for 10 seconds. Again another 45 seconds of rest and another 10 seconds of stimulation data.

I want to have the first 45seconds of the plot in white and the next 10 seconds in green to
show the rest-to-stimulation transition (and again another 45seconds of white and 10 seconds of
white). I have seen this displayed in some papers but i have no idea how to do it. 

e.g.
¦data with white background¦data with green background¦
	...where ¦ is the transition between the rest and stimulation data
	Any help appreciated,
ChrisJ.
	


(You need to be a member of matlab -- send a blank email to matlab-subscribe@yahoogroups.com )

RE: Break plot up into block intervals in different colours - Jeff Winter - Mar 9 11:04:00 2006

Hi Chris,

For once I'd say use MS Excel rather than Matlab. It's a piece of cake.  The
graphics capability of Excel is often overlooked.

Cheers,

Jeff
	-----Original Message-----
From: matlab@matl... [mailto:matlab@matl...]On Behalf Of
chrissoraghan@chri...
Sent: 08 March 2006 17:16
To: matlab@matl...
Subject: [matlab] Break plot up into block intervals in different
colours
	Hi,

I have some EEG data. The 1st 45seconds of data is rest data, followed by
some stimulation data for 10 seconds. Again another 45 seconds of rest and
another 10 seconds of stimulation data.

I want to have the first 45seconds of the plot in white and the next 10
seconds in green to show the rest-to-stimulation transition (and again
another 45seconds of white and 10 seconds of white). I have seen this
displayed in some papers but i have no idea how to do it.

e.g.
¦data with white background¦data with green background¦
	...where ¦ is the transition between the rest and stimulation data
	Any help appreciated,
ChrisJ.
	


(You need to be a member of matlab -- send a blank email to matlab-subscribe@yahoogroups.com )

Re: Break plot up into block intervals in different colours - Christopher Soraghan - Mar 9 13:39:00 2006

Hi Jeff,

The Excel idea will work but i would rather try and keep it within Matlab.
There will be many tests like this and the protocols for each will not
always adhere to the same rest and stimulation periods of 45seconds and
10seconds as mentioned previously. I have to perform some pre and post
processing to the noisy data and apply other algorithms to SOME of the
results so I would like to find a way to control the graphics of matlab as
mentioned below and be able to change the lenght of time for the different
states, rest stimulation, semi stimulation. Really im looking for a way to
section off different states in the plot with colour ID, of green and white
as mentioned below. If i cannot get the info on how to do it I will use
Excel for the time being but it would be better to have a function m-file to
adjust the graphics, as with 'bar.m' etc. Thanks for the help Jeff,

ChrisJ
	On 3/9/06, Jeff Winter <jeff.winter@jeff...> wrote:
>
> Hi Chris,
>
> For once I'd say use MS Excel rather than Matlab. It's a piece of
> cake.  The
> graphics capability of Excel is often overlooked.
>
> Cheers,
>
> Jeff
>
>
> -----Original Message-----
> From: matlab@matl... [mailto:matlab@matl...]On Behalf Of
> chrissoraghan@chri...
> Sent: 08 March 2006 17:16
> To: matlab@matl...
> Subject: [matlab] Break plot up into block intervals in different
> colours
>
>
> Hi,
>
> I have some EEG data. The 1st 45seconds of data is rest data, followed by
> some stimulation data for 10 seconds. Again another 45 seconds of rest and
> another 10 seconds of stimulation data.
>
> I want to have the first 45seconds of the plot in white and the next 10
> seconds in green to show the rest-to-stimulation transition (and again
> another 45seconds of white and 10 seconds of white). I have seen this
> displayed in some papers but i have no idea how to do it.
>
> e.g.
> ¦data with white background¦data with green background¦
>
>
> ...where ¦ is the transition between the rest and stimulation data
>
>
> Any help appreciated,
> ChrisJ.
>
	


(You need to be a member of matlab -- send a blank email to matlab-subscribe@yahoogroups.com )

RE: Break plot up into block intervals in different colours - Jeff Winter - Mar 9 13:53:00 2006

Hi Chris,
 
One way of plotting the points in a different colour is to create a number of arrays (equal to the number of transitions) that are of the same length as the total data you want to plot.
 
If your data is: rest1 ¦ stim1 ¦ rest2 ¦ stim2 which for arguments sake is 110 samples long, then the aim is to have 4 arrays (of the same length so that plot doesn't moan) that contain some of the data:
rest1 ¦ ----- ¦ ----- ¦ -----
----- ¦ stim1 ¦ ----- ¦ -----
----- ¦ ----- ¦ rest2 ¦ -----
----- ¦ ----- ¦ ----- ¦ stim2
 
To plot each of these segments you'll need 4 zero'd arrays the same length as your data:
array1 = zeros(1,110); array2 = array1 ; array1 ; array4 = array1 ;
 
Then all you need to do is copy the correct part of each data segment into one of the new arrays. However, you will want to offset the start point of your data entry into each new array. e.g.:
If rest1 is 45 samples long, then array1(1:45) = data(1:45);
If stim1 is 10 samples long, then array2(46:55) = data(46:55);
If rest2 is 45 samples long, then array2(56:100) = data(56:100);
If stim2 is 10 samples long, then array2(101:110) = data(101:110);
 
Now you should be able to plot all four arrays of any colour you want on top of each other so that each transition is in a different colour.
This does assume that you know the sample rate the data was recorded at, so that you can work out what the array indexing should be.
 
The down side to this is that the zeros will also be plotted.  As Matlab plots all the points in a standard plot this will make the intercept points on your graph look odd.  However, you could plot the points in different colours and symbols using this technique on top of a grey line for example.
 
In any case this is one way to segment your data.
 
Cheers,
 
Jeff
-----Original Message-----
From: Christopher Soraghan [mailto:c...@gmail.com]
Sent: 09 March 2006 17:39
To: j...@aeroflex.com
Cc: Subject: Re: [matlab] Break plot up into block intervals in different colours

Hi Jeff,
 
The Excel idea will work but i would rather try and keep it within Matlab. There will be many tests like this and the protocols for each will not always adhere to the same rest and stimulation periods of 45seconds and 10seconds as mentioned previously. I have to perform some pre and post processing to the noisy data and apply other algorithms to SOME of the results so I would like to find a way to control the graphics of matlab as mentioned below and be able to change the lenght of time for the different states, rest stimulation, semi stimulation. Really im looking for a way to section off different states in the plot with colour ID, of green and white as mentioned below. If i cannot get the info on how to do it I will use Excel for the time being but it would be better to have a function m-file to adjust the graphics, as with ' bar.m' etc. Thanks for the help Jeff,
 
ChrisJ
 

 
On 3/9/06, Jeff Winter <j...@aeroflex.com> wrote:
Hi Chris,

For once I'd say use MS Excel rather than Matlab. It's a piece of cake.  The
graphics capability of Excel is often overlooked.

Cheers,

Jeff-----Original Message-----
From: m...@yahoogroups.com [mailto:m...@yahoogroups.com]On Behalf Of
c...@gmail.com
Sent: 08 March 2006 17:16
To: m...@yahoogroups.com
Subject: [matlab] Break plot up into block intervals in different
coloursHi,

I have some EEG data. The 1st 45seconds of data is rest data, followed by
some stimulation data for 10 seconds. Again another 45 seconds of rest and
another 10 seconds of stimulation data.

I want to have the first 45seconds of the plot in white and the next 10
seconds in green to show the rest-to-stimulation transition (and again
another 45seconds of white and 10 seconds of white). I have seen this
displayed in some papers but i have no idea how to do it.

e.g.
¦data with white background¦data with green background¦...where ¦ is the transition between the rest and stimulation dataAny help appreciated,
ChrisJ.

<*> To visit your group on the web, go to:
   http://groups.yahoo.com/group/matlab/

<*> To unsubscribe from this group, send an email to:
   m...@yahoogroups.com

<*>





(You need to be a member of matlab -- send a blank email to matlab-subscribe@yahoogroups.com )

Re: Break plot up into block intervals in different colours - Christopher Soraghan - Mar 9 14:03:00 2006

Hi Jeff,
	What a quick reply and what a good advice, thanks a million! This is what I
will use,
	Cheers,

ChrisJ
	On 3/9/06, Jeff Winter <jeff.winter@jeff...> wrote:
>
>  Hi Chris,
>
> One way of plotting the points in a different colour is to create a number
> of arrays (equal to the number of transitions) that are of the same length
> as the total data you want to plot.
>
> If your data is: rest1 ¦ stim1 ¦ rest2 ¦ stim2 which for arguments sake is
> 110 samples long, then the aim is to have 4 arrays (of the same length so
> that plot doesn't moan) that contain some of the data:
> rest1 ¦ ----- ¦ ----- ¦ -----
> ----- ¦ stim1 ¦ ----- ¦ -----
> ----- ¦ ----- ¦ rest2 ¦ -----
> ----- ¦ ----- ¦ ----- ¦ stim2
>
> To plot each of these segments you'll need 4 zero'd arrays the same length
> as your data:
> array1 = zeros(1,110); array2 = array1 ; array1 ; array4 = array1 ;
>
> Then all you need to do is copy the correct part of each data segment into
> one of the new arrays. However, you will want to offset the start point of
> your data entry into each new array. e.g.:
> If rest1 is 45 samples long, then array1(1:45) = data(1:45);
> If stim1 is 10 samples long, then array2(46:55) = data(46:55);
> If rest2 is 45 samples long, then array2(56:100) = data(56:100);
> If stim2 is 10 samples long, then array2(101:110) = data(101:110);
>
> Now you should be able to plot all four arrays of any colour you want on
> top of each other so that each transition is in a different colour.
> This does assume that you know the sample rate the data was recorded at,
> so that you can work out what the array indexing should be.
>
> The down side to this is that the zeros will also be plotted.  As Matlab
> plots all the points in a standard plot this will make the intercept points
> on your graph look odd.  However, you could plot the points in different
> colours and symbols using this technique on top of a grey line for example.
>
> In any case this is one way to segment your data.
>
> Cheers,
>
> Jeff
>
> -----Original Message-----
> *From:* Christopher Soraghan [mailto:chrissoraghan@chri...]
> *Sent:* 09 March 2006 17:39
> *To:* jeff.winter@jeff...
> *Cc:* *Subject:* Re: [matlab] Break plot up into block intervals in
> different colours
>
> Hi Jeff,
>
> The Excel idea will work but i would rather try and keep it within Matlab.
> There will be many tests like this and the protocols for each will not
> always adhere to the same rest and stimulation periods of 45seconds and
> 10seconds as mentioned previously. I have to perform some pre and post
> processing to the noisy data and apply other algorithms to SOME of the
> results so I would like to find a way to control the graphics of matlab as
> mentioned below and be able to change the lenght of time for the different
> states, rest stimulation, semi stimulation. Really im looking for a way to
> section off different states in the plot with colour ID, of green and white
> as mentioned below. If i cannot get the info on how to do it I will use
> Excel for the time being but it would be better to have a function m-file to
> adjust the graphics, as with ' bar.m' etc. Thanks for the help Jeff,
>
> ChrisJ
>
>
>
> On 3/9/06, Jeff Winter <jeff.winter@jeff...> wrote:
> >
> > Hi Chris,
> >
> > For once I'd say use MS Excel rather than Matlab. It's a piece of
> > cake.  The
> > graphics capability of Excel is often overlooked.
> >
> > Cheers,
> >
> > Jeff
> >
> >
> > -----Original Message-----
> > From: matlab@matl... [mailto:matlab@matl...]On Behalf Of
> >
> > chrissoraghan@chri...
> > Sent: 08 March 2006 17:16
> > To: matlab@matl...
> > Subject: [matlab] Break plot up into block intervals in different
> > colours
> >
> >
> > Hi,
> >
> > I have some EEG data. The 1st 45seconds of data is rest data, followed
> > by
> > some stimulation data for 10 seconds. Again another 45 seconds of rest
> > and
> > another 10 seconds of stimulation data.
> >
> > I want to have the first 45seconds of the plot in white and the next 10
> > seconds in green to show the rest-to-stimulation transition (and again
> > another 45seconds of white and 10 seconds of white). I have seen this
> > displayed in some papers but i have no idea how to do it.
> >
> > e.g.
> > ¦data with white background¦data with green background¦
> >
> >
> > ...where ¦ is the transition between the rest and stimulation data
> >
> >
> > Any help appreciated,
> > ChrisJ.
> >
	


(You need to be a member of matlab -- send a blank email to matlab-subscribe@yahoogroups.com )

RE: Break plot up into block intervals in different colours - Premal Madhani - Mar 9 15:32:00 2006

You can also try using the 'patch' function. Say for example the data is stored as  a
vector, data = [segment45 segment10 ... ]. You plot this out and then use the patch function in
a for loop over the number of segments, in every iteration of the for loop, use patch([x1 x2 x2
x1],[y1 y1 y2 y2],[0 1 0]) for segment45 where (x1,y1),(x2,y2),(x1,y2) and (x2,y1) are the end
points of rectangular patch and the end parameter is for green color. To plot the patch in the
background so you can see the plot, use a = get(gca,'child');set(gca,'child',flipud(a)).
Similarly plot a patch for segment10.
   
  Premal

Jeff Winter <jeff.winter@jeff...> wrote:
      Hi Chris,
   
  One way of plotting the points in a different colour is to create a number of arrays (equal
to the number of transitions) that are of the same length as the total data you want to plot.
   
  If your data is: rest1 ¦ stim1 ¦ rest2 ¦ stim2 which for arguments sake is 110 samples long,
then the aim is to have 4 arrays (of the same length so that plot doesn't moan) that contain
some of the data:
  rest1 ¦ ----- ¦ ----- ¦ ----- 
  ----- ¦ stim1 ¦ ----- ¦ -----
  ----- ¦ ----- ¦ rest2 ¦ ----- 
  ----- ¦ ----- ¦ ----- ¦ stim2
   
  To plot each of these segments you'll need 4 zero'd arrays the same length as your data:
  array1 = zeros(1,110); array2 = array1 ; array1 ; array4 = array1 ; 
   
  Then all you need to do is copy the correct part of each data segment into one of the new
arrays. However, you will want to offset the start point of your data entry into each new
array. e.g.:
  If rest1 is 45 samples long, then array1(1:45) = data(1:45);
  If stim1 is 10 samples long, then array2(46:55) = data(46:55);
  If rest2 is 45 samples long, then array2(56:100) = data(56:100);
  If stim2 is 10 samples long, then array2(101:110) = data(101:110);
   
  Now you should be able to plot all four arrays of any colour you want on top of each other so
that each transition is in a different colour.
  This does assume that you know the sample rate the data was recorded at, so that you can work
out what the array indexing should be. 
   
  The down side to this is that the zeros will also be plotted.  As Matlab plots all the points
in a standard plot this will make the intercept points on your graph look odd.  However, you
could plot the points in different colours and symbols using this technique on top of a grey
line for example.
   
  In any case this is one way to segment your data.
   
  Cheers,
   
  Jeff
    -----Original Message-----
From: Christopher Soraghan [mailto:chrissoraghan@chri...]
Sent: 09 March 2006 17:39
To: jeff.winter@jeff...
Cc: Subject: Re: [matlab] Break plot up into block intervals in different colours
	  Hi Jeff, 
   
  The Excel idea will work but i would rather try and keep it within Matlab. There will be many
tests like this and the protocols for each will not always adhere to the same rest and
stimulation periods of 45seconds and 10seconds as mentioned previously. I have to perform some
pre and post processing to the noisy data and apply other algorithms to SOME of the results so
I would like to find a way to control the graphics of matlab as mentioned below and be able to
change the lenght of time for the different states, rest stimulation, semi stimulation. Really
im looking for a way to section off different states in the plot with colour ID, of green and
white as mentioned below. If i cannot get the info on how to do it I will use Excel for the
time being but it would be better to have a function m-file to adjust the graphics, as with '
bar.m' etc. Thanks for the help Jeff,
   
  ChrisJ
	  On 3/9/06, Jeff Winter <jeff.winter@jeff...> wrote:   Hi Chris,

For once I'd say use MS Excel rather than Matlab. It's a piece of cake.  The
graphics capability of Excel is often overlooked. 

Cheers,

Jeff
	-----Original Message-----
From: matlab@matl... [mailto:matlab@matl...]On Behalf Of 
chrissoraghan@chri...
Sent: 08 March 2006 17:16
To: matlab@matl...
Subject: [matlab] Break plot up into block intervals in different 
colours
	Hi,

I have some EEG data. The 1st 45seconds of data is rest data, followed by
some stimulation data for 10 seconds. Again another 45 seconds of rest and
another 10 seconds of stimulation data. 

I want to have the first 45seconds of the plot in white and the next 10
seconds in green to show the rest-to-stimulation transition (and again
another 45seconds of white and 10 seconds of white). I have seen this 
displayed in some papers but i have no idea how to do it.

e.g.
¦data with white background¦data with green background¦
	...where ¦ is the transition between the rest and stimulation data
	Any help appreciated,
ChrisJ.
	


(You need to be a member of matlab -- send a blank email to matlab-subscribe@yahoogroups.com )

RE: Break plot up into block intervals in different colours - Tolga Özkurt - Mar 9 15:51:00 2006

Well, If I understand your correctly, all you will do
simply should be something like: 

----------------------------------------
plot(1:45, eeg(1:45));
hold on;
plot(45:100, eeg(45:100),'r')
hold on;
plot(100:150, eeg(100:150),'g')
-----------------------------------------

the indices will definitely change depending on the
sampling frequency. hope it helps.
	tolga esat ozkurt

--- Jeff Winter <jeff.winter@jeff...> wrote:

> Hi Chris,
> 
> One way of plotting the points in a different colour
> is to create a number
> of arrays (equal to the number of transitions) that
> are of the same length
> as the total data you want to plot.
> 
> If your data is: rest1 ¦ stim1 ¦ rest2 ¦ stim2 which
> for arguments sake is
> 110 samples long, then the aim is to have 4 arrays
> (of the same length so
> that plot doesn't moan) that contain some of the
> data:
> rest1 ¦ ----- ¦ ----- ¦ -----
> ----- ¦ stim1 ¦ ----- ¦ -----
> ----- ¦ ----- ¦ rest2 ¦ -----
> ----- ¦ ----- ¦ ----- ¦ stim2
> 
> To plot each of these segments you'll need 4 zero'd
> arrays the same length
> as your data:
> array1 = zeros(1,110); array2 = array1 ; array1 ;
> array4 = array1 ;
> 
> Then all you need to do is copy the correct part of
> each data segment into
> one of the new arrays. However, you will want to
> offset the start point of
> your data entry into each new array. e.g.:
> If rest1 is 45 samples long, then array1(1:45) =
> data(1:45);
> If stim1 is 10 samples long, then array2(46:55) =
> data(46:55);
> If rest2 is 45 samples long, then array2(56:100) =
> data(56:100);
> If stim2 is 10 samples long, then array2(101:110) =
> data(101:110);
> 
> Now you should be able to plot all four arrays of
> any colour you want on top
> of each other so that each transition is in a
> different colour.
> This does assume that you know the sample rate the
> data was recorded at, so
> that you can work out what the array indexing should
> be.
> 
> The down side to this is that the zeros will also be
> plotted.  As Matlab
> plots all the points in a standard plot this will
> make the intercept points
> on your graph look odd.  However, you could plot the
> points in different
> colours and symbols using this technique on top of a
> grey line for example.
> 
> In any case this is one way to segment your data.
> 
> Cheers,
> 
> Jeff
>   -----Original Message-----
>   From: Christopher Soraghan
> [mailto:chrissoraghan@chri...]
>   Sent: 09 March 2006 17:39
>   To: jeff.winter@jeff...
>   Cc: Subject: Re: [matlab] Break plot up into block
> intervals in different
> colours
> 
> 
>   Hi Jeff,
> 
>   The Excel idea will work but i would rather try
> and keep it within Matlab.
> There will be many tests like this and the protocols
> for each will not
> always adhere to the same rest and stimulation
> periods of 45seconds and
> 10seconds as mentioned previously. I have to perform
> some pre and post
> processing to the noisy data and apply other
> algorithms to SOME of the
> results so I would like to find a way to control the
> graphics of matlab as
> mentioned below and be able to change the lenght of
> time for the different
> states, rest stimulation, semi stimulation. Really
> im looking for a way to
> section off different states in the plot with colour
> ID, of green and white
> as mentioned below. If i cannot get the info on how
> to do it I will use
> Excel for the time being but it would be better to
> have a function m-file to
> adjust the graphics, as with ' bar.m' etc. Thanks
> for the help Jeff,
> 
>   ChrisJ
> 
> 
> 
>   On 3/9/06, Jeff Winter <jeff.winter@jeff...>
> wrote:
>     Hi Chris,
> 
>     For once I'd say use MS Excel rather than
> Matlab. It's a piece of cake.
> The
>     graphics capability of Excel is often
> overlooked.
> 
>     Cheers,
> 
>     Jeff
> 
> 
>     -----Original Message-----
>     From: matlab@matl...
> [mailto:matlab@matl...]On Behalf Of
>     chrissoraghan@chri...
>     Sent: 08 March 2006 17:16
>     To: matlab@matl...
>     Subject: [matlab] Break plot up into block
> intervals in different
>     colours
> 
> 
>     Hi,
> 
>     I have some EEG data. The 1st 45seconds of data
> is rest data, followed
> by
>     some stimulation data for 10 seconds. Again
> another 45 seconds of rest
> and
>     another 10 seconds of stimulation data.
> 
>     I want to have the first 45seconds of the plot
> in white and the next 10
>     seconds in green to show the rest-to-stimulation
> transition (and again
>     another 45seconds of white and 10 seconds of
> white). I have seen this
>     displayed in some papers but i have no idea how
> to do it.
> 
>     e.g.
>     ¦data with white background¦data with green
> background¦
> 
> 
>     ...where ¦ is the transition between the rest
> and stimulation data
> 
> 
>     Any help appreciated,
>     ChrisJ.
>
	


(You need to be a member of matlab -- send a blank email to matlab-subscribe@yahoogroups.com )

Re: Break plot up into block intervals in different colours - ravi...@softhome.net - Mar 10 0:32:00 2006

Hi Chris,
Try using 'hold on'.
Say,your data is in the arrays rest1 ¦ stim1 ¦ rest2 ¦ stim2 .. 

lr1 = length(rest1);
ls1 = length(stim1);
.... 

hold on;
plot(1:lr1,rest1,'r');
plot(lr1+1:lr1+ls1,stim1,'b');
.... 

regards,
Ravi
	Jeff Winter writes: 

> Hi Chris, 
> 
> One way of plotting the points in a different colour is to create a number
> of arrays (equal to the number of transitions) that are of the same length
> as the total data you want to plot. 
> 
> If your data is: rest1 ¦ stim1 ¦ rest2 ¦ stim2 which for arguments sake is
> 110 samples long, then the aim is to have 4 arrays (of the same length so
> that plot doesn't moan) that contain some of the data:
> rest1 ¦ ----- ¦ ----- ¦ -----
> ----- ¦ stim1 ¦ ----- ¦ -----
> ----- ¦ ----- ¦ rest2 ¦ -----
> ----- ¦ ----- ¦ ----- ¦ stim2 
> 
> To plot each of these segments you'll need 4 zero'd arrays the same length
> as your data:
> array1 = zeros(1,110); array2 = array1 ; array1 ; array4 = array1 ; 
> 
> Then all you need to do is copy the correct part of each data segment into
> one of the new arrays. However, you will want to offset the start point of
> your data entry into each new array. e.g.:
> If rest1 is 45 samples long, then array1(1:45) = data(1:45);
> If stim1 is 10 samples long, then array2(46:55) = data(46:55);
> If rest2 is 45 samples long, then array2(56:100) = data(56:100);
> If stim2 is 10 samples long, then array2(101:110) = data(101:110); 
> 
> Now you should be able to plot all four arrays of any colour you want on top
> of each other so that each transition is in a different colour.
> This does assume that you know the sample rate the data was recorded at, so
> that you can work out what the array indexing should be. 
> 
> The down side to this is that the zeros will also be plotted.  As Matlab
> plots all the points in a standard plot this will make the intercept points
> on your graph look odd.  However, you could plot the points in different
> colours and symbols using this technique on top of a grey line for example. 
> 
> In any case this is one way to segment your data. 
> 
> Cheers, 
> 
> Jeff
>   -----Original Message-----
>   From: Christopher Soraghan [mailto:chrissoraghan@chri...]
>   Sent: 09 March 2006 17:39
>   To: jeff.winter@jeff...
>   Cc: Subject: Re: [matlab] Break plot up into block intervals in different
> colours 
> 
> 
>   Hi Jeff, 
> 
>   The Excel idea will work but i would rather try and keep it within Matlab.
> There will be many tests like this and the protocols for each will not
> always adhere to the same rest and stimulation periods of 45seconds and
> 10seconds as mentioned previously. I have to perform some pre and post
> processing to the noisy data and apply other algorithms to SOME of the
> results so I would like to find a way to control the graphics of matlab as
> mentioned below and be able to change the lenght of time for the different
> states, rest stimulation, semi stimulation. Really im looking for a way to
> section off different states in the plot with colour ID, of green and white
> as mentioned below. If i cannot get the info on how to do it I will use
> Excel for the time being but it would be better to have a function m-file to
> adjust the graphics, as with ' bar.m' etc. Thanks for the help Jeff, 
> 
>   ChrisJ 
> 
>  
> 
>   On 3/9/06, Jeff Winter <jeff.winter@jeff...> wrote:
>     Hi Chris, 
> 
>     For once I'd say use MS Excel rather than Matlab. It's a piece of cake.
> The
>     graphics capability of Excel is often overlooked. 
> 
>     Cheers, 
> 
>     Jeff 
> 
> 
>     -----Original Message-----
>     From: matlab@matl... [mailto:matlab@matl...]On Behalf Of
>     chrissoraghan@chri...
>     Sent: 08 March 2006 17:16
>     To: matlab@matl...
>     Subject: [matlab] Break plot up into block intervals in different
>     colours 
> 
> 
>     Hi, 
> 
>     I have some EEG data. The 1st 45seconds of data is rest data, followed
> by
>     some stimulation data for 10 seconds. Again another 45 seconds of rest
> and
>     another 10 seconds of stimulation data. 
> 
>     I want to have the first 45seconds of the plot in white and the next 10
>     seconds in green to show the rest-to-stimulation transition (and again
>     another 45seconds of white and 10 seconds of white). I have seen this
>     displayed in some papers but i have no idea how to do it. 
> 
>     e.g.
>     ¦data with white background¦data with green background¦ 
> 
> 
>     ...where ¦ is the transition between the rest and stimulation data 
> 
> 
>     Any help appreciated,
>     ChrisJ. 
>
	


(You need to be a member of matlab -- send a blank email to matlab-subscribe@yahoogroups.com )

RE: Break plot up into block intervals in different colours - Jeff Winter - Mar 10 9:49:00 2006

Tolga you're a star!

Thanks for pointing that out.

Regards,

Jeff

-----Original Message-----
From: matlab@matl... [mailto:matlab@matl...]On Behalf Of
Tolga Özkurt
Sent: 09 March 2006 19:52
To: matlab@matl...
Subject: RE: [matlab] Break plot up into block intervals in different
colours
	Well, If I understand your correctly, all you will do
simply should be something like:

----------------------------------------
plot(1:45, eeg(1:45));
hold on;
plot(45:100, eeg(45:100),'r')
hold on;
plot(100:150, eeg(100:150),'g')
-----------------------------------------

the indices will definitely change depending on the
sampling frequency. hope it helps.
	tolga esat ozkurt

--- Jeff Winter <jeff.winter@jeff...> wrote:

> Hi Chris,
>
> One way of plotting the points in a different colour
> is to create a number
> of arrays (equal to the number of transitions) that
> are of the same length
> as the total data you want to plot.
>
> If your data is: rest1 ¦ stim1 ¦ rest2 ¦ stim2 which
> for arguments sake is
> 110 samples long, then the aim is to have 4 arrays
> (of the same length so
> that plot doesn't moan) that contain some of the
> data:
> rest1 ¦ ----- ¦ ----- ¦ -----
> ----- ¦ stim1 ¦ ----- ¦ -----
> ----- ¦ ----- ¦ rest2 ¦ -----
> ----- ¦ ----- ¦ ----- ¦ stim2
>
> To plot each of these segments you'll need 4 zero'd
> arrays the same length
> as your data:
> array1 = zeros(1,110); array2 = array1 ; array1 ;
> array4 = array1 ;
>
> Then all you need to do is copy the correct part of
> each data segment into
> one of the new arrays. However, you will want to
> offset the start point of
> your data entry into each new array. e.g.:
> If rest1 is 45 samples long, then array1(1:45) =
> data(1:45);
> If stim1 is 10 samples long, then array2(46:55) =
> data(46:55);
> If rest2 is 45 samples long, then array2(56:100) =
> data(56:100);
> If stim2 is 10 samples long, then array2(101:110) =
> data(101:110);
>
> Now you should be able to plot all four arrays of
> any colour you want on top
> of each other so that each transition is in a
> different colour.
> This does assume that you know the sample rate the
> data was recorded at, so
> that you can work out what the array indexing should
> be.
>
> The down side to this is that the zeros will also be
> plotted.  As Matlab
> plots all the points in a standard plot this will
> make the intercept points
> on your graph look odd.  However, you could plot the
> points in different
> colours and symbols using this technique on top of a
> grey line for example.
>
> In any case this is one way to segment your data.
>
> Cheers,
>
> Jeff
>   -----Original Message-----
>   From: Christopher Soraghan
> [mailto:chrissoraghan@chri...]
>   Sent: 09 March 2006 17:39
>   To: jeff.winter@jeff...
>   Cc: Subject: Re: [matlab] Break plot up into block
> intervals in different
> colours
>
>
>   Hi Jeff,
>
>   The Excel idea will work but i would rather try
> and keep it within Matlab.
> There will be many tests like this and the protocols
> for each will not
> always adhere to the same rest and stimulation
> periods of 45seconds and
> 10seconds as mentioned previously. I have to perform
> some pre and post
> processing to the noisy data and apply other
> algorithms to SOME of the
> results so I would like to find a way to control the
> graphics of matlab as
> mentioned below and be able to change the lenght of
> time for the different
> states, rest stimulation, semi stimulation. Really
> im looking for a way to
> section off different states in the plot with colour
> ID, of green and white
> as mentioned below. If i cannot get the info on how
> to do it I will use
> Excel for the time being but it would be better to
> have a function m-file to
> adjust the graphics, as with ' bar.m' etc. Thanks
> for the help Jeff,
>
>   ChrisJ
>
>
>
>   On 3/9/06, Jeff Winter <jeff.winter@jeff...>
> wrote:
>     Hi Chris,
>
>     For once I'd say use MS Excel rather than
> Matlab. It's a piece of cake.
> The
>     graphics capability of Excel is often
> overlooked.
>
>     Cheers,
>
>     Jeff
>
>
>     -----Original Message-----
>     From: matlab@matl...
> [mailto:matlab@matl...]On Behalf Of
>     chrissoraghan@chri...
>     Sent: 08 March 2006 17:16
>     To: matlab@matl...
>     Subject: [matlab] Break plot up into block
> intervals in different
>     colours
>
>
>     Hi,
>
>     I have some EEG data. The 1st 45seconds of data
> is rest data, followed
> by
>     some stimulation data for 10 seconds. Again
> another 45 seconds of rest
> and
>     another 10 seconds of stimulation data.
>
>     I want to have the first 45seconds of the plot
> in white and the next 10
>     seconds in green to show the rest-to-stimulation
> transition (and again
>     another 45seconds of white and 10 seconds of
> white). I have seen this
>     displayed in some papers but i have no idea how
> to do it.
>
>     e.g.
>     ¦data with white background¦data with green
> background¦
>
>
>     ...where ¦ is the transition between the rest
> and stimulation data
>
>
>     Any help appreciated,
>     ChrisJ.
>
	


(You need to be a member of matlab -- send a blank email to matlab-subscribe@yahoogroups.com )

Re: Break plot up into block intervals in different colours - Christopher Soraghan - Mar 10 11:52:00 2006

Thank you all for the help. The explanation by Tolga has been the simplest

and quickest but very efficient. Here is the code:

****

seg1_len = (1:(rest_per*fs));

seg2_len = (((rest_per)*fs):((rest_per+stim_per)*fs));

seg3_len = (((rest_per+stim_per)*fs):((rest_per*2+stim_per)*fs));

seg4_len = (((rest_per*2+stim_per)*fs):((rest_per*2+stim_per*2)*fs));

plot( seg1_len, oxy(seg1_len), 'b');

hold on

plot(seg2_len, oxy(seg2_len),'k');

plot(seg3_len, oxy(seg3_len), 'b');

plot(seg4_len, oxy(seg4_len), 'k');

****
Thanks again,
I second that, fair play Tolga, thanks too Jeff,

Chris.
	On 3/10/06, Jeff Winter <jeff.winter@jeff...> wrote:
>
> Tolga you're a star!
>
> Thanks for pointing that out.
>
> Regards,
>
> Jeff
>
> -----Original Message-----
> From: matlab@matl... [mailto:matlab@matl...]On Behalf Of
> Tolga Özkurt
> Sent: 09 March 2006 19:52
> To: matlab@matl...
> Subject: RE: [matlab] Break plot up into block intervals in different
> colours
>
>
> Well, If I understand your correctly, all you will do
> simply should be something like:
>
> ----------------------------------------
> plot(1:45, eeg(1:45));
> hold on;
> plot(45:100, eeg(45:100),'r')
> hold on;
> plot(100:150, eeg(100:150),'g')
> -----------------------------------------
>
> the indices will definitely change depending on the
> sampling frequency. hope it helps.
>
>
> tolga esat ozkurt
>
> --- Jeff Winter <jeff.winter@jeff...> wrote:
>
> > Hi Chris,
> >
> > One way of plotting the points in a different colour
> > is to create a number
> > of arrays (equal to the number of transitions) that
> > are of the same length
> > as the total data you want to plot.
> >
> > If your data is: rest1 ¦ stim1 ¦ rest2 ¦ stim2 which
> > for arguments sake is
> > 110 samples long, then the aim is to have 4 arrays
> > (of the same length so
> > that plot doesn't moan) that contain some of the
> > data:
> > rest1 ¦ ----- ¦ ----- ¦ -----
> > ----- ¦ stim1 ¦ ----- ¦ -----
> > ----- ¦ ----- ¦ rest2 ¦ -----
> > ----- ¦ ----- ¦ ----- ¦ stim2
> >
> > To plot each of these segments you'll need 4 zero'd
> > arrays the same length
> > as your data:
> > array1 = zeros(1,110); array2 = array1 ; array1 ;
> > array4 = array1 ;
> >
> > Then all you need to do is copy the correct part of
> > each data segment into
> > one of the new arrays. However, you will want to
> > offset the start point of
> > your data entry into each new array. e.g.:
> > If rest1 is 45 samples long, then array1(1:45) =
> > data(1:45);
> > If stim1 is 10 samples long, then array2(46:55) =
> > data(46:55);
> > If rest2 is 45 samples long, then array2(56:100) =
> > data(56:100);
> > If stim2 is 10 samples long, then array2(101:110) =
> > data(101:110);
> >
> > Now you should be able to plot all four arrays of
> > any colour you want on top
> > of each other so that each transition is in a
> > different colour.
> > This does assume that you know the sample rate the
> > data was recorded at, so
> > that you can work out what the array indexing should
> > be.
> >
> > The down side to this is that the zeros will also be
> > plotted.  As Matlab
> > plots all the points in a standard plot this will
> > make the intercept points
> > on your graph look odd.  However, you could plot the
> > points in different
> > colours and symbols using this technique on top of a
> > grey line for example.
> >
> > In any case this is one way to segment your data.
> >
> > Cheers,
> >
> > Jeff
> >   -----Original Message-----
> >   From: Christopher Soraghan
> > [mailto:chrissoraghan@chri...]
> >   Sent: 09 March 2006 17:39
> >   To: jeff.winter@jeff...
> >   Cc: Subject: Re: [matlab] Break plot up into block
> > intervals in different
> > colours
> >
> >
> >   Hi Jeff,
> >
> >   The Excel idea will work but i would rather try
> > and keep it within Matlab.
> > There will be many tests like this and the protocols
> > for each will not
> > always adhere to the same rest and stimulation
> > periods of 45seconds and
> > 10seconds as mentioned previously. I have to perform
> > some pre and post
> > processing to the noisy data and apply other
> > algorithms to SOME of the
> > results so I would like to find a way to control the
> > graphics of matlab as
> > mentioned below and be able to change the lenght of
> > time for the different
> > states, rest stimulation, semi stimulation. Really
> > im looking for a way to
> > section off different states in the plot with colour
> > ID, of green and white
> > as mentioned below. If i cannot get the info on how
> > to do it I will use
> > Excel for the time being but it would be better to
> > have a function m-file to
> > adjust the graphics, as with ' bar.m' etc. Thanks
> > for the help Jeff,
> >
> >   ChrisJ
> >
> >
> >
> >   On 3/9/06, Jeff Winter <jeff.winter@jeff...>
> > wrote:
> >     Hi Chris,
> >
> >     For once I'd say use MS Excel rather than
> > Matlab. It's a piece of cake.
> > The
> >     graphics capability of Excel is often
> > overlooked.
> >
> >     Cheers,
> >
> >     Jeff
> >
> >
> >     -----Original Message-----
> >     From: matlab@matl...
> > [mailto:matlab@matl...]On Behalf Of
> >     chrissoraghan@chri...
> >     Sent: 08 March 2006 17:16
> >     To: matlab@matl...
> >     Subject: [matlab] Break plot up into block
> > intervals in different
> >     colours
> >
> >
> >     Hi,
> >
> >     I have some EEG data. The 1st 45seconds of data
> > is rest data, followed
> > by
> >     some stimulation data for 10 seconds. Again
> > another 45 seconds of rest
> > and
> >     another 10 seconds of stimulation data.
> >
> >     I want to have the first 45seconds of the plot
> > in white and the next 10
> >     seconds in green to show the rest-to-stimulation
> > transition (and again
> >     another 45seconds of white and 10 seconds of
> > white). I have seen this
> >     displayed in some papers but i have no idea how
> > to do it.
> >
> >     e.g.
> >     ¦data with white background¦data with green
> > background¦
> >
> >
> >     ...where ¦ is the transition between the rest
> > and stimulation data
> >
> >
> >     Any help appreciated,
> >     ChrisJ.
> >
	


(You need to be a member of matlab -- send a blank email to matlab-subscribe@yahoogroups.com )