[FieldTrip] Automatically saving GDF using the realtime buffer

Eric Pohlmeyer notthemindprobe at yahoo.com
Thu Oct 10 21:39:00 CEST 2013


Fieldtrip users:
 
Well, I managed to get the remote start/stop of GDF files working via the TCP/IP port.  It is not that complicated, but there are some ambiguities in the documentation, so I thought I would post the solution in case it helped anyone else.  
 
Apparently there is a fifth argument that can be given to the biosemi2ft code.  I had seen the listing of the command as:
 
biosemi2ft <config-file> <gdf-file> <hostname> <port>
 
However, if you give it a 5th argument, that works as the port to which to control the ODM, if not specified the control port is 8000, since I had been trying to use the local default port (1972) that is why I was having issues.  At some spoint someone may want to update the documentation to specify that the control port default is 8000, and not the port used for the buffer.  I was able to control the saving of the GDF files by just using the matlab tcp_udp_ip toolbox:
 
host = 'localhost';
port = 8000;
 
con=pnet('tcpconnect',host,port)
pnet(con,'setwritetimeout',2)
[ip,port]=pnet(con,'gethost')
stat=pnet(con,'status')
 
msg = 'SAVE START';
pnet(con,'printf','\n%s\n',msg);
pause(5)
msg = 'SAVE STOP';
pnet(con,'printf','\n%s\n',msg);
pause(5)
% 
pnet(con,'close')
 
 
Best,

Eric



________________________________
From: "fieldtrip-request at science.ru.nl" <fieldtrip-request at science.ru.nl>
To: fieldtrip at science.ru.nl 
Sent: Tuesday, October 8, 2013 5:41 PM
Subject: fieldtrip Digest, Vol 35, Issue 11


Send fieldtrip mailing list submissions to
    fieldtrip at science.ru.nl

To subscribe or unsubscribe via the World Wide Web, visit
    http://mailman.science.ru.nl/mailman/listinfo/fieldtrip
or, via email, send a message with subject or body 'help' to
    fieldtrip-request at science.ru.nl

You can reach the person managing the list at
    fieldtrip-owner at science.ru.nl

When replying, please edit your Subject line so it is more specific
than "Re: Contents of fieldtrip digest..."


Today's Topics:

  1. definetrial with ANT .cnt files (Epstein, Michael)
  2. Automatically saving GDF using the realtime buffer
      (Eric Pohlmeyer)
  3. Re: Using Atlas ROIs in EEG Source Statistics
      (ft_sourcestatistics) (Roey Schurr)


----------------------------------------------------------------------

Message: 1
Date: Tue, 8 Oct 2013 15:50:07 +0000
From: "Epstein, Michael" <MEpstein at NKI.RFMH.ORG>
To: FieldTrip discussion list <fieldtrip at science.ru.nl>
Subject: [FieldTrip] definetrial with ANT .cnt files
Message-ID: <3E54C3C165B1F2428D0A866C8A04ADBD011246 at nki-exchdb2>
Content-Type: text/plain; charset="us-ascii"

Hi all,

I'm having a problem defining triggers using ft_definetrial  with ANT .cnt files. Say I want to do a simple epoching around events with a trigger code of 1 - when I put in cfg.trialdef.eventvalue = 1; I get an error saying no trials are defined. However I figured out that if I put in cfg.trialdef.eventvalue =[1 char(0) char(0)]; then it works fine. The trigger files look totally normal, and other programs don't seem to have this issue. Anyone else ever have a problem like this?

Thanks,

-Michael

IMPORTANT NOTICE: This e-mail is meant only for the use of the intended recipient. It may contain confidential information which is legally privileged or otherwise protected by law. If you received this e-mail in error or from someone who is not authorized to send it to you, you are strictly prohibited from reviewing, using, disseminating, distributing or copying the e-mail. PLEASE NOTIFY US IMMEDIATELY OF THE ERROR BY RETURN E-MAIL AND DELETE THIS MESSAGE FROM YOUR SYSTEM. Thank you for your cooperation.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20131008/1e2d4cb0/attachment-0001.html>

