07-19-2019 12:09 PM
Hi all,
I have an application I'm developing that reads in recorded data from a file on disk (was recorded by a non-NI DAQ).
I am trying to determine the best data type to use to work with the data in Labview. The end goal of my application is to translate the data into another file format.
My data is stored in 16 bit binary format. I have all the information to convert each data point to a scalar. I also have the following time information for each channel:
I was thinking of using the waveform data type to organize my data before I write it to the output file. I was looking at the documentation for the waveform type and if I understand correctly, t0 corresponds to the start time of my first data sample (absolute time).
Is there a way to create a waveform with a relative time (i.e. my data starts at -1024 ms and ends at +6000 ms)?
Is there a better data type to use? I also considered an array of clusters, where each cluster contains a channel's metadata and an array of data points.
07-19-2019
02:21 PM
- last edited on
11-07-2024
01:16 PM
by
Content Cleaner
Waveforms support Attributes which can store metadata:
https://www.ni.com/docs/en-US/bundle/labview-api-ref/page/functions/set-waveform-attribute.html
07-19-2019 02:47 PM
I see two ways:
1. Two arrays. One with data and second with properties in class. Classes you may use in other projects and it have properties, methods and private settings.
2. Variant. labview 2017 has a functions for recognize datatype inside variant. Or you can store data type in attributes of variant.
07-21-2019 09:51 AM
Waveform with "Pre-trigger" Attribute sounds reasonable and efficient. Leave t0 "as is" (if you have it, use it, otherwise you can set it to 0, which will look like a time near midnight on New Years Day, 1905), set dt to your sampling time (0.001), and set Pre-Trigger to 1024 (and save an Array of 1024 + 6000 Dbls, scaling them as appropriate to "useful Units" instead of 16-bit integers, unscaled).
Bob Schor
07-22-2019
12:51 AM
- last edited on
11-07-2024
01:17 PM
by
Content Cleaner
Hi to all. I don't know why do you use the "t0" propertie? NI waveform has a builtin properties.
t0 = NI_ExpStartTimeStamp;
Name = NI_ChannelName.
All of that properties shown in help link.
07-22-2019
08:31 AM
- last edited on
11-07-2024
01:17 PM
by
Content Cleaner
Bob,
Which attribute is the Pre-trigger one? The documentation I can find is:
https://www.ni.com/docs/en-US/bundle/labview-api-ref/page/functions/set-waveform-attribute.html
Do I use the "NI_ExpTimeStamp" and set it to -1024 (see attached vi snip)?
07-22-2019 08:54 AM
@sirwin wrote:
Is there a way to create a waveform with a relative time (i.e. my data starts at -1024 ms and ends at +6000 ms)?
Sorry, I was unclear. As I understand your description of your data, when you start sampling, the first 1024 ms of the sample occur before the "real" stimulus occurs, and you then record for an additional 6000 ms. Your Waveform's t0 corresponds to the start of the entire session (1024 msec before the stimulus). What I was suggesting is to create a Waveform Attribute called "Pre-Trigger" and set it to 1024 (or 1.024, depending on whether you make it an I32 in milliseconds or a Dbl in seconds). When you go to process these data, you could read this Waveform Attribute and account for this offset as you wish. This preserves the body of the Waveform Definition that NI has created, so you can use "regular Waveform functions" to process your data. One of these could be to write a VI that takes a "Waveform with Pre-Trigger" and returns a Waveform with the Pre-Trigger part removed, i.e. a Waveform that starts at the Trigger point. Here's how you'd make this:
Bob Schor
07-22-2019 09:21 AM
@sirwin wrote:
Which attribute is the Pre-trigger one
Bob was suggesting to use the Attribute variant, which you can have any number of variant attributes inside of.
07-22-2019
11:08 AM
- last edited on
11-07-2024
01:17 PM
by
Content Cleaner
@sirwin wrote:
Bob,
Which attribute is the Pre-trigger one? The documentation I can find is:
https://www.ni.com/docs/en-US/bundle/labview-api-ref/page/functions/set-waveform-attribute.html
Do I use the "NI_ExpTimeStamp" and set it to -1024 (see attached vi snip)?
Attribute names can be anything- there are a handful that NI uses for some "under the hood" stuff. I'd just use the name "Pretrigger" where you have "NI_ExpTimeStamp" and call it a day. Attributes work as key-value pairs, where the key can be anything and the value can be any datatype (AFAIK).