Biomedical User Group Discussions

cancel
Showing results for 
Search instead for 
Did you mean: 

Question on reading and analyzing LVM files


Greetings,

My final year thesis project would be to develop a wireless EMG device via Bluetooth using an Arduino and an Amplifier Circuit. I could be using LabVIEW 2010 for the software to receive and process the EMG signal. So far I've been able to save the received data in LVM(without header) format.

What I want to achieve next would be to open the LVM file and perform analysis on it. But there seems to be a problem with opening the file since there is no time information that goes along with the files. Basically, the file is just a series of Y(amplitude) values. The problem is resolved by saving the file again, but this time placing header, and then changing the delta_X on the header to 0.001 and the time on the header to "Relative" instead of "Absolute". This saving and changing of the information on the header is done manually and not in LabVIEW.

Can anyone teach me how to properly open the LVM file to be read as a waveform with a delta_x of 0.001 so the waveform would have the proper frequencies.

Attached is a sample data in LVM format, and the vi that I want to use for the analysis. But I think there's still work to be done in properly reading the file

Download All
0 Kudos
Message 1 of 7
(6,125 Views)

Hi ArvinB,

how you are saving your data? are you using the "write meas files" VI ?

I've change a little few your VI.... try to open it, using my attached signal.

Look the notes i write in front and back painel.... and compare your "read meas file" from mine.....

try to post your "SaveLVM.vi"......

good luck.

Ramon Campos

Download All
0 Kudos
Message 2 of 7
(3,734 Views)

To recap, the file you posted does not contain timing information.  You correctly determined how to modify the Write To Measurement File Express VI so it saves timing information.  However, you are still getting the wrong timing information.  This is probably due to not feeding the Write To Measurement File Express VI the proper timing information.  This is very easy to do, since the input data type (dynamic data type or DDT) can handle data which does not contain timing information.  If you post the code which writes the file, we can give you definite answers.  However, I would guess that you are using a simple array of DBLs as the input to the file.  You can fix this easily enough by converting your array of DBLs to a waveform and setting the dt and t0 before writing to the file.  Drop a Build Waveform node and expand it to show the t0, dt, and Y inputs.  Wire your array of DBLs to the Y input and set the t0 and dt appropriately.  Use this to write to the file and your values should be correct.

If this is not the problem, please post your writing code and we can take a look.

0 Kudos
Message 3 of 7
(3,734 Views)

Greetings RamonCampos,

Yes, I'm using the "Write to Measurement File" vi to save the data received from the serial port.

I've attached the vi that I'm using to receive and save the data.

How did you manage to place time stamps in your "signal-01" LVM file?

I'm interested to do the same in my files to be able to read and anaylze them properly.

0 Kudos
Message 4 of 7
(3,734 Views)

Hello Sir DFGray,

I believe you have understood my problem correctly. I tried doing your suggestion on using the Build Waveform vi but I am not confident that I am implementing it correctly. Can you show me how to implement it?

I've attached here my Receive and Save vi. Basically the vi simply receives the values from the com port and saves them in a LVM file with no headers and no timing information.

How can I have the correct timing information of dt(or delta_x) = 0.001 to read the file correctly by the OpenLVM vi I posted earlier.

Thank you.

0 Kudos
Message 5 of 7
(3,734 Views)

Saving LVM using the express VI does not work well for your particular application (logging single points at a time).  In addition, your timing is somewhat uncertain, since it is driven totally by software.  I would suggest you use the file I/O primitives to do this yourself.

For Write:

  1. Outside your loop, open a text file
  2. Write a line into it containing a label and your dt (e.g. "dt: 0.5").  You may or may not want to separate the label and value by a tab.
  3. Run the error and file reference wires into your loop using shift registers.
  4. Inside your loop, convert the DBL to a string, add an end-of-line, and write to the file.
  5. When done, close the file outside the loop.

For Read (assumes a number of points in the few thousand or less range):

  1. Open the file
  2. Read all of it
  3. Close the file
  4. Split the string at the first end-of-line.  This splits your data from your dt line.
  5. Look for your separator (tab, colon, whatever) and split the first line into the label and dt value.
  6. Convert the dt value to a DBL
  7. Use the spreadsheet string to array primitive to convert the rest of the string to a DBL array
  8. Build a waveform and set the dt value to the DBL you created above, the Y value to the DBL array

If your file is huge, you can read it from disk in chunks and append to a DBL array to save space.  You can also add a further line at the beginning of the file to save the timestamp.

Let us know if you need more help.

0 Kudos
Message 6 of 7
(3,734 Views)

Hi ArvinB,

double click in your "Write To Measurement File",  in X value (time) Columns option, choose one column per channel.

try to save your signal again..... and read it in OpenLVM-02.vi

probably it will work fine!

Ramon Campos

0 Kudos
Message 7 of 7
(3,649 Views)