osl_ephys.maxfilter#

Submodules#

Attributes#

parser

osl_logger

__doc__

Functions#

validate_outdir(outdir)

Checks if an output directory exists and if not creates it.

add_subdir(file, outdir[, run_id])

Add sub-directory.

process_file_inputs(inputs)

Process inputs for several cases

_add_headpos(cmd, args, outfif)

Estimates and stores head position parameters but does not transform data

_add_movecomp(cmd, args)

Estimates head movements and transforms data.

_add_movecompinter(cmd, args)

Estimates head movements and transforms data with intermittent HPI

_add_hpie(cmd, args)

sets the error limit for hpi coil fitting (def 5 mm)

_add_hpig(cmd, args)

sets the g-value limit for hpi coil fitting (def 0.98)

_add_hpisubt(cmd, args)

subtracts hpi signals: chpi sine amplitudes, amp + linefreq harmonics,

_add_autobad(cmd, args)

sets automated bad channel detection on: scan the whole raw data file, off: no autobad

_add_autobad_dur(cmd, args)

sets automated bad channel detection on with specified duration.

_add_badlimit(cmd, args)

Threshold for bad channel detection (>ave+X*SD)

_add_bad(cmd, args)

sets the list of static bad channels (logical chnos, e.g.: 0323 1042 2631)

_add_linefreq(cmd, args)

sets the basic line interference frequency (50/60Hz)

_add_tsss(cmd, args)

Add all tsss related args

_add_trans(cmd, args)

transforms the data into head position in <fiff_file>

_add_force(cmd, args)

Ignore program warnings....

_add_inorder(cmd, args)

sets the order of the inside expansion

_add_outorder(cmd, args)

sets the order of the outside expansion

_add_ctc(cmd, args)

uses the cross-talk matrix in <ctcfile>

_add_cal(cmd, args)

uses the fine-calibration in <calfile>

_add_origin(cmd, args)

set a custom sphere origin.

_add_frame(cmd, args)

set origin frame.

_add_scanner(cmd, args)

quick_load_dig(fname)

fit_cbu_origin(infif[, outbase, remove_nose])

run_maxfilter(infif, outfif, args[, logfile_tag])

Wrapper for Elekta Maxfilter.

run_multistage_maxfilter(infif, outbase, args)

Wrapper for running run_maxfilter in three sequential steps:

run_cbu_3stage_maxfilter(infif, outbase, args)

Wrapper for running run_maxfilter in three

run_maxfilter_batch(files, outdir[, args])

Batch Maxfiltering.

main([argv])

Package Contents#

osl_ephys.maxfilter.validate_outdir(outdir)[source]#

Checks if an output directory exists and if not creates it.

osl_ephys.maxfilter.add_subdir(file, outdir, run_id=None)[source]#

Add sub-directory.

osl_ephys.maxfilter.process_file_inputs(inputs)[source]#

Process inputs for several cases

The argument, inputs, can be… 1) string path to unicode file 2) string path to dir (e.g. if CTF .ds dir) 3) string path to file or regular-expression matching files 4) list of string paths to files 5) list of string paths to dirs (e.g. if CTF .ds dirs) 6) list of tuples with path to file and output name pairs 7) list of MNE objects

osl_ephys.maxfilter.parser[source]#
osl_ephys.maxfilter._add_headpos(cmd, args, outfif)[source]#

Estimates and stores head position parameters but does not transform data

osl_ephys.maxfilter._add_movecomp(cmd, args)[source]#

Estimates head movements and transforms data.

Data are transformed to reference head position in continuous raw data

osl_ephys.maxfilter._add_movecompinter(cmd, args)[source]#

Estimates head movements and transforms data with intermittent HPI

Data are transformed to reference head position in continuous raw data

osl_ephys.maxfilter._add_hpie(cmd, args)[source]#

sets the error limit for hpi coil fitting (def 5 mm)

osl_ephys.maxfilter._add_hpig(cmd, args)[source]#

sets the g-value limit for hpi coil fitting (def 0.98)

osl_ephys.maxfilter._add_hpisubt(cmd, args)[source]#

subtracts hpi signals: chpi sine amplitudes, amp + linefreq harmonics, or switch off (def = amp)

osl_ephys.maxfilter._add_autobad(cmd, args)[source]#

sets automated bad channel detection on: scan the whole raw data file, off: no autobad

osl_ephys.maxfilter._add_autobad_dur(cmd, args)[source]#

sets automated bad channel detection on with specified duration.

osl_ephys.maxfilter._add_badlimit(cmd, args)[source]#

Threshold for bad channel detection (>ave+X*SD)

osl_ephys.maxfilter._add_bad(cmd, args)[source]#

sets the list of static bad channels (logical chnos, e.g.: 0323 1042 2631)

osl_ephys.maxfilter._add_linefreq(cmd, args)[source]#

sets the basic line interference frequency (50/60Hz)

osl_ephys.maxfilter._add_tsss(cmd, args)[source]#

