Skip to content
Bruno Miguel edited this page Nov 27, 2015 · 1 revision

Welcome to the TBV_MATLAB_RECEIVER wiki!

main.m

Implements the comparison between 4 different methods to compute the mean ROI activation.

First, turn on the TBV 3.2 with the network plugin 1.7.

run main.m.

The first part, will establish a connection with the network plugin (please define configs.TBV_IP and configs.TBV_PORT according to the properties of the TBV network plugin). If the connection is successful a message will appear in the MATLAB command prompt: "connection open: 1"

Then, the number of ROIs is retrieved (tbvNetInt.tGetNrOfROIs();) as well as the coordinates for each ROI. Please notice that TBV indexes variables using 0-index, and MATLAB 1-index (to retrieve coordinates for the ROI #1, please use tGetAllCoordsOfVoxelsOfROI(0) )!

coordsOfVoxelsOfROI = cell([1 n_rois]);
for i=1:n_rois
    coordsOfVoxelsOfROI{i} = tbvNetInt.tGetAllCoordsOfVoxelsOfROI(i - 1); 
end

The function tGetDimsOfFunctionalData returns the dimensions of the functional dataset (64x64x30 for the default dataset); and tGetExpectedNrOfTimePoints returns the number of points expected in the dataset.

Then we can iterate over time t (Please notice that TBV indexes variables using 0-index, and MATLAB 1-index):

while time <= currentTime
   if time == currentTime && currentTime ~= expectedTime
        disp('Waiting...')
        pause(5)
        counter = counter + 1;
        if counter == 5
            break;
        end
    else
        %---Method 1 --> Get Mean ROI
        [ROImeansM1(time,:),timeM1(time)] = method1(n_rois,tbvNetInt,time-1);
 
        %---Method 2 --> All Voxels
        [ROImeansM2(time,:),timeM2(time)] = method2(n_rois,tbvNetInt,coordsOfVoxelsOfROI,xDim,yDim,time-1);
    
        %---Method 3 --> All Voxels Raw
        [ROImeansM3(time,:),timeM3(time)] = method3(n_rois,tbvNetInt,coordsOfVoxelsOfROI,xDim,yDim,time-1);
    
        %---Method 4 --> Voxels 1by1
        [ROImeansM4(time,:),timeM4(time)] = method4(n_rois,tbvNetInt,coordsOfVoxelsOfROI,time-1);
    
        fprintf('Time %d \n',time);
    
        time = time + 1;
        counter = 0;
    end
    currentTime = tbvNetInt.tGetCurrentTimePoint;
end
Clone this wiki locally