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

📄 bffdocu.m

📁 toolbox of BVQX, This is the access between BV and matlab. It will help you to analysis data from BV
💻 M
字号:
function [varargout] = bffdocu
% BFF documentation (file format, usage)
% -------------------------------------------------------------------
%
% BFF (binary file format) is a text based specification given to
% read binary files (primarily with fixed sized content).
%
% The specification file itself must meet the following requirements
% to be recognized (and successfully parsed by bffparse()):
%
%  - empty lines are removed from the file
%  - all lines will be cut after any occurance of a hash mark (#)
%  - the first line of the file MUST contain the token 'BinaryFileFormat'
%  - the following tokens are recognized as single line options:
%    * EncodingSyntax:<either 'native', 'ieee-le', or 'ieee-be'>
%    * Extensions:<comma separated list of supported file extensions>
%    * FilenameMatch:<comma separated list of regexpi tokens>
%    * Filetype:<string used for file open dialogs and texts>
%    * TransIOSize:<string that must evaluate to a number of bytes>
%  - the following tokens are used as section delimiters
%    * AfterReadCode:                     [opens a section until]
%    * EndAfterReadCode
%    * BeforeWriteCode:                   [opens a section until]
%    * EndBeforeWriteCode
%    * ListOfFields:<field delimiter>     [opens a section until]
%    * EndListOfFields
%    * Magic:<field delimiter>            [opens a section until]
%    * EndMagic
%
% ----
%
% The AfterReadCode and BeforeWriteCode sections may contain code
% that is executed either after reading the file or before writing
% the file to disk (even before a file open is attempted in the
% latter case).
%
% Both sections may contain ($|@)([a-z][a-z_0-9]*)/i variable
% references, which will be resolved correctly. Make sure that the
% code does NOT contain hash marks (other than to comment out things
% that is!)
%
% ----
%
% The ListOfFields section describes the rules to read and write the
% binary file contents. Conditional reads and writes can be made (to
% support different sub-formats or versions of the same file type),
% loops can be used and valid expressions calculated. The section
% itself is a formatted table which in its first row must contain at
% least the following header tokens (order irrelevant):
%
%  - type:     either of
%              - 'BLOOP': begin loop (name in varname, length in dim)
%              - 'ELOOP': end loop (name must match)
%              - 'EXPRE': evaluate an expression
%              - 'FIELD': read a field from file
%              - 'SKIPN': skip the next N rules (given in dim)
%              - 'XLOOP': exit loop (on condition, name must match)
%              lines with an empty type field are discarded
%  - cond:     conditional statement when to go/exit into a loop or
%              read/write a field, e.g. '@FileVer > 1 & @FileVer < 16'
%  - disktype: reading datatype (char, uint16, int32, single, ...)
%  - datatype: storage datatype (uint32, double, colorcode, ...)
%              custom datatypes can be given, for which two functions
%              MUST exist (DISKTYPE2DATATYPE and DATATYPE2DISKTYPE,
%              e.g. uint322colorcode and colorcode2uint32)
%  - dim:      dimension (1-D for BLOOP, N-D for FIELD)
%  - default:  default value (in datatype syntax), if given, FIELD
%              content may be missing on writing calls to bffio(...)
%  - varname:  depending on type:
%              - 'BLOOP': loop variable name (used by $LOOPVAR)
%              - 'EXPRE': evaluated expression
%              - 'FIELD': source/target variable (postfixed to struct)
% 
% Next to the built-in datatypes (fread, fwrite), one additional
% datatype is supported by bffio: cstring. It reads until the next
% 0x00 value is encountered in the stream, and upon writing adds this
% end-of-string signature into the file. Multiple strings can be used
% by giving a non singleton dimension.
%
% EXPREssions can re-use FIELD varnames (FIELD itself is able to use
% inline expressions). Variables are addressed via $VARNAME and,
% internally, resolved via the struct namevars.(...).
%
% FIELDs are read into both namevars.(...) and bffcont.(...). To set
% or alter content in the bffcont struct, the syntax @VARNAME can be
% used in EXPREssions.
%
% The following variables can be used as predefined variables:
%
% $BFFVERSION: version string of bffio, also copied to bffcont struct
% $BFFREAD:    if true, indicates that the file is being read from
% $BFFWRITE:   if true, indicates that the file is being written to
% $EXTENSION:  file extension of the file currently being read/written
% $FILENAME:   name of the file currently being read/written
% $FILESIZE:   size of the file (only available in read mode)
%
% # Here is an example for a ListOfFields section:
% ListOfFields:!
% type !cond        !disktype!datatype!dim       !default !varname
% 
% # read file version
% FIELD!            !uint16  !double  !1, 1      !1       !FVersion
%
% # get dimensions for writing
% EXPRE!$BFFWRITE   !!!!!@DimX = size(@BinData, 1);
% EXPRE!$BFFWRITE   !!!!!@DimY = size(@BinData, 2);
%
% # read/write dimensions
% FIELD!            !uint32  !double  !1, 1      !        !DimX
% FIELD!            !uint32  !double  !1, 1      !        !DimY
%
% # read/write data
% FIELD!            !uint8   !uint8   !@DimX, @DimY !     !BinData
% EndListOfFields
%
% For more extensive examples, please have a look at the BFF spec
% files coming with this toolbox.
%
% ----
%
% The Magic section describes, if possible for the format, how it can
% be detected from its content. The section itself is a formatted table
% which in its first row must contain at least the following header
% tokens (order irrelevant):
%  - name:     unique token to go with this format
%  - range:    1x2 double (integer) array to look for in the file
%              negative numbers are considered as reverse from EOF
%  - type:     either of 'strfind', 'hex', 'regexp'
%  - magic:    pattern to match to accept content;
%              - strfind: simple string
%              - hex:     packed content, syntax: 00,08,00,10[,...]
%              - hex16:   packed content, syntax: 0800,0010[,...]
%              - hex32:   packed content, syntax: 08000010[,...]
%              - regexp:  regular expression, any 0x{CC} are replaced
%                         to allow custom characters, such as | and #
%              - regexpi: regular expression, case ignored
%              - strfind: do a simple strfind with range and pattern
%
% # Here is an example for a Magic section
% Magic:|
% name         |range       |type    |magic
% BMP_bmType   |1, 2        |strfind |BM
% EndMagic
%
% In practice this would mean that a file containing the string 'BM'
% within the byte range [1, 2] would be recognized as, in this case, a
% Windows BITMAP (BMP) file.

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

varargout = cell(1, nargout);
help bffdocu;

⌨️ 快捷键说明

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