Dear Neuromeg,
I have a data set in which one meg channel is missing and I would like
to find a way to enter this channel into the raw file and then have
maxfilter interpolate it as if it was a bad channel.
A colleague of mine (Dan Wakeman) wrote some code to try and do just
that. It seems to work when looking at the raw signal but when I try to
use maxfilter on the file it fails.
I'm attaching the code to add the flat channel, along with the various
maxfilter error messages and would appreciate any advice on where/how
things could be going wrong.
Thanks,
Marie
*******************************************************************************
function replace_missing(file)
rawfileout=[file 'new'];
info2=fiff_setup_read_raw('goodfile.fif');
info1=fiff_setup_read_raw(file);
data1=fiff_read_raw_segment(info1);
info1=fiff_setup_read_raw(file)
info1.info.nchan=info2.info.nchan;
info1.info.chs=info2.info.chs
info1.info.ch_names=info2.info.ch_names;
info1.info.acq_pars=info2.info.acq_pars;
info1.cals=info2.cals;
data2=zeros(size(data1) + [1 0]);
data2(1:267,:)=data1(1:267,:);
data2(269:end,:)=data1(268:end,:);
FIFF=fiff_define_constants;
[fid,cals] = fiff_start_writing_raw(rawfileout,info1.info);
for i=info1.first_samp:ceil(11*info1.info.sfreq):info1.last_samp
until=i+ceil(11*info1.info.sfreq)-1;
if until>info1.last_samp
until=info1.last_samp;
end
if i==info1.first_samp
fiff_write_int(fid,FIFF.FIFF_FIRST_SAMPLE,i);
end
fiff_write_raw_buffer(fid,data2(:,i-info1.first_samp+1:until-info1.first_samp),cals);
end
fiff_finish_writing_raw(fid)
*******************************************************************************
maxfilter -f fixedfile.fif -o outtest.fif -autobad off -bad 2343 -frame
head -origin 0 0 40 -ds 4 -v
--- Processing raw tag #b = 123/123 (#t = 260.878) ---
Static bad channels (1): 2343
Using direct pseudo-inverse...
INTERNAL ERROR: illegal processing limits!
Output file outtest.fif was not written (exit value = 8)!
maxfilter -f fixedfile.fif -o outtest.fif -autobad off -bad 2343 -st 10
-frame head -origin 0 0 40 -ds 4 -v
Scanning flat channels: #1/123[5D2/123[5D3/123[5D4/123[5D5/123[5D6/123[5D7/123[5D8/123[5D9/123[5D10/123[6D11/123[6D12/123[6D13/123[6D14/123[6D15/123[6D16/123[6D17/123[6D18/123[6D19/123[6D20/123[6D21/123[6D22/123[6D23/123[6D24/123[6D25/123[6D26/123[6D27/123[6D28/123[6D29/123[6D30/123[6D31/123[6D32/123[6D33/123[6D34/123[6D35/123[6D36/123[6D37/123[6D38/123[6D39/123[6D40/123[6D41/123[6D42/123[6D43/123[6D44/123[6D45/123[6D46/123[6D47/123[6D48/123[6D49/123[6D50/123[6D51/123[6D52/123[6D53/123[6D54/123[6D55/123[6D56/123[6D57/123[6D58/123[6D59/123[6D60/123[6D61/123[6D62/123[6D63/123[6D64/123[6D65/123[6D66/123[6D67/123[6D68/123[6D69/123[6D70/123[6D71/123[6D72/123[6D73/123[6D74/123[6D75/123[6D76/123[6D77/123[6D78/123[6D79/123[6D80/123[6D81/123[6D82/123[6D83/123[6D84/123[6D85/123[6D86/123[6D87/123[6D88/123[6D89/123[6D90/123[6D91/123[6D92/123[6D93/123[6D94/123[6D95/123[6D96/123[6D97/123[6D98/123[6D99/123[6D100/123[7D101/123[7D102/123[7D103/123[7D104/123[7D105/123[7D106/123[7D107/123[7D108/123[7D109/123[7D110/123[7D111/123[7D112/123[7D113/123[7D114/123[7D115/123[7D116/123[7D117/123[7D118/123[7D119/123[7D120/123[7D121/123[7D122/123[7D123/123Program
died due to signal 11.
Core dump disabled.
maxfilter -f fixedfile.fif -o outtest.fif -autobad off -bad 2343
-movecomp -frame head -origin 0 0 40 -ds 4 -v
--- Processing raw tag #b = 1/123 (#t = 17.000) ---
ERROR: illegal hpistep (200 samples)!
Output file outtest.fif was not written (exit value = 3)!
|