Diff for "maxpreproc" - Meg Wiki
location: Diff for "maxpreproc"
Differences between revisions 15 and 16
Revision 15 as of 2008-11-11 14:46:59
Size: 5450
Editor: MarieSmith
Comment:
Revision 16 as of 2008-11-11 15:01:33
Size: 7109
Editor: MarieSmith
Comment:
Deletions are marked like this. Additions are marked like this.
Line 33: Line 33:
'''Step 3. Transforming to a different co-ordinate frame''' == Step 3. Transforming to a different co-ordinate frame ==
Unlike EEG data, the sensors of the MEG are not affixed to the head of the participant making averaging of blocks of data of one subject, or across all of your subjects more difficult. A solution to this is to make use of maxfilter option -trans to transform your data to either one specified raw fif file (e.g. the first data block for a subject) or to the default device co-ordinate scheme. Due to a maxfilter [http://imaging.mrc-cbu.cam.ac.uk/meg/maxbugs bug] it is not possible to perform trans at the same time as movement compensation, so you should perform it on an already SSS'd file.
Line 35: Line 36:
To transform to a single file (e.g. if your experiment has 5 blocks, you would transform all to the third block).

 * '''[Trans file]''' maxfilter -f <output_file_from_step2> -o <new_output_file> -ctc /neuro/databases/ctc/ct_sparse.fif -cal /neuro/databases/sss/sss_cal.dat -autobad off -trans <chosen_fif_file> -force -v | tee <trans_log_file>
To transform to the default position (e.g. if you want to compare across subjects). NB Due to another [javascript:void(0);/*1226415444948*/ bug] you must specifiy the frame and origin in this call. The origin can be that given by maxfilter in Step2, the default values (0,0,40), or that established by any other program. It has been observed that applying a small correction to the sphere origin results in less artefacts being introduced into the data.

 * '''[Trans default]''' maxfilter -f <output_file_from_step2> -o <new_output_file> -ctc /neuro/databases/ctc/ct_sparse.fif -cal /neuro/databases/sss/sss_cal.dat -autobad off -trans default -frame head -origin <x> <y> <z> -force -v | tee <trans_log_file>

Guideline for MEG Pre-processing

Typically pre-processing with MaxFilter requires three steps:

  1. finding bad channels,
  2. applying sss to remove noise,
  3. transforming the data to a different co-ordinate frame.

Each step is detailed below along with code that you can use. NB you need to input your file names in the appropriate places. For full details of maxfilter and the options used below please see the Maxfilter manual.

Step 1. Identifying Bad Channels with Maxfilter

In the first step, we call maxfilter to establish which channels in the data set are bad by using the -autobad option. Maxfilter scans the first 20 seconds of your recording (or however long you waited before turing on cHPI) and returns the output to a log file. To save time we tell maxfilter to skip the remainder of the file. The -ctc and -cal options refer to the fine calibration and cross talk correction data specific to our MEG system. Inputting them to maxfilter will produce a better result.

  • maxfilter -f <rawdata_file> -o <output_file> -ctc /neuro/databases/ctc/ct_sparse.fif -cal /neuro/databases/sss/sss_cal.dat -autobad 20 -skip 21 999999 -v | tee <log_file>

Step 2. Applying Signal Space Separation

In this second call to maxfilter there are a number of different things that you can do. Just pick and choose from the following commands to do what you want with your data. All of the following options can be put in one call to maxfilter, and it doesn't matter which order you type them in.

The most simple call would be to run only spatial SSS correction with your specified list of bad channels as:

  • [SSS] maxfilter -f <rawdata_file> -o <output_file> -ctc /neuro/databases/ctc/ct_sparse.fif -cal /neuro/databases/sss/sss_cal.dat -autobad off -bad <list of bad channels> -v | tee <log_file>

NB. Due to a [:maxbugs:bug ]in maxfilter you must not run autobad and anything else together! Sometimes there are artifacts left in the data after running SSS, e.g. sensor jumps, which can be dealt with by using the temporal extension (-st) to maxfilter. To use this option you are required to specify a temporal buffer over which it will work. The default buffer is 4 seconds which corresponds to a high pass filter of 0.25Hz. If you are keen to keep lower frequencies then you can set the buffer time to be longer (e.g 10secs - 0.1Hz), at the cost of processing time.

  • [SSS, -ST] maxfilter -f <rawdata_file> -o <output_file> -ctc /neuro/databases/ctc/ct_sparse.fif -cal /neuro/databases/sss/sss_cal.dat -autobad off -bad <list of bad channels> -st 10 -v | tee <log_file>

The reason for using cHPI (continuous head position tracking) during recordings is so that we can monitor / correct for movements of the head of our participants within a recording session. To monitor headmovements and output them to a file we use the -headpos option. To correct for movements we use the -movecomp option. With both options we specify the log file which will store the head position parameters (to be visually inspected later) and set the estimation interval (normally 200ms but 500 and 1000ms also available). You can also choose to have maxfilter subtract out the cHPI signals (very high frequencies) from your data by using the -hpisubt option (either amp or off).

  • [SSS, -ST, -movecomp] maxfilter -f <rawdata_file> -o <output_file> -ctc /neuro/databases/ctc/ct_sparse.fif -cal /neuro/databases/sss/sss_cal.dat -autobad off -bad <list of bad channels> -st 10 -movecomp -hpistep 200 -hp <head_pos_log_file> -hpisubt amp -v | tee <log_file>

During head movemement compensation or estimation, maxfilter continually acceses the cHPI data. If HPI failed at some point during your run, head movement compensation/estimation will fail and the resulting data block will be skipped (i.e. set to zero). To force maxfilter to use the last known HPI position you can use the -movecomp inter option. But be careful if this happens early on in your file as you will not really be performing movement correction anymore.

  • [SSS, -ST, -movecomp inter] maxfilter -f <rawdata_file> -o <output_file> -ctc /neuro/databases/ctc/ct_sparse.fif -cal /neuro/databases/sss/sss_cal.dat -autobad off -bad <list of bad channels> -st 10 -movecomp inter -hpistep 200 -hp <head_pos_log_file> -hpisubt amp -v | tee <log_file>

Choice of Origin

The outcome of Maxfilter depends on the coordinate system origin being used. By default maxfilter will determine this origin for you by fitting a sphere to your digitized points. However you may run into problems with this. The most common ones being that the "sphere fit extends outside of the sensors" or that the origin is found to be 0,0,0 (as a result of a bug in maxfilter - see [:max000:here] for more details). Both errors can be fixed in the same way: by manually specifiying the origin that you want to use. This origin can either be a default setting (x=0,y=0,z=40mm), or can be established by other sphere fitting tools (see an [:max000:example of this in matlab]).

  • [SSS, -ST, -movecomp, origin] maxfilter -f <rawdata_file> -o <output_file> -ctc /neuro/databases/ctc/ct_sparse.fif -cal /neuro/databases/sss/sss_cal.dat -autobad off -bad <list of bad channels> -st 10 -movecomp -hpistep 200 -hp <head_pos_log_file> -hpisubt amp -frame head -origin <x> <y> <z> -v | tee <log_file>

Step 3. Transforming to a different co-ordinate frame

Unlike EEG data, the sensors of the MEG are not affixed to the head of the participant making averaging of blocks of data of one subject, or across all of your subjects more difficult. A solution to this is to make use of maxfilter option -trans to transform your data to either one specified raw fif file (e.g. the first data block for a subject) or to the default device co-ordinate scheme. Due to a maxfilter [http://imaging.mrc-cbu.cam.ac.uk/meg/maxbugs bug] it is not possible to perform trans at the same time as movement compensation, so you should perform it on an already SSS'd file.

To transform to a single file (e.g. if your experiment has 5 blocks, you would transform all to the third block).

  • [Trans file] maxfilter -f <output_file_from_step2> -o <new_output_file> -ctc /neuro/databases/ctc/ct_sparse.fif -cal /neuro/databases/sss/sss_cal.dat -autobad off -trans <chosen_fif_file> -force -v | tee <trans_log_file>

To transform to the default position (e.g. if you want to compare across subjects). NB Due to another [javascript:void(0);/*1226415444948*/ bug] you must specifiy the frame and origin in this call. The origin can be that given by maxfilter in Step2, the default values (0,0,40), or that established by any other program. It has been observed that applying a small correction to the sphere origin results in less artefacts being introduced into the data.

  • [Trans default] maxfilter -f <output_file_from_step2> -o <new_output_file> -ctc /neuro/databases/ctc/ct_sparse.fif -cal /neuro/databases/sss/sss_cal.dat -autobad off -trans default -frame head -origin <x> <y> <z> -force -v | tee <trans_log_file>

CbuMeg: maxpreproc (last edited 2024-02-22 12:12:36 by RikHenson)