Command line tools using Python

mne browse_raw

Usage: mne browse_raw [options]

Browse raw data.

Options:
--version show program’s version number and exit
-h, --help show this help message and exit
--raw=FILE Input raw FIF file
--proj=FILE Projector file
--eve=FILE Events file
-d DURATION, --duration=DURATION
 Time window for plotting (sec)
-t START, --start=START
 Initial start time for plotting
-n N_CHANNELS, --n_channels=N_CHANNELS
 Number of channels to plot at a time
-o ORDER, --order=ORDER
 Order for plotting (‘type’ or ‘original’)
-p PRELOAD, --preload=PRELOAD
 Preload raw data (for faster navigaton)
-s SHOW_OPTIONS, --show_options=SHOW_OPTIONS
 Show projection options dialog
--allowmaxshield
 Allow loading MaxShield processed data
--highpass=HIGHPASS
 Display high-pass filter corner frequency
--lowpass=LOWPASS
 Display low-pass filter corner frequency
--filtorder=FILTORDER
 Display filtering IIR order
--clipping=CLIPPING
 Enable trace clipping mode, either ‘clip’ or ‘transparent’
--filterchpi=FILTERCHPI
 Enable filtering cHPI signals.

You can do for example:

$ mne browse_raw –raw sample_audvis_raw.fif
–proj sample_audvis_ecg-proj.fif –eve sample_audvis_raw-eve.fif

mne bti2fiff

Usage: mne bti2fiff [options]

Import BTi / 4D MagnesWH3600 data to fif file.

Options:
--version show program’s version number and exit
-h, --help show this help message and exit
-p FILE, --pdf=FILE
 Input data file name
-c FILE, --config=FILE
 Input config file name
--head_shape=FILE
 Headshape file name
-o OUT_FNAME, --out_fname=OUT_FNAME
 Name of the resulting fiff file
-r ROTATION_X, --rotation_x=ROTATION_X
 Compensatory rotation about Neuromag x axis, deg
-T TRANSLATION, --translation=TRANSLATION
 Default translation, meter
--ecg_ch=ECG_CH
 4D ECG channel name
--eog_ch=EOG_CH
 4D EOG channel names

example usage: mne bti2fiff –pdf C,rfDC -o my_raw.fif

Note. 1) Currently direct inclusion of reference channel weights is not supported. Please use ‘mne_create_comp_data’ to include the weights or use the low level functions from this module to include them by yourself. 2) The informed guess for the 4D name is E31 for the ECG channel and E63, E63 for the EOG channels. Pleas check and adjust if those channels are present in your dataset but ‘ECG 01’ and ‘EOG 01’, ‘EOG 02’ don’t appear in the channel names of the raw object.

mne clean_eog_ecg

Usage: mne clean_eog_ecg [options]

Clean a raw file from EOG and ECG artifacts with PCA (ie SSP).

Options:
--version show program’s version number and exit
-h, --help show this help message and exit
-i FILE, --in=FILE
 Input raw FIF file
-o FILE, --out=FILE
 Output raw FIF file
-e, --no-eog Remove EOG
-c, --no-ecg Remove ECG
-q, --quiet Suppress mne_process_raw output

You can do for example:

$ mne clean_eog_ecg -i in_raw.fif -o clean_raw.fif -e -c

mne compare_fiff

Usage: mne compare_fiff <file_a> <file_b>

Compare FIFF files.

Options:
--version show program’s version number and exit
-h, --help show this help message and exit

You can do for example:

$ mne compare_fiff test_raw.fif test_raw_sss.fif

mne compute_proj_ecg

Usage: mne compute_proj_ecg [options]

Compute SSP/PCA projections for ECG artifacts.

Options:
--version show program’s version number and exit
-h, --help show this help message and exit
-i FILE, --in=FILE
 Input raw FIF file
--tmin=TMIN Time before event in seconds
--tmax=TMAX Time after event in seconds
-g N_GRAD, --n-grad=N_GRAD
 Number of SSP vectors for gradiometers
-m N_MAG, --n-mag=N_MAG
 Number of SSP vectors for magnetometers
-e N_EEG, --n-eeg=N_EEG
 Number of SSP vectors for EEG
--l-freq=L_FREQ
 Filter low cut-off frequency in Hz
--h-freq=H_FREQ
 Filter high cut-off frequency in Hz
--ecg-l-freq=ECG_L_FREQ
 Filter low cut-off frequency in Hz used for ECG event detection
--ecg-h-freq=ECG_H_FREQ
 Filter high cut-off frequency in Hz used for ECG event detection
-p PRELOAD, --preload=PRELOAD
 Temporary file used during computation (to save memory)
