| Author |
Message |
glyn68
Joined: Jul 5, 2008 Posts: 18
|
Posted: Jul 5, 2008 8:58 PM Post subject: Output sample rate of logicals |
|
Dear BioEra community, I am new to this forum, and pretty new to bioera. I am a biofeedback therapist based in york, England, and keen programmer. The first (probably of many) questions I would like to pose is this: I want to send the output of a threshold (pass/fail) to an oscilloscope. I expected to see a square wave, moving between 0 and 1. I set up this oscilloscope next to another, with the same time scale. I thought the signals would just move together, but they don't. I'm used to thinking in (dare I say it) bioexplorer terms, where the output sample rate is always the same as the input sample rate, but it appears bioera isn't like that. What I ultimately want to do, is time the interval between two instances when a threshold is crossed. Thank you for any advice/clarification. Best wishes,
Glyn Blackett |
|
 |
jarek
Joined: Oct 22, 2007 Posts: 1075
|
Posted: Jul 5, 2008 10:09 PM Post subject: |
|
Glyn,
yes, rate can be different in many spots of the same design. In fact all signal parameters can be different, that is why each element has ability to set signal parameters in Advanced Properties. Logical output sends a value usually when the level changes, performance if better this way.
If you want to have two oscilloscopes one under another, then I created a simple design which shows how to show a square wave on the bottom oscilloscope. Please note: the advanced properties of the Buffer element are modified, so that its Signal Parameters are the same as in the signal coming to the first Oscilloscope.
The snippet design:
http://bioera.net/support/designs/timeinterval.bpd
Jarek
|
|
 |
glyn68
Joined: Jul 5, 2008 Posts: 18
|
Posted: Jul 6, 2008 6:19 PM Post subject: |
|
Jarek, Many thanks for the design. Using the Buffer is certainly a step forward. I'm developing a heart beat detector based on ECG. Well I've got a threshold object that reliably picks up each beat. I can save the time of a beat using the Buffer object, which is connected to a Time Source. The next task is to calculate an inter-beat interval (IBI) - the interval between the last beat and the current. I've tried using an ExpressionEvaluator. In1 is the logical from the beat detector threshold object. In2 is the time. In3 is the stored time of the last beat. The expression I've tried is: Out1 = (In1 is true) ? In2 - In3 : Out1; - but it doesn't seem to work. Any thoughts? Many thanks again,
Glyn |
|
 |
jarek
Joined: Oct 22, 2007 Posts: 1075
|
Posted: Jul 6, 2008 8:05 PM Post subject: |
|
Glyn,
the expression should probably look like that:
Out1 = (In1 > 0) ? In2 - In3 : Out1;
Because logical values in BioEra are 1 or 0 (numeric).
Jarek
|
|
 |
glyn68
Joined: Jul 5, 2008 Posts: 18
|
Posted: Jul 6, 2008 8:09 PM Post subject: |
|
Thanks Jarek. I actually had
Out1 = (In1 == 1) ? In2 - In3 : Out1;
I'll try your version tomorrow at the office. Best,
Glyn |
|
 |
glyn68
Joined: Jul 5, 2008 Posts: 18
|
Posted: Jul 7, 2008 7:24 PM Post subject: |
|
Hi Jarek, I've tried incorporating your ideas about getting a square wave on an oscilloscope. Something very strange seems to be going on. I have my ECG trace, and I have a threshold object which is definitely detecting the spikes in the ECG trace (heart beats). I pass the threshold logical output to my oscilloscope via a buffer object. I see a square wave train as expected, with short pulses where the threshold output is 1. But the strange thing is, some of the beats are missing from this trace. I'd say about 1 in 10 don't show, and it appears random. I know the beats are detected because I can see the threshold as a dotted line. Also I record the time of each beat, successfully. I can't imagine what can be going on. (My method of calculating inter-beat interval is not working at all, either.) Any ideas? A question: under advanced properties, we have the signal parameters listed. What does checking the box achieve? Many thanks again,
Glyn |
|
 |
jarek
Joined: Oct 22, 2007 Posts: 1075
|
Posted: Jul 7, 2008 8:05 PM Post subject: |
|
Hi Glyn,
it is hard to tell what is wrong without analyzing the design. I understand you are recording times correctly, which means they peaks are detected properly, just not shown. Maybe the time above the threshold is too short to show on display?
I will try to find my older design for the HR detection and post it here. It measures and displays also the R-R interval time.
> under advanced properties, we have the signal parameters listed. What does checking the box achieve
When a box is checked, then you can modify and set constant the value on the right side. If it is not checked, then the value is automatically taken from the element connected to first input. Signal parameters propagate through connected elements.
Jarek |
|
 |
