Home > vbmeg > external > mne > fiff_write_short.m

fiff_write_short

PURPOSE ^

SYNOPSIS ^

function fiff_write_short(fid, kind, data)

DESCRIPTION ^

 fiff_write_short(fid, kind, data)

 Writes a 16-bit integer tag to a fif file

     fid           An open fif file descriptor
     kind          Tag kind
     data          The integers to use as data

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function fiff_write_short(fid, kind, data)
0002 %
0003 % fiff_write_short(fid, kind, data)
0004 %
0005 % Writes a 16-bit integer tag to a fif file
0006 %
0007 %     fid           An open fif file descriptor
0008 %     kind          Tag kind
0009 %     data          The integers to use as data
0010 %
0011 
0012 %
0013 %   Author : Matti Hamalainen, MGH Martinos Center
0014 %   License : BSD 3-clause
0015 %
0016 %   Revision 1.1  2006/04/27 22:38:37  msh
0017 %   Splitting an empty list now results in an empty output.
0018 %   Added fiff_write_double and fiff_write_short
0019 %   Write an array of floats, ints, and doubles instead of just one value.
0020 %   Fixed help text of fiff_pick_channels.
0021 %
0022 %
0023 
0024 me = 'MNE:fiff_write_short';
0025 
0026 if nargin ~= 3
0027     error(me, 'Incorrect number of arguments');
0028 end
0029 
0030 FIFFT_SHORT = 2;
0031 FIFFV_NEXT_SEQ = 0;
0032 nel = numel(data);
0033 datasize = nel * 2;
0034 count = fwrite(fid, int32(kind), 'int32');
0035 if count ~= 1
0036     error(me, 'write failed');
0037 end
0038 count = fwrite(fid, int32(FIFFT_SHORT), 'int32');
0039 if count ~= 1
0040     error(me, 'write failed');
0041 end
0042 count = fwrite(fid, int32(datasize), 'int32');
0043 if count ~= 1
0044     error(me, 'write failed');
0045 end
0046 count = fwrite(fid, int32(FIFFV_NEXT_SEQ), 'int32');
0047 if count ~= 1
0048     error(me, 'write failed');
0049 end
0050 count = fwrite(fid, int16(data), 'int16');
0051 if count ~= nel
0052     error(me, 'write failed');
0053 end
0054 
0055 return

Generated on Mon 22-May-2023 06:53:56 by m2html © 2005