File Exchange

image thumbnail

Load BIOPAC ACQ (AcqKnowledge for PC) data

version 1.3.0.0 (221 KB) by Jimmy Shen
Load BIOPAC's *.acq file (AcqKnowledge for Windows data format).

26 Downloads

Updated 22 Feb 2011

View License

"load_acq.m" will load BIOPAC's AcqKnowledge (ACQ) data to a structure containing ACQ header field and data matrix field.

It is based on Application Note #156 from BIOPAC web site (see attachment). The note mentioned that: "This document describes file formatting for all Windows versions of AcqKnowledge 3.9.x or below". Thanks to the open Python source code provided by Nathan Vack, this program can also read AcqKnowledge 4.0 & 4.1 data (with no documentation from BIOPAC). Compressed data is not supported by this program.

Usage: acq = load_acq(filename, [force_chan_by_chan_load])

acq - AcqKnowledge file structure containing ACQ header field, and data matrix.

filename - BIOPAC's AcqKnowledge file

force_chan_by_chan_load is an optional argument. By default, this optional flag will be set to 1, which means that when you use acq = load_acq(fname), the data will be loaded one channel after the other. This can avoid memory crash when you load very large ACQ data. If your ACQ data is not huge, I suggest that you set this optional flag to 0, i.e. acq = load_acq(fname, 0). In this case, the program will read data depending on the data type. If the program detects that the data type in ACQ file are different from channel to channel, it will still read data channel by channel. Otherwise, it will read whole data in one block (a lot faster than using traditional way from channel to channel with the same result).

A script called "acq2mat.m" is provided to help you convert all .acq files to .mat files in all specified folders in advance, since to load corresponding .mat files will be much quicker. i.e. In your MATLAB code, instead of using: acq = load_acq('MyGSR.acq'); you can now use: load('MyGSR.mat');

Comments and Ratings (33)

Hi
the code did not show any error but the struct output file is empty.

FYI, looks like Nathan's github has been updated for 5.0.

Any chance this will be updated to work with AcqKnowledge 5.0? As a workaround, 5.0 can save files in the 3.x format, which still works with load_acq.

I tried the fix suggested by Jay Buckey, however I still got the error below:

Error in load_acq>read_acq (line 458)
data(:,i) = tmp(1:min_len);

Error in load_acq (line 96)
acq.data = read_acq(fid, acq.hdr, chan_by_chan);

Any ideas to solve this? Thanks!

Jonathan

This code was buggy for me. At least two issues: 1) it did not read in all the data! stopped short about 2/3rds of the way through. 2) the data read in the initial samples was read incorrectly. This was after I did the fix described by Jay below -- without that fix, the code would not run. Instead, I used this package, which was very easy to use: https://github.com/njvack/bioread

Jay Buckey

This fixed it for me around line 280
if file_version >= 68

unused = fread(fid, 5, 'double')'; % 112 + 40
% hdr.var_sample_divider = fread(fid, 1, 'int16')'; % 152 + 2
hdr.var_sample_divider = 1;

Jay Buckey

I tried the fix suggested by Robert Barretto and added a line 271 hdr.var_sample_divider=1, but get the result below:

Subscript indices must either be real positive integers or logicals.

Error in load_acq>read_acq (line 471)
mask(1:sample_divider(j):min_len, j)=1;

Error in load_acq (line 96)
acq.data = read_acq(fid, acq.hdr, chan_by_chan);

Any thoughts?

For those getting the load_acq error that Piyush kant and Sanjeev are getting -- I dug into the Jimmy Shen's code a bit.

I manually set a parameter in line 279:
hdr.var_sample_divider = 1

I noticed this parameter was set to -1 for my Biopac file_version, which is at 133. Fixing this parameter alone was able to give me the appropriate acq output.

good luck everyone

Thank you for this code. It is very helpful.
Cheers!

Piyush kant

i am also getting same error as sanjeev

Error in load_acq>read_acq (line 470)
mask(1:sample_divider(j):min_len, j)=1;

Error in load_acq (line 96)
acq.data = read_acq(fid, acq.hdr, chan_by_chan);

if any one can help???

Susan Rose

Lawliet, it is the problem of the latest version of MATLAB. I am still using old R2010 and do not have this problem.

I have some problem while loading acq which is
"Error: Unexpected MATLAB expression"
anyone know how to fix this? Thanks

I have some problem while loading acq which is
"Error: Unexpected MATLAB expression"
anyone know how to fix this? Thanks

Sanjeev

I am trying to load a dataset recorded by Biopac Version 4.3 , when i am trying to load that data using acq=load_acq('data.acq_'); it shows following error
Loading data.acq_ Subscript indices must either be real positive integers or logicals.

