⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 vmp_makehiresvmp.m

📁 toolbox of BVQX, This is the access between BV and matlab. It will help you to analysis data from BV
💻 M
字号:
function hvmp = vmp_MakeHiResVMP(hfile, mapno)
% VMP::MakeHiResVMP  - convert one of the VMP maps to hi-res
%
% FORMAT:       hvmp = vmp.MakeHiResVMP([mapno])
%
% Input fields:
%
%       mapno       if given, only convert sub-selection
%
% Output fields:
%
%       hvmp        1x1x1 interpolated VMP

% Version:  v0.7b
% Build:    7083111
% Date:     Aug-31 2007, 11:48 AM CEST
% Author:   Jochen Weber, Brain Innovation, B.V., Maastricht, NL
% URL/Info: http://wiki.brainvoyager.com/BVQXtools

% argument check
if nargin < 1 || ...
    numel(hfile) ~= 1 || ...
   ~isBVQXfile(hfile, 'vmp')
    error( ...
        'BVQXfile:BadArgument', ...
        'Invalid call to %s.', ...
        mfilename ...
    );
end
bc = bvqxfile_getcont(hfile.L);
if nargin < 2 || ...
   ~isa(mapno, 'double') || ...
    isempty(mapno) || ...
    any(isinf(mapno(:)) | isnan(mapno(:)) | mapno(:) < 1)
    mapno = 1:numel(bc.Map);
end
mapno = unique(round(mapno(:)));
mapno(mapno > numel(bc.Map)) = [];
if isempty(mapno)
    error( ...
        'BVQXfile:BadArgument', ...
        'Invalid sub-selection of maps.' ...
    );
end
numm = numel(mapno);

% get dims right
xs = bc.XStart;
xe = bc.XEnd;
ys = bc.YStart;
ye = bc.YEnd;
zs = bc.ZStart;
ze = bc.ZEnd;
br = bc.Resolution;
sr = 1 / br;
mapx = (xe - xs) / br;
mapy = (ye - ys) / br;
mapz = (ze - zs) / br;
dimx = xe - xs + 1;
dimy = ye - ys + 1;
dimz = ze - zs + 1;
dims = [dimx, dimy, dimz];

% special cases
if ~bc.NativeResolutionFile
    error( ...
        'BVQXfile:InvalidObject', ...
        'This method is only available for NativeResolutionFiles.' ...
    );
end
if br == 1
    hvmp = aft_CopyObject(vmp);
    hbc = bvqxfile_getcont(hvmp.L);
    if any(size(hbc.Map(1).VMPData) ~= dims)
        for mc = 1:numel(hbc.Map)
            hbc.Map(mc).VMPData = ...
                single(reframearray(hbc.Map(mc).VMPData, dims, single(0)));
        end
    end
    bvqxfile_setcont(hvmp.L, hbc);
    return;
end

% resampling required, so create output object
hvmp = BVQXfile('new:vmp');
hbc = bvqxfile_getcont(hvmp.L);
hbc.FileVersion = 3;
hbc.NrOfMaps = numm;
hbc.VMRDimX = 256;
hbc.VMRDimY = 256;
hbc.VMRDimZ = 256;
hbc.XStart = xs;
hbc.XEnd = xe;
hbc.YStart = ys;
hbc.YEnd = ye;
hbc.ZStart = zs;
hbc.ZEnd = ze;
hbc.Resolution = 1;

% create default map
hbc.Map.Type = 1;
hbc.Map.Name = '';
hbc.Map.VMPData = single([]);
hbc.Map.VMPData(1:dimx, 1:dimy, 1:dimz) = single(0);
hbc.Map(2:numm) = hbc.Map(1);

% get interpolation matrices
[cx, cy] = ndgrid(single(1:sr:(mapx + 1)), single(1:sr:(mapy + 1)));
ncx = size(cx, 1);
ncy = size(cx, 2);
cx = cx(:);
cy = cy(:);
numcrds = numel(cx);
slicecoords = single(1:sr:mapz);

% resample maps
hMap = hbc.Map;
oMap = bc.Map;
for cc = 1:numm
    
    % copy settings first
    mc = mapno(cc);
    hMap(cc).Type                 = oMap(mc).Type;
    hMap(cc).LowerThreshold       = oMap(mc).LowerThreshold;
    hMap(cc).UpperThreshold       = oMap(mc).UpperThreshold;
    hMap(cc).Name                 = oMap(mc).Name;
    hMap(cc).RGBLowerThreshPos    = oMap(mc).RGBLowerThreshPos;
    hMap(cc).RGBUpperThreshPos    = oMap(mc).RGBUpperThreshPos;
    hMap(cc).RGBLowerThreshNeg    = oMap(mc).RGBLowerThreshNeg;
    hMap(cc).RGBUpperThreshNeg    = oMap(mc).RGBUpperThreshNeg;
    hMap(cc).UseRGBColor          = oMap(mc).UseRGBColor;
    hMap(cc).TransColorFactor     = oMap(mc).TransColorFactor;
    hMap(cc).NrOfLags             = oMap(mc).NrOfLags;
    hMap(cc).MinLag               = oMap(mc).MinLag;
    hMap(cc).MaxLag               = oMap(mc).MaxLag;
    hMap(cc).CCOverlay            = oMap(mc).CCOverlay;
    hMap(cc).ClusterSize          = oMap(mc).ClusterSize * (br ^ 3);
    hMap(cc).EnableClusterCheck   = oMap(mc).EnableClusterCheck;
    hMap(cc).UseValuesAboveThresh = oMap(mc).UseValuesAboveThresh;
    hMap(cc).DF1                  = oMap(mc).DF1;
    hMap(cc).DF2                  = oMap(mc).DF2;
    hMap(cc).BonferroniValue      = oMap(mc).BonferroniValue;
    
    % interpolate content
    omapc = oMap(mc).VMPData(:, :, :);
    nmapc = hbc.Map(end).VMPData;
    for sc = 1:numel(slicecoords)
        cz = slicecoords(sc) * ones(numcrds, 1);
        nmapc(:, :, sc) = reshape( ...
            interpn_linnonull(omapc, cx, cy, cz), [ncx, ncy]);
    end
    hMap(cc).VMPData = nmapc;
end

% store back
hbc.Map = hMap;
bvqxfile_setcont(hvmp.L, hbc);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -