function export_sqd(source,destination,data,pre,smpr,scale) % adds channels to the data to equal 192 channels; cuts off data from % pre-stimulus interval (Meg160 will always interpret the data as starting at time = 0); % scales the data by the input 'scale,' (scaling by 1000 works well if the % data is a matrix of correlation coefficients); then makes a new sqd file from this data. pre = pre*smpr; d = 192 - length(data(1,:)); c = zeros(length(data(:,1)),d); newdata = [data, c]; newdata1 = zeros((length(data(:,1))-pre),192); for i=1:length(newdata1(:,1)) for j=1:length(newdata1(1,:)) newdata1(i,j) = newdata1(i,j) + newdata((i+pre),j); end end newdata1 = newdata1 .* scale; sqdwrite(source,destination,newdata1); end