01-28-2011 11:20 AM
I am currently having issues using the Write to Binary Function to create files to be used with Offline Sorter. From my understanding, Labview is currently writing these numbers in base 256, meaning that a 16 bit number consists of two "digits" from 0 to 255. The problem is that when this is loaded into Offline Sorter, the program doesn't recognize the two digits as being part of the same number and reads them separately. I am able to use Matlab to convert the data into a format that works, but this takes several hours to complete with the file sizes I am working with. Moving to writing an 8-bit number is also not an option due to the loss of resolution. Is there a way to get Labview to write this binary value as a single binary "digit" between 0 and 65535 instead of breaking it up?
01-28-2011 11:31 AM
A flat binary file has no delimiters, so your first statement is certainly incorrect. You can write any kind of binary file with any kind of byte order directly in LabVIEW, you are just doing it wrong.
Can you show us how you are writing the file and what your matlab program does to straighten out your LabVIEW errors. There should be a 30 second fix for that. 😄
Also please attach one of your LabVIEW generated files as well as its matlab corrected version. Thanks!
What is your LabVIEW version?
01-28-2011 11:48 AM
I don't have access to the files right now, but the gist of the current configuration can be seen in the screen shot below. The files we will be ending up trying to write are a 2D array instead of a double.
The current Matlab fix is just writing to text instead, reading that into Matlab, and using Matlab to rewrite it as a binary file. With a binary file the fix would be reading it in and creating a new array by summing 256*(first value of pair) + second value of pair.
01-28-2011 12:11 PM
You have something completely mixed up and we are not gettting the entire story. A binary file written like that does not have information on size and number of dimensions.
Can you show us the matlab code that writes the file? As said, an actual correct output file would be even better.
Is this under windows?
01-28-2011 12:22 PM
I also don't know what an "offline sorter" is. Is there a manual that describes the expected file structure?
02-01-2011 11:37 AM
Sorry for the delay in reply.
To write the file in Matlab, I am just using Fwrite, which creates a file that can be appropriately loaded by Offline Sorter.
Offline Sorter is a program used to sort neural recording spikes. It simply looks for 16 bit binary files, but when I use the following sequence of commands
fid = fopen ('filename');
a= fread(fid);
it comes out as described in my original post (pairs of 8 bit numbers).
I am unable to attach the binary files as this forum does not support uploading .bin files, which is the extension compatible with OLS that I am using to write to.
02-01-2011 11:42 AM
02-01-2011 12:33 PM - edited 02-01-2011 12:37 PM
Here you go. Set the program to run the loop 20 times and just added a 2nd file writing to text in the previous program (same lay out with Write to Text instead of Write to Binary), used b=textread('name') to read it into Matlab then fopen('newname','wb') and fwrite(fid,b) to write it. The good file has no second dimension. I can try it again with larger numbers to see what happens once the value to write to text exceeds 255, but I don't think it changes.
Edit: Tried it again with larger numbers, caps at 255 with no overflow. Unless you can see something I specifically messed up, the issue is probably somewhere with how Matlab and OLS handle binary, not Labview. I'll have to figure it out with those programs. Thanks for your help.
02-01-2011 12:43 PM - edited 02-01-2011 12:50 PM
The bad file has x00 interlaced. You are probably writing with the wrong representation. You would get the good result if you would convert to U8 in the above shown code. Try it!
02-01-2011 12:54 PM - edited 02-01-2011 12:54 PM