%%Reading Epoch MEG data %%Ellen Lau November 2006 %%This function takes an exported MEG epoch filename as input and outputs both %%an array of time x channels x epochs, as well as a mean time x channels %%file %%[epocharray,meanarray] = epRead(epdataname,samplingfreq,eplength,baselinelength) %%length should be specified in data points, not in time (e.g. if your %%sampling freq is 500 Hz and you have a 100 ms baseline, baselinelength = %%50) %% First need to export 156 channels of meg epoch file to a 32-bit bin %% file (don't forget to select channels). then you can read it in using %% huan luo's readingMEGfile.m function varargout = epReadFT(epdataname,hdr) %[data_new,channelnum,datapoints] = readingMEGfile192(epdataname,[]); [data_new,channelnum,datapoints] = readingMEGfile(epdataname,[]); %%this gives you channel x total time array [m,n] = size(data_new); eplength = hdr.nSamples; %%find # of epochs numep = hdr.nTrials; clear dataEp; %%read into 3-dimensional variable with epochs as the third dimension for x=[1:numep] x; beg = (x-1) * eplength + 1; en = (x-1) * eplength + eplength; dataEp(:,:,x) = data_new(:,beg:en)'; end varargout{1} = dataEp;