BrainVoyager - Matlab interoperability

The following code was kindly provided by Alex Wade, Stanford University:

------ CreateProjects.m ----------


% MATLAB BrainVoyager script
% Brainvoyager can be accessed as a COM server via MATLAB's activex functions.
% The script below is based on createprojects.vbs found in the BrainVoyager/Samples/objectsrawdata/ directory.
% Basically, you use 'actxserver' to create the BrainVoyager handle (opens BV if it doesn't already exist)
% and then use 'invoke' to call the functions. You can also use invoke on handles to documents as well as the activex server.
% ARW 07/06/00

BrainVoyager = actxserver('BrainVoyager.1');


% Use BVpath since 'path' is a reserved word in Matlab
% You could also use the matlab command pwd to help here...

BVpath = 'c:\program files\BrainVoyager\Samples\objectsrawdata\';

docFMR_T1=invoke(BrainVoyager,'CreateProjectFMR', 'IMA',[BVpath,'5807-2-4.ima'], 1, 15, 'r1_firstvol-', 1, 128, 128, 2, BVpath);

invoke(docFMR_T1,'ConvertFuncToAMR',[BVpath,'func_as_anat.amr']);
invoke(docFMR_T1,'SaveAs',[BVpath,'r1_firstvol.fmr']);
invoke(docFMR_T1,'Close');
doc = invoke(BrainVoyager,'CreateProjectFMR','IMA', [BVpath,'5807-4-34.ima'], 126, 15, 'r1_slice-', 1, 128, 128, 2, BVpath);

% Display it nicely
invoke(doc,'SetLayoutRowsCols', 3, 5);
invoke(doc,'SetZoomLevel', 1);

% Link in the AMR and stimulation protocol
invoke(doc,'LinkAMRFile',[BVpath,'func_as_anat.amr']);
invoke(doc,'LinkStimulationProtocol', [BVpath,'cg_objects.prt']);
invoke(doc,'SaveAs',[BVpath,'cg_objects.fmr']);

% do slice time correction
invoke(doc,'SliceTimeCorrectionEx',4500, 155, 1, [BVpath,'cg_objects_sc.fmr'], [BVpath,'r1_slice_sc-']);
invoke(doc,'Close');

docVMR = invoke(BrainVoyager,'CreateProjectVMR','IMA',[BVpath,'5807-130-1924.ima'], 170, 1, 256, 256, 2);
invoke(docVMR,'SaveAs', [BVpath,'cg_3DT1MPR.vmr']);

invoke(docVMR,'Close');

% You get the idea....