Open source MATLAB API

Post Reply

At what level would you be interested in an open source MATLAB API to collect data from Biosemi ActiveTwo in MATLAB (no toolboxes required)?

Open source project manager / contributor
0
No votes
Project contributor / user
9
75%
User
3
25%
Curious observer
0
No votes
Completely uninterested
0
No votes
What is MATLAB?
0
No votes
 
Total votes: 12

Lloyd
Posts: 26
Joined: Fri Mar 26, 2004 7:46 pm
Location: Wilmington, NC, USA
Contact:

Open source MATLAB API

Post by Lloyd »

Hi all. Over the course of 2010 and 2011 Cortech Solutions employed a developer who created a MATLAB API for the ActiveTwo system. As I see now, operating systems and MATLAB itself are moving targets, meaning that maintaining the API will require more resources going forward than we are able to assign to the project just to keep it running on current platforms.

Instead, I have decided to make the project open-source under a BSD Free license. I am writing now to hear from MATLAB developers in the Biosemi user community who would like to have access to the source code and who may have opinions about the best way to maintain the code repository. I am inclined to setup a project under github, but I am not a developer and would not be able to manage the project without the involvement of one or more users.

If you are interested in participating in this effort, please contact me at lsmith@cortechsolutions.com. Thanks!

Lloyd Smith
President Cortech Solutions, Inc.
Biosemi representative for US / Canada

Lloyd
Posts: 26
Joined: Fri Mar 26, 2004 7:46 pm
Location: Wilmington, NC, USA
Contact:

Update on API status

Post by Lloyd »

We have just taken the first step toward putting the API in the open source domain. The API code now has the FreeBSD license prepended and I am in need of one or more experienced coders / github.com users to help move the code to a github project so that all can benefit from the continuing efforts of the community. Please indicate your interest here or contact me directly.
I'd like to get the project up on github.com soon so that all can benefit from efforts at improving and maintaining the code.

Lloyd
Posts: 26
Joined: Fri Mar 26, 2004 7:46 pm
Location: Wilmington, NC, USA
Contact:

Support for the API

Post by Lloyd »

Hi, all. I'm not sure if everyone understands the fundamentals here, so I feel the need to provide some background. The API has been moved into the open source domain under a FreeBSD license. The upside for you is that we are giving away the source code; the downside is that we are not supporting it - the community of users would need to step up and play that role. I will direct all future requests for support and files to this forum so that all can benefit from the conversation. Please post your questions and comments here. Thanks.

Lloyd
Posts: 26
Joined: Fri Mar 26, 2004 7:46 pm
Location: Wilmington, NC, USA
Contact:

Missing files in the API package

Post by Lloyd »

A user asks:

[quote]
I have started studying your matlab api for biosemi. Running setup
script generated an error .

I presume the reason is that the files you sent me seem to
be missing the BioSemiWinUSB2.INF driver. I went to your website and
did not find it there either.
[/quote]

Make sure you have the driver properly installed. Get the Biosemi WinUSB2 driver files from http://www.biosemi.com/download.htm.

[quote]BDF folder that I believe is need for simulator to run is not present in the set of files I have.[/quote]

Sample BDF files can be downloaded from here: http://www.biosemi.com/download/BDFtestfiles.zip and it should be possible to point the simulator at these samples. If the simulator needs a matching CFG file, you may need to download and install the Biosemi ActiView software and the required LabVIEW runtime engine to create a suitable CFG file.


[quote]Also, what should we do regarding the hardlock? Should we use the c2c file?
[/quote]

The main job of all you smart programmers now in possession of the source code is to strip out the part that enforces licensing. We will not be issuing licenses or hardlocks for the API any longer.

Lloyd
Posts: 26
Joined: Fri Mar 26, 2004 7:46 pm
Location: Wilmington, NC, USA
Contact:

Documentation for the API

Post by Lloyd »

It was brought to my attention that the documentation for the API was not in the original download package. I remember now that I meant to post it as an editable Google Doc as a first stab at a dynamic document. Documentation is here:

https://docs.google.com/document/d/1IP7 ... NdQrM/edit

and I will also make any contributors editors upon request.