-a, --average Compute SSP after averaging
--proj=PROJ Use SSP projections from a fif file.
--filtersize=FILTER_LENGTH
 Number of taps to use for filtering
-j N_JOBS, --n-jobs=N_JOBS
 Number of jobs to run in parallel
-c CH_NAME, --channel=CH_NAME
 Channel to use for ECG detection (Required if no ECG found)
--rej-grad=REJ_GRAD
 Gradiometers rejection parameter in fT/cm (peak to peak amplitude)
--rej-mag=REJ_MAG
 Magnetometers rejection parameter in fT (peak to peak amplitude)
--rej-eeg=REJ_EEG
 EEG rejection parameter in uV (peak to peak amplitude)
--rej-eog=REJ_EOG
 EOG rejection parameter in uV (peak to peak amplitude)
--avg-ref Add EEG average reference proj
--no-proj Exclude the SSP projectors currently in the fiff file
--bad=BAD_FNAME
 Text file containing bad channels list (one per line)
--event-id=EVENT_ID
 ID to use for events
--event-raw=RAW_EVENT_FNAME
 raw file to use for event detection
--tstart=TSTART
 Start artifact detection after tstart seconds
--qrsthr=QRS_THRESHOLD
 QRS detection threshold. Between 0 and 1. Can also be ‘auto’ for automatic selection

You can do for example:

$ mne compute_proj_ecg -i sample_audvis_raw.fif -c “MEG 1531”
–l-freq 1 –h-freq 100 –rej-grad 3000 –rej-mag 4000 –rej-eeg 100

mne compute_proj_eog

Usage: mne compute_proj_eog [options]

Compute SSP/PCA projections for EOG artifacts.

Options:
--version show program’s version number and exit
-h, --help show this help message and exit
-i FILE, --in=FILE
 Input raw FIF file
--tmin=TMIN Time before event in seconds
--tmax=TMAX Time after event in seconds
-g N_GRAD, --n-grad=N_GRAD
 Number of SSP vectors for gradiometers
-m N_MAG, --n-mag=N_MAG
 Number of SSP vectors for magnetometers
-e N_EEG, --n-eeg=N_EEG
 Number of SSP vectors for EEG
--l-freq=L_FREQ
 Filter low cut-off frequency in Hz
--h-freq=H_FREQ
 Filter high cut-off frequency in Hz
--eog-l-freq=EOG_L_FREQ
 Filter low cut-off frequency in Hz used for EOG event detection
--eog-h-freq=EOG_H_FREQ
 Filter high cut-off frequency in Hz used for EOG event detection
-p PRELOAD, --preload=PRELOAD
 Temporary file used during computation (to save memory)
-a, --average Compute SSP after averaging
--proj=PROJ Use SSP projections from a fif file.
--filtersize=FILTER_LENGTH
 Number of taps to use for filtering
-j N_JOBS, --n-jobs=N_JOBS
 Number of jobs to run in parallel
--rej-grad=REJ_GRAD
 Gradiometers rejection parameter in fT/cm (peak to peak amplitude)
--rej-mag=REJ_MAG
 Magnetometers rejection parameter in fT (peak to peak amplitude)
--rej-eeg=REJ_EEG
 EEG rejection parameter in uV (peak to peak amplitude)
--rej-eog=REJ_EOG
 EOG rejection parameter in uV (peak to peak amplitude)
--avg-ref Add EEG average reference proj
--no-proj Exclude the SSP projectors currently in the fiff file
--bad=BAD_FNAME
 Text file containing bad channels list (one per line)
--event-id=EVENT_ID
 ID to use for events
--event-raw=RAW_EVENT_FNAME
 raw file to use for event detection
--tstart=TSTART
 Start artifact detection after tstart seconds
-c CH_NAME, --channel=CH_NAME
 Custom EOG channel(s), comma separated

You can do for example:

$ mne compute_proj_eog -i sample_audvis_raw.fif
–l-freq 1 –h-freq 35 –rej-grad 3000 –rej-mag 4000 –rej-eeg 100

or

$ mne compute_proj_eog -i sample_audvis_raw.fif
–l-freq 1 –h-freq 35 –rej-grad 3000 –rej-mag 4000 –rej-eeg 100 –proj sample_audvis_ecg-proj.fif

to exclude ECG artifacts from projection computation.

mne coreg

Usage: mne coreg [options]

Open the coregistration GUI.

Options:
--version show program’s version number and exit
-h, --help show this help message and exit
-d SUBJECTS_DIR, --subjects-dir=SUBJECTS_DIR
 Subjects directory
-s SUBJECT, --subject=SUBJECT
 Subject name
-f INST, --fiff=INST
 FIFF file with digitizer data for coregistration
