LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

extract random portion of signal

Solved!
Go to solution

If I am loading a signal from an LVM file, is there a way to extract a random portion of the signal?  Just some background, I will be loading multiple files in through a for loop/case structure, and each of the files may be of different lengths, so I won't know ahead of time how long the signal is.

 

thanks,

George

0 Kudos
Message 1 of 12
(3,947 Views)
Not sure what your data looks like as I havent worked with LVM files but can you use read spreadsheet file? You can then get the size of the array it returns and you will know how to limit the range it can randomly select from based on the size of the array.
Message Edited by for(imstuck) on 05-14-2009 04:55 PM
0 Kudos
Message 2 of 12
(3,942 Views)
I don't think I can get the size directly from the LVM, there may be a way to convert it to an array and get teh size, but then how do I randomly extract a portion?  Also the portion can be of any size, but has to be a minimum of a particular size.  How would i do that?
0 Kudos
Message 3 of 12
(3,939 Views)
I'm sure there is a better way to do this but it is possible to generate random numbers between 0-1. It's in the functions pallette. You can then multiply by 10, 100 etc to make thenumber larger based on the amount of data. But i think ill pass this on to someone else who may be able to help you better this is just an idea or two off the top of my head.
0 Kudos
Message 4 of 12
(3,935 Views)

LVM includes the number of points in each segment header.  You can get this by reading and parsing the header yourself.  The spec is located here.  The Express VIs presume that, being an ASCII file, LVM files are relatively small.  As such, the entire file is read into memory by the Express VI.  You can use the array or waveform VIs to easily extract a portion of this.

 

If you have huge files and this creates a memory issue, you can parse the file yourself.   Look for the ***End_of_Header*** line.  The next line is the column headers, followed by the data, one item per line.  The bad news is that lines can be a variable number of characters long.  This can make searching a long file for lines a very slow process.  One option is to read the file in 65,000 byte chunks and process these serially to get the data you want (this is what LVM does internally to convert from ASCII to data).

0 Kudos
Message 5 of 12
(3,932 Views)
Ok, I think I can figure out the length of the file.  How do I randomly select a section of at least a min length?
0 Kudos
Message 6 of 12
(3,928 Views)
Also, sorry, I want to start the reading after the signal reaches a particular level first.  I don't want to start before then.  How do I do that?
0 Kudos
Message 7 of 12
(3,919 Views)

LVM comes under the class of ASCII file and hence random access of the files content is not possible.  Just switch to tdms which offers you bundle of facilities and you can accompolish the tasks very easily without pain.

 

Look into tdms examples shipped with LabVIEW to get an idea of tdms.

Post back for queries.

With regards,
JK
(Certified LabVIEW Developer)
Give Kudos for Good Answers, and Mark it a solution if your problem is solved.
0 Kudos
Message 8 of 12
(3,901 Views)

I am not sure I understand what you are trying to do.  Do you only want to read part of the file?  Or can you read all of the file and then extract part of the signal?

 

From reading this thread I would suggest reading the entire file and convert your signal(s) to waveform or array datatypes.  Then search for the threshold you mentioned in your last post.  Then apply the random extraction to the portion of the signal after the threshold.  Is the start position or the length of the segment or both random?

 

Selecting random portions of a signal seems unusual.  Can you tell us what you are trying to achieve?  Perhaps someone can suggest a better way.

 

Lynn 

0 Kudos
Message 9 of 12
(3,877 Views)
Solution
Accepted by topic author GMik

The easiest way to do what you want to do is the following:

  1. Read the file using  the Express Read From Measurement File. This will read the entire file into memory.
  2. Convert this to either a single waveform or array of waveforms using the Express From DDT. This will not create a data copy.
  3. Use Basic Level Trigger Detection to find the location of your start point.
  4. Use Get Waveform Subset to fetch the section of interest.
If your waveforms are big enough that this causes memory issues, you can parse the text from the file directly, but this is far more complex and could easily be far slower if you do not do it exactly right (see notes above).  If you need to pursue this case, let us know and we can supply better direction.
0 Kudos
Message 10 of 12
(3,876 Views)