BVQXtools code samples

From BVwiki

Jump to: navigation, search

Contents

Requirements

All samples require the installation of the BVQXtools toolbox in the MATLAB path. The version with which the example has been created (which can be seen as the minimum requirement) is denoted in the example respectively.

Design matrices

Concatenation

Available as of version 0.5a

In case you have two (or several) runs and want to create a combined design matrix (that can be used for PSC/z-transformed concatenated time courses), there is a very simple way to come to this:

>> r1 = BVQXfile('run_1.rtc');
>> r2 = BVQXfile('run_2.rtc');
>> r1and2 = r1.Concatenate(r2);
>> r1and2.SaveAs('run_1and2.rtc');

As part of this process, ambiguous regressor names will be appended with the study (run) number. The result then looks like this

  Design matrix for run 1 + Design matrix for run 2
= Blocked design matrix for runs 1 and 2

GLM's

Concatenating FFX GLMs

Available as of version 0.5c In case you have many, many subjects and yet want to use full (per-study) predictor separation, the calculation may take a while. BrainVoyager QX actually creates a design matrix that allows to code between-subject interactions, which normally (unless you explicitely and manually do so) are not part of the design matrix. Hence the calculus can be sped up by splitting the MDM in some partitions, calculate the FFX models separately and then joining them together again:

>> mdm = BVQXfile('study.mdm');   % read MDM
>> mdm.NrOfStudies = 10;          % take only first ten
>> mdm.XTC_RTC = mdm.XTC_RTC(1:10,:);
>> mdm.SaveAs('first10.mdm');
% (...) do so for 11-20, etc.
>> glm = BVQXfile('first10.glm');
>> glm = glm.JoinFFX(BVQXfile('second10.glm'));
>> glm = glm.JoinFFX(BVQXfile('remaining.glm'));
>> glm.SaveAs('fullgroup.glm');

VMRs

Creation of the Talairach VMR

Available as of version 0.5b

The TalairachBrain.vmr file can be, principally, self generated from the Talairach Daemon database with the following commands

>> vmr = BVQXfile('vmr');
>> vd = vmr.VMRData;
>> ba = [1:13, 17:25, 27:47];
>> for bc = 1:length(ba), bvc = tal2bv(tdlocal(6, sprintf('Brodmann area %d', ba(bc))))';
    for cc = 1:size(bvc), vd(bvc(cc,1)+1, bvc(cc,2)+1, bvc(cc,3)+1) = uint8(226 + mod(bc-1, 20)); end
end
>> vmr.VMRData = vd;
>> vmr.SaveAs('TalBrainAlternative.vmr');

On the first call to tdlocal, a cache file will be created that, for future sessions, will speed up this a lot!

Caution: the resulting VMR file will not be 100 per cent identical!

Comparison of own with BVQX Talairach VMR


Cleaning, and brain peeling of VMR

Available as of version 0.7a, Snapshot 37 (Aug/26/07)

The code is relatively simple (for a better understanding, check the BVQXtools SBS VMR cleaning guide).

Part 1: cleaning the V16

>> v16 = BVQXfile('*.v16');
>> v16_clean = v16.CleanVMR;
>> v16_clean.LimitVMR;
>> v16_clean.SaveAs;

Part 2: Peeling the VMR

>>vmr = BVQXfile('*.vmr');
>> vmr_peeled = vmr.PeelBrain;
>> vmr_peeled.SaveAs;
>> vmr = BVQXfile('*.vmr');

Caution: these functions are still experimental!

Final peeled result in BVQX


Personal tools