glyn68
Joined: Jul 5, 2008 Posts: 18
|
Posted: Jul 8, 2008 11:48 AM Post subject: |
|
Hi Jarek, I would really like to see your HR detection design, if you can find it. Best wishes and thanks,
Glyn |
|
 |
jarek
Joined: Oct 22, 2007 Posts: 1075
|
Posted: Jul 8, 2008 3:21 PM Post subject: |
|
Glyn,
try this one and let me know. It may need improvement, it was created long time ago. Make sure you copy design and edf file to right folders (like in the zip file).
bioera.net/support/designs/hr.zip
Jarek |
|
 |
glyn68
Joined: Jul 5, 2008 Posts: 18
|
Posted: Jul 9, 2008 9:40 PM Post subject: |
|
Hi Jarek, Many thanks for the HR design. I was able to take elements of it to get my own design working. (The key one was the Transform object which outputs the difference between the last two samples received.) A couple of points/questions arose:
1. It seems that the only way to force the output sample rate upwards is to use the buffer object. For example, I tried to use an activity generator with output rate set to 256 in advanced properties, and its input coming from a logical output of a threshold object. But it still only passes on changes as and when they arrive. Is this right? Can I conclude that checking the rate box of an object's signal parameters, will reduce the rate downwards, but will not be able to increase it?
2. Before I was attempting to use the ExpressionEvaluator object, with In1 a logical from a threshold output, In2 a time from a TimeSource, and In3 coming from a Buffer. In2 and In3 input rates would have been 256, but not In1. What would be the output rate? How often would the expression get evaluated? The output was not what I would have expected. Would you say, it is a bad idea to mix input rates in an ExpressionEvaluator object like that? Many thanks,
Glyn |
|
 |
glyn68
Joined: Jul 5, 2008 Posts: 18
|
Posted: Jul 9, 2008 9:51 PM Post subject: |
|
Hi Jarek, I'm suffering more problems with getting my oscilloscope to display properly. I've calculated a heart rate based on an ECG signal, and I'm sending it to the oscilloscope. I want it to display 50 to 90 on the vertical scale. I set the properties and advanced properties just as I did before. The only difference is the signal - this time it is coming from a calculation, before it was coming from the J&J source. I need a better understanding of the signal properties - digi max and min etc. Several objects have the max and min values as +1,-1, and sometimes I see the rate as 0 - but these can't be right? For example, I'm using a TimeSource object, which has these signal properties. How can I determine the real characteristics of my signal?
Also, in the Oscilloscope, does amplitude range X mean 0 to X or -X to +X?
Thanks if you can clarify,
Glyn |
|
 |
jarek
Joined: Oct 22, 2007 Posts: 1075
|
Posted: Jul 9, 2008 9:56 PM Post subject: |
|
Glyn,
1. When you change the rate value in Advanced Properties, this is only a description which is used by the following elements (for example Oscilloscope) to properly calculate time (which is based on number of incoming samples). Changing this value doesn't change how data samples are transferred. It doesn't increase or decrease anything.
The actual rate change is performed by Buffer (in this case), which is triggered 256 times per second, and therefore it sends 256 values per second.
2. The ExpressionEvaluator can process data from sources of different rate. It performs a calculation when at least one sample arrives to at least one input. If a sample arrives only to Input1, but not Input2, then previous value is used for In2 variable (previous value is remembered). This means that the output rate of ExpressionEvaluator is the same as the highest input rate. It is not bad to mix it like that, but you need to know what you are doing.
Jarek
|
|
 |
jarek
Joined: Oct 22, 2007 Posts: 1075
|
Posted: Jul 9, 2008 10:09 PM Post subject: |
|
Glyn,
the rate=0 is unusual, but it can be fine if the signal is very rare. For example SystemEventSource may send a value only one time: during start and never again. So in long term this means rate 0.
The actual rate is not always required. It is necessary only by elements which use it to calculate time. For example Oscilloscope knows that with rate 256sps, it takes 256 input samples for 1 second of data. But other (most) elements like NumericDisplay don't care about the rate, so they will work even with rate=0.
Data range can be 0..X or -X..+X, but nothing else than that. It is either positive, or evenly balanced (for example it can't be 1..10 or -5..10). Oscilloscope (and others) detects it from Signal Properties of the element connected to its input. You can see the Signal Properties either in AdvancedPropeties, or select element and type key 's'.
Jarek
|
|