LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

define a data type (read binary file)

Solved!
Go to solution

Hi,

 

I want to read a EEG TRC file and am struggling with it's data type, i know that i can put a cluster in the input of data type on a "Read binary file", but i don't know how it actually works, her is what i have:

 

I have a definition of the TRC header file:

offset: 0, label: patient info, data type: char, description: patient data

offset: 32, label: recording info, data type: char, description: recording info

offset: 64, label: acquisition unit, data type: Unsigned long, description: type of device

etc...

 

Above is an example (fake one), because i can't give away the file structure description, from this specific file... 

 

So my question is: how would you define a data type cluster that could read binary files and reads it like exactly that way?

 

Or does this only works with files saved as a labview structure? For example a cluster?

 

Best regards,

Thijs Boeree

0 Kudos
Message 1 of 11
(5,734 Views)

I tried the thing in the attached file... But it doesn't work

regards,

Thijs

0 Kudos
Message 2 of 11
(5,728 Views)

Hey Thijs,

 

Could you not just read it in as a text file and use string manipulation to get the parameters that you need? If you give me an example of the data you are trying to feed into the cluster I will give you an example.

Regards

Andy
_______________________________________

"To 'G' and not to 'C', this is not a question!"
0 Kudos
Message 3 of 11
(5,721 Views)

Unflatten won't work like this, how would it know where to separate the input string into the different strings in your cluster?

You will have to split the string.

You can do this by reading the file in pieces (define number of bytes to read) and convert each piece into the corresponding data type, or you can read the whole file as string and then split and parse it.

 

0 Kudos
Message 4 of 11
(5,716 Views)

Oke,

 

For example you can use the "constant" string in my attached vi in the original question and convert that to the cluster also in the VI this is the structure for the data:

Cluster

 32 char

 32 char

   cluster

     22 char

     20 char

     1 U8

     1 U8

     1 U8

 

Best regards

 

0 Kudos
Message 5 of 11
(5,713 Views)

Hey Thijs,

 

So maybe you could use something like this:

 

String parameters.png

Regards

Andy
_______________________________________

"To 'G' and not to 'C', this is not a question!"
0 Kudos
Message 6 of 11
(5,705 Views)

Or like this:

parse-string.png

 

Message 7 of 11
(5,698 Views)
Hi, i am on my way home now, so i'm going to check it first thing in the morning. I was thinking about it, and came to the conclusion that i maybe needed to make an array of a cluster with an offset, length (count) and diffrent data types and run that in a fror loop to instruct the read binary file and the 'set file position' to retrieve the data and than later on put these in a well defined cluster!
But maybe you have the same solution...
0 Kudos
Message 8 of 11
(5,696 Views)
Solution
Accepted by topic author ThijsBoeree

@ThijsBoeree wrote:
Hi, i am on my way home now, so i'm going to check it first thing in the morning. I was thinking about it, and came to the conclusion that i maybe needed to make an array of a cluster with an offset, length (count) and diffrent data types and run that in a fror loop to instruct the read binary file and the 'set file position' to retrieve the data and than later on put these in a well defined cluster!
But maybe you have the same solution...

You can do that, but of course you can't auto-index different data types into one array. But you could populate the cluster directly in the for loop.

parse-string-2.png

 

 

Message 9 of 11
(5,691 Views)
I was planning to make a case each with a different data type... and according to the data type in the cluster array it would switch to a different case... but we'll see!
0 Kudos
Message 10 of 11
(5,685 Views)