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

📄 bvqx_srf_writeneighbors.m

📁 toolbox of BVQX, This is the access between BV and matlab. It will help you to analysis data from BV
💻 M
字号:
function bvqx_srf_writeneighbors(fid, varargin)
% bvqx_srf_writeneighbors  - write neighbors to SRF file
%
% FORMAT:       bvqx_srf_parseneighbors(fid, neighbors [, sanitycheck])
%
% Input fields:
%
%       fid         input file fid (fopen)
%       neighbors   Nx2 cell array with neighbor numbers and lists
%       sanitychecks, if given, check number of neighbors and content
%
% See also BVQXfile, bffio, bvqx_srf_parseneighbors

% Version:  v0.7b
% Build:    7083015
% Date:     Aug-30 2007, 3:23 PM CEST
% Author:   Jochen Weber, Brain Innovation, B.V., Maastricht, NL
% URL/Info: http://wiki.brainvoyager.com/BVQXtools

% argument check
if nargin < 2 || ...
   ~isa(fid, 'double') || ...
    isempty(fid) || ...
   ~isreal(fid) || ...
   ~any(fopen('all') == fid(1)) || ...
   ~iscell(varargin{1}) || ...
    isempty(varargin{1}) || ...
    length(size(varargin{1})) ~= 2 || ...
    size(varargin{1}, 2) ~= 2
    error( ...
        'BVQXtools:BadArgument', ...
        'Bad or missing argument.' ...
    );
end
neighbors = varargin{1};

% grand TRY loop
try
    
% without checks
if nargin < 3

    % loop over content
    for nc = 1:size(neighbors, 1)

        % write number of neighbors
        fwrite(fid, numel(neighbors{nc, 2}), 'uint32');

        % write neighbors 
        fwrite(fid, neighbors{nc, 2}(:) - 1, 'uint32');

    end

% with checks
else

    % loop over content
    for nc = 1:size(neighbors, 1)

        % check number of neighbors
        if isemtpy(neighbors{nc, 1}) || ...
            neighbors{nc, 1}(1) ~= numel(neighbors{nc, 2})
            error('BAD_NEIGHBORS_LIST');
        end

        % write number of neighbors
        fwrite(fid, numel(neighbors{nc, 2}), 'uint32');

        % write neighbors 
        fwrite(fid, neighbors{nc, 2}(:), 'uint32');

    end
end

% error handling
catch
    error( ...
        'BVQXtools:BadFileOrContent', ...
        'Writing of file failed with: ''%s''.', ...
        lasterr ...
    );
end

⌨️ 快捷键说明

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