ossadtchi
Posts: 3
Joined: Thu May 03, 2012 11:44 am
Location: St. Petersburg, Russia

Re: Missing files in the API package

Post by ossadtchi »

Hello,
I intend to use ACTIVE 2 Matlab adaptor kit in simulator mode only since I don't have an actual device. I have downloaded the driver but can not install it since I have no corresponding hardware to plugin into a USB port. Rightclicking and choosing install results into nothing and the same error in Matlab appears when running setup.p Add Hardware alos does not let install the driver.

Any suggestions? Would anybody give me a hand on that?

ossadtchi
Posts: 3
Joined: Thu May 03, 2012 11:44 am
Location: St. Petersburg, Russia

Re: Missing files in the API package

Post by ossadtchi »

Was it intentional that setup.p file is left in the encoded form and
the users can not see the insides?

The reason I am asking is that I am encountering a problem running
Setup script of Biosemi Matlab API and can not figure out what's
wrong, partly, because unable to look inside the setup.p file.

The suggestion on installing the dirvers is hard to implement in my
circumstances since I don't have the device and therefore
windows does not let me to install the drivers.

Any help is appreciated!

Lloyd
Posts: 26
Joined: Fri Mar 26, 2004 7:46 pm
Location: Wilmington, NC, USA
Contact:

Don't have ActiveTwo hardware and want to use simulator

Post by Lloyd »

It should be possible to run the API with only the simulator, no hardware or driver, though it may be necessary to modify the code to do this. Anyone tried this yet?

Lloyd
Posts: 26
Joined: Fri Mar 26, 2004 7:46 pm
Location: Wilmington, NC, USA
Contact:

Re: Missing files in the API package

Post by Lloyd »

[quote="ossadtchi"]Was it intentional that setup.p file is left in the encoded form and the users can not see the insides?[/quote]

Not intentional. I found setup.m and it contains the following:

[color=darkred]
[i]%% Sets up the HASP SRM
r=dos('bin\haspdinst.exe -i');
if ~r
fprintf('Active2 RTE has been installed.\n')
else
fprintf('Problems installing Active2 RTE.\nPlease contact Cortec Solutions Inc.\n')
end[/i][/color]

My impression is that this installs from a package that was created to incorporate license management as well as software. I don't think the installer is needed except for the HASP SRM stuff, and I looked at Active2.m and found that by searching for HASP you can easily find where all of the HASP stuff is called and comment or delete it.

Not so sure about the calls to the ActiveTwo driver calls.

ossadtchi
Posts: 3
Joined: Thu May 03, 2012 11:44 am
Location: St. Petersburg, Russia

Post by ossadtchi »

If anybody cares here is a set of obvious steps to make the API running in Sim mode without the actual device and the drivers

0. Make sure you have Matlab 2008b or newer
1. You don't have to run Setup from Matlab prompt as all it does it performs dos command and install hasp key drivers

2. in Active2.m modify function that starts at 3317 by adding return after LicenseStatus = 0; line.

function [LicenseStatus] = Active2MatlabAPILicenseCheck(Act2)%,LicenseTime,WebDateStrM0)
% Specify the aloted trial period.
% LicenseTime = 20;
LicenseStatus =0;
return;

That's all for now.

Lloyd
Posts: 26
Joined: Fri Mar 26, 2004 7:46 pm
Location: Wilmington, NC, USA
Contact:

Re: Open source MATLAB API

Post by Lloyd »

Outstanding - that's progress! I did also search through the code for the word "HASP" and it is my impression that one can easily comment out all of the code that calls licensing functions. I guess that if you have used the code you have figured this out by now. The simulator operation without hardware/driver and the licensing code were the two major stumbling blocks to making the API code usable by the public. Once these two items have been addressed, it seems to me that the time is right to post the project to github.

Lloyd
Posts: 26
Joined: Fri Mar 26, 2004 7:46 pm
Location: Wilmington, NC, USA
Contact:

Re: Open source MATLAB API

Post by Lloyd »