-t, --tabbed Option for small screens: Combine the data source panel and the coregistration panel into a single panel with tabs.
--no-guess-mri Prevent the GUI from automatically guessing and changing the MRI subject when a new head shape source file is selected.
--head-opacity=HEAD_OPACITY
 The opacity of the head surface, in the range [0, 1].
--high-res-head
 Use a high-resolution head surface.
--low-res-head Use a low-resolution head surface.
--trans=TRANS Head<->MRI transform FIF file (“-trans.fif”)
--verbose Turn on verbose mode.

example usage: $ mne coreg

mne flash_bem

Usage: mne flash_bem [options]

Create 3-layer BEM model from Flash MRI images.

Options:
--version show program’s version number and exit
-h, --help show this help message and exit
-s SUBJECT, --subject=SUBJECT
 Subject name
-d SUBJECTS_DIR, --subjects-dir=SUBJECTS_DIR
 Subjects directory
-3, --noflash30
 Skip the 30-degree flip angle data
-n, --noconvert
 Assume that the Flash MRI images have already been converted to mgz files
-u, --unwarp Run grad_unwarp with -unwarp <type> option on each of the converted data sets
-o, --overwrite
 Write over existing .surf files in bem folder
-v, --view Show BEM model in 3D for visual inspection

This program assumes that FreeSurfer and MNE are installed and sourced properly.

This function extracts the BEM surfaces (outer skull, inner skull, and outer skin) from multiecho FLASH MRI data with spin angles of 5 and 30 degrees. The multiecho FLASH data are inputted in DICOM format. This function assumes that the Freesurfer segmentation of the subject has been completed. In particular, the T1.mgz and brain.mgz MRI volumes should be, as usual, in the subject’s mri directory.

Before running this script do the following: (unless the –noconvert option is specified)

  1. Copy all of your FLASH images in a single directory <source> and create a directory <dest> to hold the output of mne_organize_dicom
  2. cd to <dest> and run $ mne_organize_dicom <source> to create an appropriate directory structure
  3. Create symbolic links to make flash05 and flash30 point to the appropriate series: $ ln -s <FLASH 5 series dir> flash05 $ ln -s <FLASH 30 series dir> flash30 Some partition formats (e.g. FAT32) do not support symbolic links. In this case, copy the file to the appropriate series: $ cp <FLASH 5 series dir> flash05 $ cp <FLASH 30 series dir> flash30
  4. cd to the directory where flash05 and flash30 links are
  5. Set SUBJECTS_DIR and SUBJECT environment variables appropriately
  6. Run this script

Example usage:

$ mne flash_bem –subject sample

mne freeview_bem_surfaces

Usage: mne freeview_bem_surfaces [options]

View the 3-Layers BEM model using Freeview.

Options:
--version show program’s version number and exit
-h, --help show this help message and exit
-s SUBJECT, --subject=SUBJECT
 Subject name
-d SUBJECTS_DIR, --subjects-dir=SUBJECTS_DIR
 Subjects directory
-m METHOD, --method=METHOD
 Method used to generate the BEM model. Can be flash or watershed.

You can do for example:

$ mne freeview_bem_surfaces -s sample

mne kit2fiff

Usage: mne kit2fiff [options]

Import KIT / NYU data to fif file.

Options:
--version show program’s version number and exit
-h, --help show this help message and exit
--input=filename
 Input data file name
--mrk=filename MEG Marker file name
--elp=filename Headshape points file name
--hsp=filename Headshape file name
--stim=chs Colon Separated Stimulus Trigger Channels
--slope=slope Slope direction
--stimthresh=value
 Threshold value for trigger channels
--output=filename
 Name of the resulting fiff file
--debug Set logging level for terminal output to debug

example usage: $ mne kit2fiff –input input.sqd –output output.fif Use without arguments to invoke GUI: $ mne kt2fiff

mne make_scalp_surfaces

Usage: mne make_scalp_surfaces [options]

Create high-resolution head surfaces for coordinate alignment.

Options:
--version show program’s version number and exit
-h, --help show this help message and exit
-o, --overwrite
 Overwrite previously computed surface
-s SUBJECT, --subject=SUBJECT
 The name of the subject
-f, --force Force transformation of surface into bem.
-v, --verbose Print the debug messages.
-d SUBJECTS_DIR, --subjects-dir=SUBJECTS_DIR
 Subjects directory
-n, --no-decimate
 Disable medium and sparse decimations (dense only)

example usage: mne make_scalp_surfaces –overwrite –subject sample

mne maxfilter

Usage: mne maxfilter [options]

Apply MaxFilter.

Options:
--version show program’s version number and exit
-h, --help show this help message and exit
-i FILE, --in=FILE
 Input raw FIF file
