Working with matlab – Multichannel Systems NeuroExplorer User Manual

Page 37

Advertising
background image

1.20. Working with Matlab


NeuroExplorer can interact with Matlab via COM interface using Matlab as a powerful post-
processing engine. Matlab can also control NeuroExplorer and exchange data with NeuroExplorer via
NeuroExplorer COM interfaces. See

COM/ActiveX Interfaces

for details.


Immediately after calculating the histograms, NeuroExplorer can send the resulting matrix of
histograms to Matlab and then ask Matlab to execute any series of Matlab commands.


Use the Matlab tab in the Analysis parameters dialog to specify the matrix name and the Matlab
command string.


NeuroExplorer can also send its data variables to Matlab. To transfer the variables to Matlab, use
Matlab | Send Selected Variables to Matlab menu command.


In general, a continuous variable may contain several fragments of data. Each fragment may be of a
different length. NeuroExplorer does not store the timestamps for all the A/D values since they would
use too much space. Instead, for each fragment, it stores the timestamp of the first A/D value in the
fragment and the index of the first data point in the fragment. Therefore, for a continuous variable
(named ContVar1), the following 3 vectors will be created in Matlab:

ContVar1 - vector (or matrix with 2 columns) of all A/D values in milliVolts. If "Optimize transfer
for small amounts of data" is selected in View | Options | Matlab, Contvar1 is a matrix with 2
columns: the first column contains A/D values in millivolts, the second column contains
timestamps in seconds.
ContVar1_ts - vector of fragment timestamps in seconds. Each timestamp is for the first A/D
value of the fragment.
ContVar1_ind - array of indexes. Each index is the position of the first data point of the
fragment in the A/D array. If ContVar1_ind (2) = 201, it means that the second fragment is
ContVar1 [201], ContVar1 [202], etc.
ContVar1_ts_step - digitizing step in seconds.


You can generate all the timestamps for continuous variable using this Matlab script:

function [ ts ] = MakeTs( fragmentInd, fragmentTs, numValues, step )

% MakeTs: makes timestamps for continuous variable based on the fragment

% information

% INPUT: fragmentInd - vector of fragment indexes

% fragmentTs - vector of fragment timestamps

% numValues - total number of values in all fragments

% step - digitizing step of continuous variable

%

% Example: NeuroExplorer sent continuous variable FP01 via file transfer

% The following values were sent:

% FP01 - vector of continuous values

% FP01_ind - fragment indexes

% FP01_ts - fragment timestamps

% FP01_ts_step - digitizing step

%

% to generate all timestamps for FP01, use:

%

% ts = MakeTs(FP01_ind, FP01_ts, size(FP01,1), FP01_ts_step);

%

ts = [];

numFr = size(fragmentTs);

% add fake index for the last fragment

fragmetInd = [fragmentInd; numValues+1];

for i=1:numFr

valuesInFragment = fragmetInd(i+1)-fragmentInd(i);

Page 35

Advertising