Add all tsss related args

osl_ephys.maxfilter._add_trans(cmd, args)[source]#

transforms the data into head position in <fiff_file>

osl_ephys.maxfilter._add_force(cmd, args)[source]#

Ignore program warnings….

osl_ephys.maxfilter._add_inorder(cmd, args)[source]#

sets the order of the inside expansion

osl_ephys.maxfilter._add_outorder(cmd, args)[source]#

sets the order of the outside expansion

osl_ephys.maxfilter._add_ctc(cmd, args)[source]#

uses the cross-talk matrix in <ctcfile>

osl_ephys.maxfilter._add_cal(cmd, args)[source]#

uses the fine-calibration in <calfile>

osl_ephys.maxfilter._add_origin(cmd, args)[source]#

set a custom sphere origin.

osl_ephys.maxfilter._add_frame(cmd, args)[source]#

set origin frame.

osl_ephys.maxfilter._add_scanner(cmd, args)[source]#
osl_ephys.maxfilter.quick_load_dig(fname)[source]#
osl_ephys.maxfilter.fit_cbu_origin(infif, outbase=None, remove_nose=True)[source]#
osl_ephys.maxfilter.run_maxfilter(infif, outfif, args, logfile_tag='')[source]#

Wrapper for Elekta Maxfilter.

Parameters:
  • infif (str) – Path to input fif file (raw data).

  • outfif (str) – Path to output fif file (maxfiltered).

  • args (dict) – Dictionary of arguments to pass to maxfilter. See help(osl_ephys.maxfilter) for all options, and Notes for recommendations.

  • logfile_tag (str, optional) – Tag to append to logfile name. The default is ‘’. This is used to differentiate between different stages of maxfiltering (e.g., '_trans', '_tsss').

Returns:

  • outfif (str) – Path to output fif file (maxfiltered).

  • stdlog (str) – Path to logfile.

Notes

The recommended use for maxfilter at OHBA is to run multistage maxfiltering, with the following options: args = {'maxpath': '/neuro/bin/util/maxfilter', 'scanner': 'Neo', 'mode': 'multistage', 'tsss': {}, 'headpos': {}, 'movecomp': {}}

osl_ephys.maxfilter.run_multistage_maxfilter(infif, outbase, args)[source]#

Wrapper for running run_maxfilter in three sequential steps:

  1. Find Bad Channels

  2. Signal Space Separation

  3. Translate to reference file

Parameters:
  • infif (str) – Path to input fif file (raw data).

  • outbase (str) – output directory.

  • args (dict) – Dictionary of arguments to pass to maxfilter. See help(osl_ephys.maxfilter) for all options.

Notes

All files are written to disk and the output of each stage is used as the input to the next.

General advice (from CBU):

  • don’t use 'trans' with 'movecomp'

  • don’t use 'autobad' with 'headpos' or 'movecomp'

  • don’t use 'autobad' with 'st'

References

https://imaging.mrc-cbu.cam.ac.uk/meg/Maxfilter https://imaging.mrc-cbu.cam.ac.uk/meg/maxbugs

osl_ephys.maxfilter.run_cbu_3stage_maxfilter(infif, outbase, args)[source]#

Wrapper for running run_maxfilter in three sequential steps used by MRC Cognition and Brain Sciences Unit (CBU) in Cambridge:

  1. Fit Origin without nose

  2. Find Bad Channels

  3. Signal Space Separation

  4. Translate to default

Parameters:
  • infif (str) – Path to input fif file (raw data).

  • outbase (str) – output directory.

  • args (dict) – Dictionary of arguments to pass to maxfilter. See help(osl_ephys.maxfilter) for all options.

Notes

All files are written to disk and the output of each stage is used as the input to the next.

References

https://imaging.mrc-cbu.cam.ac.uk/meg/Maxfilter https://imaging.mrc-cbu.cam.ac.uk/meg/maxbugs

osl_ephys.maxfilter.run_maxfilter_batch(files, outdir, args=None)[source]#

Batch Maxfiltering.

Parameters:
  • files (str or list of str) – Path(s) to raw fif files to maxfilter.

  • outdir (str) – Path to directory to save output to.

  • args (str) – List of additional optional arguments to pass to osl_maxfilter. See help(osl_ephys.maxfilter) for all options. If a string is passed it it split input a list (delimited by spaces). E.g. args="--maxpath /neuro/bin/util/maxfilter" is equivalent to args=["--maxpath", "/neuro/bin/util/maxfilter"].

Notes

Example use:

>>> run_maxfilter_batch(files="/path/to/fif", outdir="/path/to/outdir",
    args="--maxpath /neuro/bin/util/maxfilter --scanner Neo --tsss --mode
    multistage --headpos --movecomp")
osl_ephys.maxfilter.main(argv=None)[source]#
osl_ephys.maxfilter.osl_logger = None[source]#
osl_ephys.maxfilter.__doc__[source]#