-o FILE Output FIF file (if not set, suffix ‘_sss’ will be used)
--origin=ORIGIN
 Head origin in mm, or a filename to read the origin from. If not set it will be estimated from headshape points
--origin-out=ORIGIN_OUT
 Filename to use for computed origin
--frame=FRAME Coordinate frame for head center (‘device’ or ‘head’)
--bad=BAD List of static bad channels
--autobad=AUTOBAD
 Set automated bad channel detection (‘on’, ‘off’, ‘n’)
--skip=SKIP Skips raw data sequences, time intervals pairs in sec, e.g.: 0 30 120 150
--force Ignore program warnings
--st Apply the time-domain MaxST extension
--buflen=ST_BUFLEN
 MaxSt buffer length in sec
--corr=ST_CORR MaxSt subspace correlation
--trans=MV_TRANS
 Transforms the data into the coil definitions of in_fname, or into the default frame
--movecomp Estimates and compensates head movements in continuous raw data
--headpos Estimates and stores head position parameters, but does not compensate movements
--hp=MV_HP Stores head position data in an ascii file
--hpistep=MV_HPISTEP
 Sets head position update interval in ms
--hpisubt=MV_HPISUBT
 Subtracts hpi signals: sine amplitudes, amp + baseline, or switch off
--nohpicons Do not check initial consistency isotrak vs hpifit
--linefreq=LINEFREQ
 Sets the basic line interference frequency (50 or 60 Hz)
--nooverwrite Do not overwrite output file if it already exists
--args=MX_ARGS Additional command line arguments to pass to MaxFilter

Example usage:

$ mne maxfilter -i sample_audvis_raw.fif –st

This will apply MaxFilter with the MaxSt extension. The origin used by MaxFilter is computed by mne-python by fitting a sphere to the headshape points.

mne report

Usage: mne report [options]

Create mne report for a folder.

Options:
--version show program’s version number and exit
-h, --help show this help message and exit
-p PATH, --path=PATH
 Path to folder who MNE-Report must be created
-i FILE, --info=FILE
 File from which info dictionary is to be read
-c FILE, --cov=FILE
 File from which noise covariance is to be read
--bmin=BMIN Time at which baseline correction starts for evokeds
--bmax=BMAX Time at which baseline correction stops for evokeds
-d SUBJECTS_DIR, --subjects-dir=SUBJECTS_DIR
 The subjects directory
-s SUBJECT, --subject=SUBJECT
 The subject name
-v, --verbose run in verbose mode
--no-browser Do not open MNE-Report in browser
--overwrite Overwrite html report if it already exists
-j N_JOBS, --jobs=N_JOBS
 Number of jobs to run in parallel
-m MRI_DECIM, --mri-decim=MRI_DECIM
 Integer factor used to decimate BEM plots

Example usage

mne report -p MNE-sample-data/ -i MNE-sample-data/MEG/sample/sample_audvis-ave.fif -d MNE-sample-data/subjects/ -s sample

mne show_fiff

Usage: mne show_fiff <file>

Show the contents of a FIFF file.

Options:
--version show program’s version number and exit
-h, --help show this help message and exit

You can do for example:

$ mne show_fiff test_raw.fif

mne show_info

Usage: mne show_info <file>

Show measurement info from .fif file.

Options:
--version show program’s version number and exit
-h, --help show this help message and exit

You can do for example:

$ mne show_info sample_audvis_raw.fif

mne surf2bem

Usage: mne surf2bem [options]

Convert surface to BEM FIF file.

Options:
--version show program’s version number and exit
-h, --help show this help message and exit
-s FILE, --surf=FILE
 Surface in Freesurfer format
-f FILE, --fif=FILE
 FIF file produced
-i ID, --id=ID Surface Id (e.g. 4 sur head surface)

Example usage

mne surf2bem –surf ${SUBJECTS_DIR}/${SUBJECT}/surf/lh.seghead –fif ${SUBJECTS_DIR}/${SUBJECT}/bem/${SUBJECT}-head.fif –id=4

mne watershed_bem

Usage: mne watershed_bem [options]

Create BEM surfaces using the watershed algorithm included with FreeSurfer.

Options:
--version show program’s version number and exit
-h, --help show this help message and exit
-s SUBJECT, --subject=SUBJECT
 Subject name (required)
-d SUBJECTS_DIR, --subjects-dir=SUBJECTS_DIR
 Subjects directory
-o, --overwrite
 Write over existing files
-v VOLUME, --volume=VOLUME
 Defaults to T1
-a, --atlas Specify the –atlas option for mri_watershed
-g, --gcaatlas Use the subcortical atlas
-p PREFLOOD, --preflood=PREFLOOD
 Change the preflood height
--verbose=VERBOSE
 If not None, override default verbose level

You can do for example:

$ mne watershed_bem -s sample