private/main.m
aaaeb6c5
 function main(model,task,subtask)
a974da24
 disp('RUN');
aaaeb6c5
 switch task 
     case 'pre'
         preprocess(model,subtask);
     case 'decode'
         decode(model,subtask);
9760fd2f
     case 'plot'
         decode_plot(model,subtask);
aaaeb6c5
 end
 end
7a4d3666
 % disp('all warnings OFF')
 % warn = warning('off','all');
 
aaaeb6c5
 
 function preprocess(model,task)
 % parse the GUI and pass parameters as structure
 
17910a1f
 evalin('base','clear(''preprocessedData'')');
 
a974da24
 timeLine = getTimeLineParams(model);
 subjects = getSubjectCellList(model);
 classDef = parseClassDef(model);
e0049736
 
 mask     = ['^' cell2mat(getImageFileMask(model)) '.*\.img$'];
fb860baf
 
 psthOpts = struct;
 psthOpts.colBias       = getColumnBiasRemoveOption(model);
 psthOpts.psthNorm      = getPsthNormalizationMethod(model);
 
a974da24
 
 switch task
     case 'COORD'
aa0fb379
         disp('LUT Approach');
aaaeb6c5
        
         out = struct;
         out.header = struct;
         out.header.type = 'COORD';
         out.header.timeline = timeLine;
         out.header.classDef = classDef;
         
e0049736
         coordargs = struct;
aaaeb6c5
         coordargs.subjects      = subjects;
         coordargs.timeline      = timeLine;
de857369
         coordargs.basedir       = getBaseDir(model);
aaaeb6c5
         coordargs.sessionList   = 1:3;
         coordargs.eventList     = classDef.eventMatrix;
         coordargs.coords        = parseCoordinateTextField(model);
         coordargs.mask          = mask;
fb860baf
         coordargs.psthOpts      = psthOpts;
aa0fb379
         coordargs.groupingFkt   = getSpatialGroupingFunction(model);
aaaeb6c5
         
         out.subjectdata = runCoordTable(coordargs);
7614718d
 
a974da24
     case 'ROI'
aa0fb379
         disp('ROI Image Approach');
f7802160
         out = struct;
         out.header = struct;
         out.header.type = 'ROI';
         out.header.timeline = timeLine;
         out.header.classDef = classDef;
         
ea58b69a
         roiargs = struct;
aaaeb6c5
         roiargs.subjects        = subjects;
         roiargs.timeline        = timeLine;
         roiargs.classes         = classDef;
         roiargs.mask            = mask;
         roiargs.basedir         = model.baseDir;
         roiargs.sessionList     = 1:3;
         roiargs.eventList       = classDef.eventMatrix;
fb860baf
         roiargs.psthOpts        = psthOpts;
ea58b69a
         
f7802160
         out.subjectdata = runROIImageMaskMode(roiargs);
         
a974da24
     case 'FBS'
9b240b57
         disp('FSB');
         out = struct;
         out.header = struct;
         out.header.type = 'FBS';
         out.header.timeline = timeLine;
         out.header.classDef = classDef;
         
7614718d
 
ef027ada
         out.subjectdata  = fbs_load_mask(getBaseDir(model),subjects);
9b240b57
         
93eb4bd9
 %         if(size(subjects,2)>1)
 %             display(sprintf('No BATCH Support for Searchlight!'));
 %             return
 %         end
9b240b57
         
7614718d
         fbsargs = struct;
9b240b57
         fbsargs.timeline        = timeLine;
         fbsargs.classes         = classDef;
         fbsargs.mask            = mask;
ef027ada
         fbsargs.basedir         = getBaseDir(model);
9b240b57
         fbsargs.sessionList     = 1:3;
         fbsargs.eventList       = classDef.eventMatrix;
         fbsargs.psthOpts        = psthOpts;
7614718d
 
         out.header.args         = fbsargs;
 
         % no more preprocessing in this step!
9b240b57
                 
aaaeb6c5
 end
7614718d
 
 assignin('base','preprocessedData',out);
 
 
aaaeb6c5
 end
 
 function decode(model,task)
8959ce94
 preprocessedData = evalin('base','preprocessedData');
feeb21e9
 
22335072
 if(~(isa(preprocessedData,'struct')))
     display('you need to preprocess some data before this step');
     return
 end
17910a1f
 warn = warning('off','all');
feeb21e9
 header            = preprocessedData.header;
 header.frameShift = getFrameShiftParams(model);
aa0fb379
 header.timeframeGroupingfunction = getTemporalGroupingFunction(model);
feeb21e9
 data              = preprocessedData.subjectdata;
 
aaaeb6c5
 switch task
0e963b35
     case 'SVM'
aaaeb6c5
         disp('SVM');
         svmopts    = getSvmArgs(model,1);
7984c76d
         header.svmrnd = getSvmRnd(model);
a37f1788
         header.nantozero = 1;
feeb21e9
         decode = calculateMultiSubjectDecodePerformance(header,data,svmopts);
27ebd4d9
         decode.header = header;
f7802160
         assignin('base','decode',decode);
8959ce94
     case 'XSVM'
2de68580
         disp('XSVM')
8959ce94
         svmopts  = getSvmArgs(model,0);
a37f1788
         header.svmrnd = getSvmRnd(model);
         header.nantozero = 1;
feeb21e9
         decode = xsvm_subject_loop(header,data,svmopts);
27ebd4d9
         decode.header = header;
8959ce94
         assignin('base','decode',decode);
0e963b35
     case 'SOM'
22335072
         display('SOM');
a37f1788
         somopts.rnd = 1;
         somopts.nantozero = 1;
916fe4f9
         somopts.size = [3 3];
         somopts.lattice = 'rect';
         somopts.nfold = 6;
         decode = som_subject_batch(header,data,somopts);
         decode.header = header;
         assignin('base','decode',decode);
d0ee75cf
     case 'XSOM'
         display('XSOM');
a37f1788
         somopts.rnd = 1;
         somopts.nantozero = 1;
b0a2dbf1
         somopts.size = [3 3];
         somopts.lattice = 'rect';
         decode = som_xsubject_performance(header,data,somopts);
22335072
         decode.header = header;
         assignin('base','decode',decode);
aa21d53b
     case 'FBS'
b0a2dbf1
         display('FBS');
87b08fd7
         fbsargs.svmopts = getSvmArgs(model,1);
         header.svmrnd   = getSvmRnd(model);
7614718d
         fbsargs.radius  = getSearchlightRadius(model);
0e95aa2f
         fbsargs.timeline = getSearchlightTimeline(model);
7614718d
             runFBSImageMaskMode(header,data,fbsargs);
0e963b35
         
a974da24
 end
 
17910a1f
 disp('warings restored');
 warning(warn);
2e65fc12
 end
07662323
 
9760fd2f
 function decode_plot(model,type)
27ebd4d9
 decode = evalin('base','decode');
 preprocessed = evalin('base','preprocessedData');
 plotDecodePerformance(type,decode,preprocessed.subjectdata);
        
feeb21e9
 end
 
07662323
 
 
ea0c5c02