------------------------------

Message: 2
Date: Tue, 8 Oct 2013 06:01:11 -0700 (PDT)
From: Eric Pohlmeyer <notthemindprobe at yahoo.com>
To: "fieldtrip at science.ru.nl" <fieldtrip at science.ru.nl>
Subject: [FieldTrip] Automatically saving GDF using the realtime
    buffer
Message-ID:
    <1381237271.38083.YahooMailNeo at web165005.mail.bf1.yahoo.com>
Content-Type: text/plain; charset="iso-8859-1"

Fieldtrip:
?
Hi, I am a new user of Fieldtrip, but our lab has a (pretty well working) real-time analysis of BioSemi EEG using?two computers, matlab, and the FieldTrip buffer.? The buffer is used for communicating?data between two machines: machine A?collects and saves?the data while also writingto the buffer, and machine B uses matlab to read the data off of the buffer (TCP/IP connection) and then run a soft real-time analysis of the EEG data.
?
Currently we manually start and stop?the saving of a GDF file on?machine A by hitting the S and D keys.
?
I would like to automatically start and stop the file saving, and was wondering if anyone had any suggestions?? I read that the OnlineDataManager (which interacts with our biosemi2ft code) handles the saving, and also does listen for ASCII messages on a TCP port for various commands, including "SAVE START/STOP".? Unfortunately, I'm not a programmer, and haven't been able to figure out how to write those commands to the port.? Is there a way to use the ft_write_data (or similar) to do that?? How do you make address the command to the specific port?
?
Any suggestions would be greatfully received.
?
Thanks!
?
Eric
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20131008/0e09033e/attachment-0001.html>

------------------------------

Message: 3
Date: Wed, 9 Oct 2013 00:41:19 +0300
From: Roey Schurr <roeysc at gmail.com>
To: FieldTrip discussion list <fieldtrip at science.ru.nl>
Subject: Re: [FieldTrip] Using Atlas ROIs in EEG Source Statistics
    (ft_sourcestatistics)
Message-ID:
    <CAHm4wZD573rYbo5U_DA8ej1Dny5-f7a3QuE2jn6_Dn26kWgriA at mail.gmail.com>
Content-Type: text/plain; charset="iso-8859-1"

Dear fieldtrippers (Jan-Mathijs included),

(This message seems long, but is actually quite simple)

Having downloaded the latest fieldtrip version (20131008), we tried
rerunning the code and got the following error:

    ??? Reference to non-existent field 'coordsys'.

    Error in ==> ft_volumelookup at 206
          if    strcmp(cfg.inputcoord, 'mni') &&
          strcmp(atlas.coordsys, 'tal')

    Error in ==> statistics_wrapper at 136
            tmp = ft_volumelookup(tmpcfg, varargin{1});

    Error in ==> ft_sourcestatistics at 107
        [stat, cfg] = statistics_wrapper(cfg, varargin{:});


Since the spm8 MNI atlas indeed has no "coordsys" field.
Even if we bypass this problem (by setting "atlas.coordsys = 'mni' " by
hand, or by simply deleting that "if" line), we still get one of two errors:

* * * * * (1) * * * * *
If we define "cfg.roi = AAL_names;" where AAL_names stores all 90 ROIs the
MNI atlas has to offer, we get an indices error:

    ??? Subscript indices must either be real positive integers or
    logicals.

    Error in ==> statistics_wrapper at 213
          tmp(i,:) = mean(dat(roi,:), 1);

    Error in ==> ft_sourcestatistics at 107
        [stat, cfg] = statistics_wrapper(cfg, varargin{:});


