Home > vbmeg > external > mne > fiff_write_int_matrix.m

fiff_write_int_matrix

PURPOSE ^

SYNOPSIS ^

function fiff_write_int_matrix(fid,kind,mat)

DESCRIPTION ^

 fiff_write_int_matrix(fid,kind,mat)
 
 Writes a integer matrix tag

     fid           An open fif file descriptor
     kind          The tag kind
     mat           The data matrix

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function fiff_write_int_matrix(fid,kind,mat)
0002 %
0003 % fiff_write_int_matrix(fid,kind,mat)
0004 %
0005 % Writes a integer matrix tag
0006 %
0007 %     fid           An open fif file descriptor
0008 %     kind          The tag kind
0009 %     mat           The data matrix
0010 %
0011 
0012 %
0013 %
0014 %   Author : Matti Hamalainen, MGH Martinos Center
0015 %   License : BSD 3-clause
0016 %
0017 %
0018 %   $Id: fiff_write_int_matrix.m 8776 2013-11-14 09:04:48Z roboos $
0019 
0020 %
0021 %
0022 
0023 me='MNE:fiff_write_int_matrix';
0024 
0025 if nargin ~= 3
0026    error(me,'Incorrect number of arguments');
0027 end
0028 
0029 if length(size(mat)) ~= 2
0030    error(me,'Input should be a two-dimensional matrix');
0031 end
0032 
0033 FIFFT_INT  = 3;
0034 FIFFT_MATRIX = bitshift(1,30);
0035 FIFFT_MATRIX_INT = bitor(FIFFT_INT,FIFFT_MATRIX);
0036 FIFFV_NEXT_SEQ=0;
0037 
0038 datasize = 4*numel(mat) + 4*3;
0039 
0040 count = fwrite(fid,int32(kind),'int32');
0041 if count ~= 1
0042     error(me,'write failed');
0043 end
0044 count = fwrite(fid,int32(FIFFT_MATRIX_INT),'int32');
0045 if count ~= 1
0046     error(me,'write failed');
0047 end
0048 count = fwrite(fid,int32(datasize),'int32');
0049 if count ~= 1
0050     error(me,'write failed');
0051 end
0052 count = fwrite(fid,int32(FIFFV_NEXT_SEQ),'int32');
0053 if count ~= 1
0054     error(me,'write failed');
0055 end
0056 count = fwrite(fid,int32(mat'),'int32');
0057 if count ~= numel(mat)
0058     error(me,'write failed');
0059 end
0060 dims(1) = size(mat,2);
0061 dims(2) = size(mat,1);
0062 dims(3) = 2;
0063 count = fwrite(fid,int32(dims),'int32');
0064 if count ~= 3
0065     error(me,'write failed');
0066 end
0067 
0068 return;
0069

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