From: Lloyd Smith <lsmith@cortechsolutions.com>
Date: Tue, Jun 26, 2012 at 3:07 PM
Subject: Re: Biosemi - Matlab API
To: <anon>
Thanks for your question. The API is open source under a FreeBSD license - you do not need to pay for the license. You need only standard MATLAB to use the API, but you may want to have other toolboxes like the signal processing toolbox to work with the data. The API supports the latest ActiveTwo driver with dynamic buffer, so you can adjust the packet size and thereby control the latency from acquisition to input to your algorithm, keeping in mind that shorter latency is achieved at a slightly higher cost in terms of processor overhead.

Best regards,

Lloyd Smith
President
Cortech Solutions, Inc.
==========
On Tue, Jun 26, 2012 at 5:53 AM, <anon> wrote:

Dear Mr. Smith,

I am writing to you to ask some information about the Open Source Matlab API ( viewtopic.php?f=7&t=688 )

We are in the process of decide which EEG recording system to buy and we must know in advance if and how we could stream the EEG data recorded via Biosemi into Matlab in (or almost) real time in order to develop a BCI programmed in Matlab code.

Could we do with the Matlab API interface you developed?
How can we get the code?
Would we need any additional licence (we already have a Matlab licence) to stream the EEG data into Matlab?

We would really appreciate if you could write back today, because we are willing to decide today which system to buy.

Thanks in advance,

Best regartds,

<anon>

Lloyd
Posts: 26
Joined: Fri Mar 26, 2004 7:46 pm
Location: Wilmington, NC, USA
Contact:

Re: Open source MATLAB API

Post by Lloyd »

A,

I don't know how much effort would be required to run it on Linux, but I suspect it will not be too bad. The ActiveTwo drivers for Windows and Linux were developed by the same person, so they should work as similarly as possible. MATLAB code should be relatively transparent too, I think. But then I am no MATLAB expert. I am optimistic it will require minimal effort to convert and I am sure that other people would be enthusiastic about your efforts. - Lloyd

==========
Hi Lloyd

Thank you. Do you know if the API can be run on Linux 64 bit? Or I need to go through the pain process and do it ?
As for uploading it on GitHub, I am working right now converting everything into Linux (before I had it working on WinOS)..... If in the process I can help with you out, I will.

Thanks,
A

afirpi
Posts: 12
Joined: Wed Aug 01, 2012 10:14 pm

Re: Open source MATLAB API

Post by afirpi »

I'll go through the code. It's a good thing now I can see the Active2.m lines. Before it was p'ed. Let's see how this goes.

I'll keep you posted it.


Thanks,
Alex

afirpi
Posts: 12
Joined: Wed Aug 01, 2012 10:14 pm

Re: Open source MATLAB API

Post by afirpi »

Lloyd

Question. As I menitoned before, I am trying to compile and run the code in Linux 64 (Fedora 17, just in case people want to know). At one point, the code uploads the library to communicate with the USB (below). I am trying to make it work both WinOS and LinuxOS. I added the second line (isunix). I installed the labview libraries as indicated on the biosemi (and those steps too needed some "tweaking", ATTR instead of SYSFS and Ctrl-Z instead of Ctrl-C to stop the test code). I am trying to upload the library for Linux (i.e., 'liblabview_dll.so') but I don't know the proto-function I need to call. Matlab allows to read the functions in the shared library but just after the library was uploaded using their 'loadlibrary' command and not before. I am having erros when trying upload the 'liblabview_dll.so'. Doing some more research about that.

This:

if ispc
[notfound,warnings] = loadlibrary('Labview_DLL.dll',@WinUSB2proto,'alias','A2__Act2__A2');
elseif isunix
[notfound,warnings] = loadlibrary('liblabview_dll.so',@WinUSB2proto,'alias','A2__Act2__A2');
end

I might need to some more research about USB ports, libs, etc. because, again, hardware is not my strong thing. Anyway, if either you know or you could forward the question to someone that by any chance could address the question, it would be cool.

Thanks,
Alex

pmac
Posts: 70
Joined: Thu Jan 21, 2010 2:51 pm
Location: Canada

Re: Open source MATLAB API

Post by pmac »

Alex,

1. A disclaimer: I have never used Matlab.