* * * * * (2) * * * * *
If we define "cfg.roi = AAL_names{1};" for example, we get a different
error:

    ??? In an assignment  A(:) = B, the number of elements in A and
    B must be the same.

    Error in ==> clusterstat at 187
        tmp(cfg.inside) = postailobs;

    Error in ==> ft_statistics_montecarlo at 326
      [stat, cfg] = clusterstat(cfg, statrand,
      statobs,'issource',issource);

    Error in ==> statistics_wrapper at 298
        [stat, cfg] = statmethod(cfg, dat, design,
        'issource',issource);

    Error in ==> ft_sourcestatistics at 107
        [stat, cfg] = statistics_wrapper(cfg, varargin{:});

And in "cluserstat" appears this comment: "%this snippet is to support
correct clustering of N-dimensional data, not fully tested yet".
Changing line 187 to: "tmp(cfg.inside) = postailobs(1);" (and line 211 to
"tmp(cfg.inside) = negtailobs(1);") prevents this problem, but misuses the
variables vectors "postailobs" and "negtailobs"


Any ideas on how to solve this atlas source statistics problem (defining
the coordsys field, performing statistics across all ROIs, and using the
postailobs/negtailobs vectors) would be greatly appreciated!

Good night,
Aia and Roey


On Tue, Oct 8, 2013 at 9:43 AM, Roey Schurr <roeysc at gmail.com> wrote:

