LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Binary file problem (Read a specific Stream)

Hi Guys ,

 

I have a problem , I want to read a binary files but not the whole binary file. I only want to read one stream.

 

Forexample , I have a binar files which has 5 streams. If I only want to read one of the stream what should i do ? How do i get the position of each stream starting and end ?

 

The binary file is attached.

Please note that the file was 5.7mb where as labview message system allows 5.2mb. therfore i uploaded the file on a file host

http://uploading.com/files/55524a3d/10211001_.raw/

 

Thankyou in advance

 

Rgs

 

M Omar Tariq

0 Kudos
Message 1 of 8
(2,744 Views)

How exactly you can read a given stream depends on the format of the file, do you know how it specifies the position and length of the data within itself etc.? Is this a raw photo file, or some other format that just happens to have that file extension(.raw)?

 

Basically you need to use the "Set File Position" function first to set the starting point for your read...and then you can use the read binary data function with a length input.

 

Whether you can get the stream in one continous chunk - or if you have to extract it from a mix of streams (either in memory or by continously changing the file position) again depends on the file format.

 

 

 

0 Kudos
Message 2 of 8
(2,736 Views)

Hi ,

 

its a raw  file , i know the set file postion logic but the problem with me is how to know the starting and ending point of each stream. This raw file contains wave channels something like ECG.

 

By using http://www.proxoft.com/BinaryViewer.aspx , i can view the binary files , its header is understandable but the problem is that i am unable to file the starting index ending index of each stream.

 

=S maybe if you could check the binary file , you would know what i mean

 

Rgs

 

Omar

 

0 Kudos
Message 3 of 8
(2,733 Views)

Ok, so it is not really a LabVIEW issue then, you are looking for a description of the file format that is more detailed than what you can read from its header.

 

The header itself does not show the start or end of each stream, so either there is a predefined "end of channel" marker within the binary data - or each channel is intertwined and you have to read all the data as a 2D array (or jump in the file based on the data type) where the number of rows/channels are given from the number of streams specified in the header.

 

There could be someone here who has a VI that reads a stream out of this type of file...but otherwise I would go and search for the file format specification...and/or try to decode it based on the above mentioned clues.

0 Kudos
Message 4 of 8
(2,723 Views)

Hi ,

 

Your right but isn#t there any method of labview from where i can get single stream only. plus your right at the moment I am reading the whole binary file and then read all the data as a 2D array. But what it does is that i can read a use this method and read 100 mb file but what if i have 1 gb of file or 2 gb of file then i can#t read the whole file , thats why i need to find the start and end of each stream so that i could read only the stream which i want too , not the whole file...

 

Rgs

 

Omar

0 Kudos
Message 5 of 8
(2,720 Views)

If it works to read it as a 2D file then there is no other start or end than the start you get from the header and the end that is the file end....But it also means that you can calculate where each element of that 2D array is in the file...so you can write functions that will extract a subset...either of just one stream or from multiple...all you need is the byte length of the data type...the set file position function...and the math to calculate what parts to read based on your preferences....

 

I could write an example for you, but that will have to wait for later.

0 Kudos
Message 6 of 8
(2,712 Views)

hmmm , at the moment I am reading it as a 2D file then then using a subarrray function i select the channel which i want as every sub array in 2D represents a channel. For example if i have 4 channels in the file my 2D array would be 4 * 1540   where (1540 is the length of the sub array)

 

hence using subarray method i can extract the channel which i want but the problem is I don't want to read the whole file first in a 2D array as for 1 gb or 2gb file it won't work. So thats why i am looking for a solution which would read the binary file channel wise which i think will be very much memory efficient .

 

If you got an example , then no prob ,i can wait for it also 😃

 

Rgs

 

Omar

0 Kudos
Message 7 of 8
(2,705 Views)

As far as I can understand. You are able to read and decode the file in Labview. But have problems with big files. In such cases. Read the data file in chunked and discard data not needed. You can also make a tool that splits the multi-channel data into separate files in a binary format easy to read from Labview. It is also not needed to have all the data in memory then analyzing the data. Analysis may in many cases be done in chunks.



Besides which, my opinion is that Express VIs Carthage must be destroyed deleted
(Sorry no Labview "brag list" so far)
0 Kudos
Message 8 of 8
(2,700 Views)