2. "liblabview_dll.so" is a link to the real file which is "liblabview_dll.so.0.0.1". Your loadlibrary may not be
smart enough to follow the link. Try using the actual filename rather than the link name.

3. There is a line missing in the INSTALL-LINUX installation instructions for the BioSemi Linux driver.
The instructions for using udev to allow non-root access to the usb should read like this:

a) As "superuser", create file "/etc/udev/rules.d/60-biosemi.rules"
containing these seven lines:

SUBSYSTEM!="usb_device", ACTION!="add", GOTO="biosemi_rules_end"
# biosemi usb receiver
SYSFS{idVendor}=="0547", SYSFS{idProduct}=="1005", MODE="0666"
SYSFS{idVendor}=="0547", SYSFS{idProduct}=="1005", SYMLINK+="biosemi"
SYSFS{idVendor}=="04b4", SYSFS{idProduct}=="8613", MODE="0666"
SYSFS{idVendor}=="04b4", SYSFS{idProduct}=="8613", SYMLINK+="biosemi2"
LABEL="biosemi_rules_end"

The first line (SUBSYSTEM ...) was missing.

4. With Linux, CTRL-Z suspends a running program and puts it into background.
Type "jobs" to see that it is still there. Use "fg" to bring it back into foreground and
use one or more CTRL-C's to kill it.

Paul

afirpi
Posts: 12
Joined: Wed Aug 01, 2012 10:14 pm

Re: Open source MATLAB API

Post by afirpi »

Paul

Thank you. I feel silly thinking that Ctrl-Z was cancellng all the jobs! When I typed ps -ux, all runs were right there! Well, at least I won't forget again what Ctrl-Z is for. As for the missing line, I knew something was wrong but by changing SYSFS to ATTR and rebooting the machine, somehow, it worked (the two lines udevadm control...XXXX weren't working at all) but it makes me wonder if the missing line is the reason why it didn't.

As for the library, actually, I tried the filename itself instead of the symlink, too. It didn't work but while working more on it it seems I was doing something wrong. Still working on it.

Thanks for the disclaimer! =) If I get this working before midnight, I'll take tomorrow off!!

Best,
Alex

afirpi
Posts: 12
Joined: Wed Aug 01, 2012 10:14 pm

Re: Open source MATLAB API

Post by afirpi »

Lloyd, Paul, Alex O. and whoever else is interested

After a week or so working on the Matlab API I already made it work for Linux 64bit. I'll be cleaning the code in the next few days.

Paul: Thank you so much for taking the time to explain how the code scans and reads from the Biosemi box. That helped me a lot. I can test the code for the new hardware if you modify it. That way (as you pointed out) we can have a way to test the synch without depending on parameters that keep changing from hardware to hardware.

Alex O.: Thank you for your input. Letting me know that your API was working on a 64 bit system led me to see the problem I was having from another perspective.

Best,
Alex

Lloyd
Posts: 26
Joined: Fri Mar 26, 2004 7:46 pm
Location: Wilmington, NC, USA
Contact:

Re: Open source MATLAB API

Post by Lloyd »

A client asked today about using the API on 64-bit Windows 7. I assume that others have been doing so successfully. Anyone want to comment on successes or challenges using the API under Win 7 64?

Lloyd Smith
================

SJackson
Posts: 1
Joined: Wed Aug 28, 2013 10:30 am

Re: Open source MATLAB API

Post by SJackson »

Hello

I commented out the parts I found while searching for "HASP", but I am still getting many different Errors.
Can somebody say me which parts you commented out exactly or send me a working Active.m?
I am really desperate with my thesis in the moment...

Did somebody found out a solution for the Win7 64 bit problem?

Thanks to all for help!

lesica
Posts: 1
Joined: Mon Feb 23, 2015 2:48 pm

Re: Open source MATLAB API

Post by lesica »

Where can I download the Matlab API?

Thanks,

Nick

Ediot
Posts: 1
Joined: Tue Oct 25, 2022 7:28 am

Re: Open source MATLAB API

Post by Ediot »

Is there any place we can download the API? We have a project need real-time interfacing with ActiveTwo system, thanks.

Post Reply