> Dear Jan-Mathijs,
>
> Thank you so much for your kind and quick answer!
> We do hope this will fix things up. We will check it asap.
>
> Best regards,
> Aia and Roey
>
>
>
>
> On Tue, Oct 8, 2013 at 9:38 AM, jan-mathijs schoffelen <
> jan.schoffelen at donders.ru.nl> wrote:
>
>> Dear Roey and Aia,
>>
>> This indeed was our bad. We have fixed it in the current version of
>> FieldTrip.
>> The version will be available for download tonight (CET), but you can get
>> an instantaneous update of the code repository by doing 'ft_version update'
>> on the Matlab command line.
>> This will update the fieldtrip copy you are using to the latest version.
>> Note that if you want to keep a 'static' version, you need to back up the
>> version with a fixed date, because all changes will be incorporated.
>>
>> A little note to the following piece of code:
>>
>> % Load the Atlas
>>> templateDir = which('ft_defaults'); % use a known function (ft_defaults)
>>> to find FieldTrip's directory
>>> backslashIndices = find(templateDir=='\');
>>> templateDir(backslashIndices(end)+1:end) = [];      clear
>>> backslashIndices;
>>> cfg.atlas = [templateDir, 'template\atlas\aal\ROI_MNI_V4.nii'];
>>>
>>
>> The same can be achieved with the fullfile function (which deals with
>> platform specific file-separators automatically):
>>
>> templateDir=which('ft_defaults');
>> cfg.atlas = fullfile(templateDir,template,atlas,ROI_MNI_V4.nii');
>>
>>
>> Best,
>> Jan-Mathijs
>>
>>
>>
>> On Oct 8, 2013, at 8:25 AM, Roey Schurr wrote:
>>
>> Hello again,
>>
>> Sorry, it seems like the older version (with ft_volumelookup) is just
>> our mistake.
>> However the problem is still relevant, for the function volumelookup is
>> still undefinded in our case.
>>
>> Hopefully someone might know what we did wrong.
>>
>> Thank you once again!
>> Aia and Roey
>>
>>
>> On Tue, Oct 8, 2013 at 12:54 AM, Roey Schurr <roeysc at gmail.com> wrote:
>>
>>> Hello all,
>>>
>>> We are having some problems defining atlas-based ROIs using
>>> ft_sourcestatistics on two source structures obtained via ft_sourceanalysis
>>> (whose grid is later changed according to a precalculated MNI-warped grid).
>>>
>>> It seems like the function "statistics_wrapper" has changed between
>>> "fieldtrip-20130822" and "fieldtrip-20131007": line 136 now calls
>>> "volumelookup" and not "ft_volumelookup", so we get the following error:
>>>
>>>      ??? Undefined function or method 'volumelookup' for input
>>>      arguments of type 'struct'.
>>>
>>>      Error in ==> statistics_wrapper at 136
>>>              tmp = volumelookup(tmpcfg, varargin{1});
>>>
>>> Using the older fieldtrip vesion we get this error:
>>>    ??? Subscript indices must either be real positive integers or
>>>    logicals.
>>>
>>>      Error in ==> statistics_wrapper at 213
>>>            tmp(i,:) = mean(dat(roi,:), 1);
>>>
>>>      Error in ==> ft_sourcestatistics at 107
>>>          [stat, cfg] = statistics_wrapper(cfg, varargin{:});
>>>
>>> So it seems like we didn't define the ROIs correctly, however we are not
>>> sure why.
>>>
>>> Any suggestions would be greatly appreciated!
>>> The relevant pieceof code is attached.
>>>
>>> Thank you all,
>>> Aia and Roey
>>>
>>>
>>>
>>> Relevant code
>>> ============
>>> % Convert sources units to mm, to fit the atlas's units
>>> sourceCondition1 = ft_convert_units(sourceCondition1, 'mm');
>>> sourceCondition2 = ft_convert_units(sourceCondition2, '
>>> design = [ ones(1,length(sourceCondition1.trial)),
>>> 2*ones(1,length(sourceCondition2.trial)) ];
>>>
>>> cfg = [];
>>> cfg.dim = sourceCondition1.dim;
>>> cfg.method = 'montecarlo';
>>> cfg.statistic = 'indepsamplesT';
>>> cfg.parameter = 'pow';
>>> cfg.correctm = 'cluster';
>>> cfg.numrandomization = 1000;
>>> cfg.alpha = 0.01;
>>> cfg.tail = 0;
>>> cfg.design(1,:) = design;
>>> cfg.ivar = 1;
>>>
>>> % Load the Atlas
>>> templateDir = which('ft_defaults'); % use a known function (ft_defaults)
>>> to find FieldTrip's directory
>>> backslashIndices = find(templateDir=='\');
>>> templateDir(backslashIndices(end)+1:end) = [];      clear
>>> backslashIndices;
>>> cfg.atlas = [templateDir, 'template\atlas\aal\ROI_MNI_V4.nii'];
>>>
>>>
>>> cfg.roi = AAL_names; % This is a cell array of the atlas's ROIs:
>>> "Precentral_L", "Precentral_R", etc/
>>>
>>> cfg.avgoverroi  = 'yes';
>>> cfg.hemisphere  = 'both';
>>> cfg.inputcoord  = 'mni';
>>>
>>> stat = ft_sourcestatistics(cfg, sourceCondition1, sourceCondition2);
>>>
>>>
>> _______________________________________________
>> fieldtrip mailing list
>> fieldtrip at donders.ru.nl
>> http://mailman.science.ru.nl/mailman/listinfo/fieldtrip
>>
>>
>>    Jan-Mathijs Schoffelen, MD PhD
>>
>> Donders Institute for Brain, Cognition and Behaviour,
>> Centre for Cognitive Neuroimaging,
>> Radboud University Nijmegen, The Netherlands
>>
>> Max Planck Institute for Psycholinguistics,
>> Nijmegen, The Netherlands
>>
>> J.Schoffelen at donders.ru.nl
>> Telephone: +31-24-3614793
>>
>> http://www.hettaligebrein.nl/
>>
>>
>> _______________________________________________
>> fieldtrip mailing list
>> fieldtrip at donders.ru.nl
>> http://mailman.science.ru.nl/mailman/listinfo/fieldtrip
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20131009/47725795/attachment.html>

------------------------------

_______________________________________________
fieldtrip mailing list
fieldtrip at donders.ru.nl
http://mailman.science.ru.nl/mailman/listinfo/fieldtrip

End of fieldtrip Digest, Vol 35, Issue 11
*****************************************
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20131010/2efd6312/attachment-0002.html>


More information about the fieldtrip mailing list