0001 function fiff_write_ch_info(fid,ch)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037
0038
0039
0040 me='MNE:fiff_write_ch_info';
0041
0042 if nargin ~= 2
0043 error(me,'Incorrect number of arguments');
0044 end
0045
0046 FIFF_CH_INFO=203;
0047 FIFFT_CH_INFO_STRUCT=30;
0048 FIFFV_NEXT_SEQ=0;
0049
0050
0051
0052
0053
0054
0055
0056
0057
0058
0059
0060
0061
0062
0063
0064
0065
0066
0067
0068
0069
0070
0071 datasize=4*13 + 4*7 + 16;
0072 count = fwrite(fid,int32(FIFF_CH_INFO),'int32');
0073 if count ~= 1
0074 error(me,'write failed');
0075 end
0076 count = fwrite(fid,int32(FIFFT_CH_INFO_STRUCT),'int32');
0077 if count ~= 1
0078 error(me,'write failed');
0079 end
0080 count = fwrite(fid,int32(datasize),'int32');
0081 if count ~= 1
0082 error(me,'write failed');
0083 end
0084 count = fwrite(fid,int32(FIFFV_NEXT_SEQ),'int32');
0085 if count ~= 1
0086 error(me,'write failed');
0087 end
0088
0089
0090
0091 count = fwrite(fid,int32(ch.scanno),'int32');
0092 if count ~= 1
0093 error(me,'write failed');
0094 end
0095 count = fwrite(fid,int32(ch.logno),'int32');
0096 if count ~= 1
0097 error(me,'write failed');
0098 end
0099 count = fwrite(fid,int32(ch.kind),'int32');
0100 if count ~= 1
0101 error(me,'write failed');
0102 end
0103 count = fwrite(fid,single(ch.range),'single');
0104 if count ~= 1
0105 error(me,'write failed');
0106 end
0107 count = fwrite(fid,single(ch.cal),'single');
0108 if count ~= 1
0109 error(me,'write failed');
0110 end
0111
0112
0113
0114 count = fwrite(fid,int32(ch.coil_type),'int32');
0115 if count ~= 1
0116 error(me,'write failed');
0117 end
0118 count = fwrite(fid,single(ch.loc),'single');
0119 if count ~= 12
0120 error(me,'write failed');
0121 end
0122
0123
0124
0125 count = fwrite(fid,int32(ch.unit),'int32');
0126 if count ~= 1
0127 error(me,'write failed');
0128 end
0129 count = fwrite(fid,int32(ch.unit_mul),'int32');
0130 if count ~= 1
0131 error(me,'write failed');
0132 end
0133
0134
0135
0136 len=length(ch.ch_name);
0137 if len > 15
0138 ch_name = ch.ch_name(1:15);
0139 else
0140 ch_name = ch.ch_name;
0141 end
0142 len = length(ch_name);
0143 count = fwrite(fid,ch_name,'char');
0144 if count ~= len
0145 error(me,'write failed');
0146 end
0147 if len < 16
0148 dum=zeros(1,16-len);
0149 count = fwrite(fid,uint8(dum),'uchar');
0150 if count ~= 16-len
0151 error(me,'write failed');
0152 end
0153 end
0154 return;