max000 - Meg Wiki
CbuMeg: max000

MaxFilter 0,0,0 origin problem and solution

Neuromag have discovered a bug in the current release of maxfilter which could impact on anyone who recorded MEG data at the CBU in early 2008. The problem occurs for sessions in which the positions of the HPI coils were re-digitised as extra points to check their location as part of the MEG prep. This seems to have been common practice in late Feb, March, April, and early May, but has since been re-placed with the check HPI option.

The bug is such that maxfilter will set the sphere origin to 0,0,0 instead of the more normal 0,0,40 during SSS which results in much more noisy data coming out. NB maxfilter will not crash and no error will be given, you have to check the log files to spot this. The solution at present is to manually input your own sphere origin during the call to max filter. An example of how to do this, using fit sphere to points, and calling it from within Matlab is given below. If you are not in a rush the new release of maxfilter (MaxFilter 2.1) will contain a fix. From looking at data with and without the fix applied it is strongly recommended that you re-analyse your data if your files do encounter this bug.

addpath /neuro/meg_pd_1.2/        % where 'hpipoints' lives; could add to your
                                  % /home/<user>/matlab/startup.m

infile = 'myrawdata.fif';         % your raw .fif filename (with .fif)
headpfname = 'myheadpoints.txt';  % filename to contain headpoints
logfile = 'mylogfile.fif';        % filename to contain MaxFilter log

[co ki]=hpipoints(infile);        % infile is your raw .fif filename (with .fif)
tmppoints=co(:,ki>1)';                                % exclude fiducial points
nloc = find(~(tmppoints(:,3)<0 & tmppoints(:,2)>0));  % Remove any nose points 
headpoints = tmppoints(nloc,:);                   
save(headpfname,'-ASCII','headpoints')
cmd_fit=['/neuro/bin/util/fit_sphere_to_points ' headpfname];
[status spherefit]=unix(cmd_fit);
if length(spherefit)<1;
    error('Spherefit failed!')
end
fit=str2num(spherefit)*1000; % m to mm;

%% Finally the call to max filter. The key part is the inclusion of -origin tag and the fit values

eval(sprintf('!/neuro/bin/util/maxfilter -f %s -o %s -ctc /neuro/databases/ctc/ct_sparse.fif -cal /neuro/databases/sss/sss_cal.dat -autobad off -frame head -origin %g %g %g -v | tee %s', infile, outfile, fit(1), fit(2), fit(3), logfile)) . 

CbuMeg: max000 (last edited 2013-03-08 10:02:30 by localhost)