05-10-2020 04:07 AM
I have data in Excel (see attached example) where column 1 contains the timing info and columns 2, 3 etc are the measurements at those time points
I can use the Read from Spreadsheet.vi to display these data on a Waveform Graph (see attached script). However the x-axis defaults to the row number. How do I display these data using the column 1 timing info as the x-axis instead?
05-10-2020 08:33 AM
You need to learn the difference between a Waveform Graph and an XY Graph. Do you know what a Waveform is? Use the LabVIEW Help to learn about the difference.
But briefly, a Waveform is a Cluster-like data structure that is used for data collected by sampling at a fixed sampling interval (called "dt"). It consists mainly of the Y component, deriving the X component from knowing the time of the initial Sample ("t0") and, for each successive point, adding "dt". If it sees an Array of data, it assume you have an Array of Waveforms, each representing a different sample "channel".
To plot independent X and Y (where, for example, the X values are not uniformly-separated times of the samples, as in your case), you use an X-Y Graph, and present the X and Y data separately (see the Help, or learn about XY Graphs, to learn how to do this).
Bob Schor
05-10-2020 11:13 AM - edited 05-10-2020 11:16 AM
Building a waveform is only appropriate if the x-axis is time. In my cases it typically isn't. Also, your x-values are truncated to about 3 significant digits, so getting the x-spacing might accumulate error if you only look at e.g. the first two x points. You might want to do a linear fit instead.
As Bob already mentioned, you somehow need to tell the graph how to map array indices to x-values. If x0,dx is always the same, you can even ignore the first column and set them manually via the axis properties of the graph. Use the property node if each dataset has different x-ramp.
The attached VI contains four ways to define the x-axis. An xy graph is only needed if the x-values are not linear with array index. A waveform only makes sense if x is time. Is it? The cluster is a special case. Waveform graphs accept a cluster of [scalarA, scalarB, 1 or 2D array], interpreting A as offset and B as slope.
05-10-2020 12:47 PM
thanks for this great advice
With my data the x axis is always time, with sampling at regular time intervals (data captured by 30Hz camera, so intervals are approx 33msec) so this needs to be displayed (and further analysed) as waveform not XY data
You have moved me past the blockage, and I appreciate that greatly!🙂
05-10-2020 01:52 PM - edited 05-10-2020 01:53 PM
@FionB wrote:
thanks for this great advice
With my data the x axis is always time, with sampling at regular time intervals (data captured by 30Hz camera, so intervals are approx 33msec) so this needs to be displayed (and further analysed) as waveform not XY data
You have moved me past the blockage, and I appreciate that greatly!🙂
Not entirely past the blockage, because every waveform is actually XY data, when it comes down to it. The misunderstanding here is that, in LabVIEW, a "waveform" is XY data presented in a very specific format. The waveform graph is only useful when you have data already in that format. (Please read Bob's discussion in this topic carefully - he explains it quite well.)
05-10-2020 03:43 PM
@FionB wrote:
thanks for this great advice
With my data the x axis is always time, with sampling at regular time intervals (data captured by 30Hz camera, so intervals are approx 33msec) so this needs to be displayed (and further analysed) as waveform not XY data
🙂
Nobody forces you to use waveform data. While there are some processing tools that utilize waveform data directly, you have more options if you don't pigeonhole yourself into waveforms. 😉 (I never use waveform data. Too limiting for me ;)).
05-10-2020 09:20 PM
How is the Time (X) column generated? If you are really taking frames at a fixed rate with the camera, you are acquiring images using the "clock" inside the camera. Looking at the numbers in the first column, they do not show equal increments, as though they were generated by the much-less-accurate PC millisecond clock. Saving inaccurate data is sometimes worse than saving no data (especially when you can "generate" accurate and precise values, in this case using an increment of 1/30 = 0.03333333333333...).
Bob Schor
05-11-2020 10:57 AM
I am a doctor, and the data (including time stamp) are generated by a proprietary medical device (i.e. in effect a 'black box'); I am therefore not in control of the data acquisition or it's level of accuracy, I just want to extract the raw numbers for further data analysis.
Although I have no doubt you are correct in theory about the merits of camera clocks versus PC clocks, as a pragmatist I have to say in the context of biodata for clinical research purposes the timing accuracy in these data is sufficient for answering my clinical questions. It is also worth pointing out the poor temporal resolution of a 30Hz camera which already places significant limitations on the accuracy of the timestamps for data capture.
05-11-2020 01:53 PM
If you know the exact t0 and dt, just manually set it to that for the axis. The main problem is that your time column is rounded (hopefully not truncated!) to three decimal digits and much less precise, i.e. there is jitter in the distance between points due to rounding. The problem is the formatting. However using my method of getting the slope and intercept from a linear fit of all time points with give you an excellent estimate because it averages the error over all available points..