Difference between revisions of "Manuals & Downloads / Repository"

From Neuroelectric's Wiki
Jump to: navigation, search
(MatNIC device controller)
(MatNIC device controller)
Line 144: Line 144:
  
 
The MatNIC zip file contains the following:
 
The MatNIC zip file contains the following:
  - The MatNIC manual (also available in our [ http://www.neuroelectrics.com/support/download| '''Downloads Area'''], an explanation on how to use the Matlab functions to remotely control NIC and
+
  - The MatNIC manual (also available in our [http://www.neuroelectrics.com/support/download '''Downloads Area'''], an explanation on how to use the Matlab functions to remotely control NIC and
 
  - RemoteStimulatioClient, a folder with all the Matlab functions for remotely controlling NIC, and an example on how to use them.
 
  - RemoteStimulatioClient, a folder with all the Matlab functions for remotely controlling NIC, and an example on how to use them.
  

Revision as of 16:10, 24 October 2013

In this page you can find links to our manuals and to a code repository. Many of these links are equivalent to those in our Download section in the Neuroelectrics website.

Neuroelectrics' systems include Enobio (EEG) and StarStim (EEG/tCS) class devices as well as our universal software controller - Neuroelectrics Instrument Controller (NIC). Manuals and other downloads are available for both.

Neuroelectrics Download Area for Manuals and software

Please visit http://www.neuroelectrics.com/support/download for an updated list of software updates (NIC, NIC Offline, API, etc), as well as user manuals.


Matlab code

Data Analysis

You can find here a zip file containing the following:

- NE_Viewer.m, a Matlab code to read and plot NE files, together with  
- some data  in .easy format and 
- a folder with the figures NE_Viewer.m generates with this data. 

The data and code are provided as examples of how to use Matlab to read and plot data.

The call used to generate the plots in the folder is

>> NE_Viewer('20130925192801_PatientTMS.easy',999,500,{'Fp1','Fp2','F3','F4','C3','C4','P3','Cz'});

The 999 mean "do average referencing" and the 500 is the sampling rate in S/s. The rest are electrode labels (the data has been collected using a StarStim 8 channels system).

Here is the header of NE_Viewer:

function [NEdata NEdataRefFilPack]= ...
                     NE_Viewer(filepath, ref, fs, LabelsElectrodes,band,T) 
% NE_Viewer(filepath) reads Enobio/StarStim (3G, released 2012) data in  
% ASCII (.txt or ".easy") or EDF format, and plots parts of it together 
% with its PSD and spectrogram.
%
% This function is provided as is as an example on how to work with NE instrument 
% data.
% 
% INPUTS: 
% Enobio/StarStim (8 or 20 or 32 Ch) data file path (mandatory) and other optional
% entries: "ref" the optional reference channel (use 0 for none, 999 for 
% an all electrode average), "fs" the sampling rate in S/s, 
% "LabelsElectrodes" a structure containing channel names, and "band" a 
% 2-element array with the low and high filtering frequency, e.g., 
% band=[1 40], in Hz. Finally, "T" is an arracy specifiying initital and 
% final time to analyze (in seconds), e.g., T=[10 130].
%
% OUTPUTS: 
% Returns the original, raw data pack, NEdata, as a Matlab variable.
% preserving the units (e.g., nV, ms). It also returnes NEdataRefFilPack, 
% the processed (referenced, detreneded, filtered) data (in uV). The time
% stamp (in seconds from start of the take) is provided in the last column.
%
% SIDE EFFECTS: creation of "figures" directory if it does not exist, 
%               creation of data plot figures of all Enobio channels, etc. 
% 
%       out = NE_Viewer(filepath) plots the data in the filepath
%       (filepath includes path relative to the Matlab current working 
%       directory of full absolute path), its PSD and spectrogram for each channel, 
%       etc., for 8 channels. As default it assumes a 500 Samples/s
%       sampling rate, and does not reference the data to any other
%       channel.  The code puts figures in a directory under the working
%       directory.
%      
%       NE_Viewer(filepath, ref) references the data to a chosen channel 
%       (ref should be a Channel number from 1 to 8 (or 20 for Enobio20), 
%       or zero to force no reference - the default). A reference = 999
%       means the average of all electrodes is used as reference.
% 
%       In addition, using the call NE_View(filepath, ref, fs) allows 
%       for changing the sampling rate fs in Samples/s. 
%      
%       Use a structure with LabelsElectrodes such as 
%         >> LabelsElectrodes={'Ch1','Ch2','Ch3','Ch4','Ch5','Ch6','Ch7','Ch8'}
%       with 
%         >> NE_View(filepath, ref, fs, LabelsElectrodes) 
%       to add LabelsElectrodes to channel IDs in plots.
% 
%
% EXAMPLE: assuming the data is in a folder called "data", 
%          NE_Viewer('./data/EC.txt')   % uses all defaults
%          NE_Viewer('./data/EC.txt',1)    % spedifies reference channel
%          NE_Viewer('./data/EC.txt',1,500) % specifies Sampling rate
%
%          To specify channel LabelsElectrodes
%          NE_Viewer('./data/EC.txt',1,500, ...
%                    {'Fp1','Fp2','P3','P4','O1','O1','T7','Pz'} ) 
%
%          To specifiy a filter band other than the default:
%          NE_Viewer('data/StarStim/20120728085042_TBtACS10Hz1mA.txt',0, ...
%                                                         [],[],[1 60]);
% 
%    As another example, 
%           
%       >> [NEdata NEdataRefFilPack]=NE_Viewer('data/Enobio8.txt');
%   and then plot data vs. time 
%       >> figure; plot(NEdataRefFilPack(:,9), NEdataRefFilPack(:,1));
%
% ABOUT THE NE ASCII DATA FORMAT (July 2012): 
%       NE ASCII files contain one line per time sample. Each line contains
%       first the EEG data (8 or 20 channels, depending on the device, with
%       units in nV), followed by  three acceleration channels (aX,aY,aZ 
%       in mm/s^2- millimeters per second squared), an *optional* external 
%       input channel, a trigger flag (int32) and, finally, 
%       a timestamp in Unix time (ms from Jan 1 1970):
%
% Ch1(nV) ... Ch8or20(nV) aX(mg) aY(mg) aZ(mg) AddSensor Flags(uint32) TimeStamp (ms)
%   
% Therefore Enobio8/StarStim will have a minimum of 8+2 (10) columns, or 8+3=11 if no 
%   accelerometer or >= 8+4 (with accelerometer). In summary:
%
%   Enobio8/20
%        10 Columns: no AddSensor, no accelerometer data:
%        11 Comumns: no accelerometer, but there is AddSensor
%        13 Columns: there is accelerometer, but no Addsensor
%        14 Comumns: there is accelerometer, AddSensor.
%
%   Enobio 20 will have >= 22 and >=24 columns if acc. data present:
%        22 Columns: no AddSensor, no accelerometer
%        23 Comumns: no accelerometer, but there is AddSensor
%        25 Columns: there is accelerometer, no AddSensor 
%        26 Comumns: there is accelerometer, AddSensor.
%
%   Enobio 32 will have >=34 adn >=36 if acc data is present
%        34 Columns: no AddSensor, no accelerometer
%        35 Comumns: no accelerometer, but there is AddSensor
%        37 Columns: there is accelerometer, no AddSensor 
%        38 Comumns: there is accelerometer, AddSensor.
%
%   Author(s): G.R. - Neuroelectrics Barcelona SL 
%   Copyright 2011-13 Neuroelectrics Barcelona SL
%   $Revision: 0.1 $  $Date: 2011/11/26 $ 
%   $Revision: 0.2 $  $Date: 2012/07/16 $ 
%   $Revision: 0.3 $  $Date: 2012/11/15 $ 
%   $Revision: 0.4 $  $Date: 2013/01/11 $ 
%   $Revision: 1.0 $  $Date: 2013/01/15 $ 
%   $Revision: 1.1 $  $Date: 2013/01/15 $ 

%   References:
%     [1] Enobio users guide. http://neuroelectrics.com

MatNIC device controller

MatNIC is a set of Matlab functions that allow remotely controlling NIC. These functions allow remotely starting and stopping the EEG streaming, loading a stimulation template and starting and stopping the stimulation protocol (when using a StarStim device).

The MatNIC zip file contains the following:

- The MatNIC manual (also available in our Downloads Area, an explanation on how to use the Matlab functions to remotely control NIC and
- RemoteStimulatioClient, a folder with all the Matlab functions for remotely controlling NIC, and an example on how to use them.

To run the example please make the following call:

>> ret = RemoteStimulationClient (templateName, '127.0.0.1', 1235)

where templaName is set with a name of an already defined stimulation template NIC, then the host where NIC is running (in the example above we use the localhost IP, so NIC is running in the same computer) and finally the port 1235 which is where the NIC server runs.

Here is the header of the example client code:

function [ret] = RemoteStimulationClient (templateName, host, port)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% RemoteStimulationClient
%
% This function implements a client to connect to the NIC Remote
% Stimulation Server. The server is running on the machine where the NIC
% application runs on the port 1235.
%
% The NIC Remote Server waits for the client to send the name of the 
% template that the client wants to use. If the NIC user accepts the
% remote control session, the template is loaded and the client is
% informed when the system is ready to start the stimulation.
%
% The client then might send the code to start the stimulation or the one
% to abort it. The abort command might be sent in any moment of the
% stimulation session. If the stimulation session is aborted locally from
% the NIC GUI the connection is automatically closed so the client needs
% to connect, send the template and wait again for the permission. When
% the stimulation script execution is finished the system prepares itself
% to start again a new stimulation so the code informing about that is
% received.
%
% The client might also send commands to start and stop receiving the EEG
% streaming. The data is received through a separate server on the port
% 1234. The 8/20 channel samples are sent in 4 bytes in two's complement.
% The MSB byte is sent first.
%
% The following are the functions to connect, send the commands to the
% server and read the status the server sends:
% - NICRemoteStimulationServerConnect
% - NICRemoteStimulationServerReadStatus
% - NICRemoteStimulationServerLoadTemplate
% - NICRemoteStimulationServerStartStimulation
% - NICRemoteStimulationServerAbortStimulation
% - NICRemoteStimulationServerStartEEG
% - NICRemoteStimulationServerStopEEG
%
% The following are the status that the server might send to the client
% and can be read with the NICRemoteStimulationServerReadStatus function:
%
% STATUS               |  TYPE         |       CODE
% -------------------------------------------------------
% EEG streaming is ON  |  Byte         |       0xF2
% -------------------------------------------------------
% EEG streaming is OFF |  Byte         |       0xF3
% -------------------------------------------------------
% Template not loaded  |  Byte         |       0xF8
% -------------------------------------------------------
% Template loaded      |  Byte         |       0xF9
% -------------------------------------------------------
% Stimulation is ready |  Byte         |       0xFC
% to be started        |               |
% -------------------------------------------------------
% Stimulation is ON    |  Byte         |       0xFD
% -------------------------------------------------------
% Stimulation is OFF   |  Byte         |       0xFE
% -------------------------------------------------------
%
% Input:
% templateName: Name of the template to be loaded on NIC.
% host: Name or IP of the host where NIC is running.
% port: Port number where the NIC server runs.
%
% Output:
% ret: Zero or positive number if the function completes successfully. A
% negative number otherwise:
% -1: The connection to the host and port number did not succeed.
% -2: Error writing template name.
% -3: Error reading from server.
% -4: Template not loaded.
% -5: Error writing command to the server.
%
% Author: Javier Acedo (javier.acedo@starlab.es)
% Company: Neuroelectrics
% Created: 16 Jan 2013
% Known issues: None
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%