Error in load_acq>read_acq (line 470)
mask(1:sample_divider(j):min_len, j)=1;

Error in load_acq (line 96)
acq.data = read_acq(fid, acq.hdr, chan_by_chan);

Please suggest how to resolve this

Peter

In acq2mat.m flip the if statement to save lots of space and time

if str2num(v7(1))<7
save(mat_fn, '-V6', 'acq');
else
save(mat_fn, 'acq');
end

Jimmy Shen

Thijs, thanks to the open Python source code provided by Nathan Vack, this program can now load both ACQ4.0 and ACQ4.1. However, there is no documentation about ACQ 4 data format from BIOPAC.

An Biopac ACQ4.0 version would be highly appriciated. Works great allready for 3.9.1, thanks!

Oscar

Hi Nathan

Thanks for sharing the Python code.
i had to spend hours setting up python and its packages, and it was worth the effort!!! your code works excellent for AcqKnowledge 4.1.

Jimmy Shen

The latest release of file format by BIOPAC is up to AcqKnowledge 3.9:
http://www.biopac.com/ResearchNotes.asp?Aid=&ANid=82&Level=4
According to BIOPAC's AcqKnowledge 4 Software Guide:
http://www.biopac.com/file.asp?ManualID=56
It is now also able to save data into MAT-file binary format.

Anthi

hi Damien...
i am having the same problems with AcqKwoledge 4.1.Did you found a solution???

Damien

hi Jimmy,

thanx a lot. There were problems with the version... I saved my file with 4.1, so the header was different...
Unfortunately BIOPAC does not support informations about 4.1 file format...

Nathan Vack

FYI, I've written a package in Python that'll do the .ACQ -> .MAT conversion. As far as I know, it'll handle any .ACQ file out there, including compressed files and very new ones.

It's available here:

https://github.com/njvack/bioread

It'll also let you work with the files in Python, of course -- but this is a Matlab site ;-)

Jimmy Shen

There are 4 places that are using 'dec2hex' command. They are: dec2hex(hdr.color_major_grid), dec2hex(hdr.color_minor_grid), dec2hex(hdr.rgb_color), dec2hex(hdr.active_seg_color).

Those values in ACQ file header are not supposed to be negative.

Since none of those values will affect the channel data, you can replace them with ' ' if you believe your ACQ data have no other problem.

Damien

hi,
I've tried to use it, but it returned:
Error using ==> dec2hex
First argument must contain non-negative integers.
can u help me, please?
thanks a lot

Jimmy Shen

Hi Dino:

Theoretically, the changes that you suggested will increase the speed. However, it doesn't seem to speed up, after I tried several datasets.

Anyway, thank you very much for the feedback, and I will make the change in the next version.

Jimmy

Dino Dvorak

Great tool. Thank you.

Couple of things to fix:

line 375, add this: data = zeros(min_len, hdr.graph.num_channels);
line 409, change
data(:,i) = tmp(1:min_len);
to
data(1:min_len, i) = tmp(1:min_len);

Alpesh Patel

Antonio Molins

Did not work for me as provided, but worked with significant changes: halted before getting to the foreign data section (missed it by 2 bytes), and did not read markers and positions. A new version has been offered to the author, and is available on request.

Wojtek Grabski

Works.

boris fain

Thank you, works great.

Aida Jimenez-Gonzalez

Updates

1.3.0.0

Thanks to the open Python source code provided by Nathan Vack, this program can also read AcqKnowledge 4.0 & 4.1 data (with no documentation from BIOPAC).

1.2.0.0

Fixed a bug in acq2mat.m script.

1.1.0.0

Fixed a bug when you use it with Matlab 6.5 and earlier.

1.0.0.0

Script "acq2mat.m" is provided to help you convert all .acq files to .mat files in all specified folders in advance.

Found '&&' in last update, which cannot run under Matlab5. It has been fixed in 'load_acq_20080609.zip'.

don't know why zip file on fileexchange is still old. upload the new one again.

Thanks Antonio Molins (amolins@mit.edu) for the changes he made (all comments started with "AM").

Modify on 31-JUL-2007 by Julio Cruz (julio.cruz@juliocruz.info) to make the program also work on MAC OS.

Thanks to Aida Jimenez in University of Southampton, I fixed a bug when reading AcqKnowledge version 3.5 and earlier.

Thanks to the bug report from Stefan Schumann in University of Freiburg, now my load_acq supports new versions of data with different sample dividers.

Added "force_chan_by_chan_load" option and set it to 1 by default to prevent out of memory problem when loading huge ACQ data

Added rgb_color interpretation, and modified description.

MATLAB Release Compatibility
Created with R11.1
Compatible with any release
Platform Compatibility
Windows macOS Linux
Acknowledgements

Inspired: ACQREAD