Command line tools using Python

mne browse_raw

Browse raw data.

Usage: mne browse_raw raw [options]

Options

--version

show program’s version number and exit

-h, --help

show this help message and exit

--raw=FILE

Input raw FIF file (can also be specified directly as an argument without the –raw prefix)

--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 GROUP_BY, --order=GROUP_BY

Order to use for grouping during plotting (‘type’ or ‘original’)

-p, --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 (or 0 to use FIR)

--clipping=CLIPPING

Enable trace clipping mode, either ‘clamp’ or ‘transparent’

--filterchpi

Enable filtering cHPI signals.

--verbose

Enable verbose mode (printing of log messages).

Examples

$ mne browse_raw sample_audvis_raw.fif \
                 --proj sample_audvis_ecg-proj.fif \
                 --eve sample_audvis_raw-eve.fif

mne bti2fiff

Import BTi / 4D MagnesWH3600 data to fif file.

Usage: mne bti2fiff [options]

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

Notes

  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.

Examples

$ mne bti2fiff --pdf C,rfDC -o my_raw.fif

mne clean_eog_ecg

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

Usage: mne clean_eog_ecg [options]

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

Examples

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

mne compare_fiff

Compare FIFF files.

Usage: mne compare_fiff <file_a> <file_b>

Options

--version

show program’s version number and exit

-h, --help

show this help message and exit

Examples

$ mne compare_fiff test_raw.fif test_raw_sss.fif

mne compute_proj_ecg

Compute SSP/PCA projections for ECG artifacts.

Usage: mne compute_proj_ecg [options]

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

Examples

$ 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

Compute SSP/PCA projections for EOG artifacts.

Usage: mne compute_proj_eog [options]

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

Examples

$ 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

Open the coregistration GUI.

Usage: mne coreg [options]

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”)

--project-eeg

Project EEG electrodes to the head surface (for visualization purposes only)

--orient-to-surface

Orient points to the surface.

--scale-by-distance

Scale points by distance from the surface.

--mark-inside

Mark points inside the head using a different color.

--interaction=INTERACTION

Interaction style to use, can be “trackball” or “terrain”.

--scale=SCALE

Scale factor for the scene.

--simple-rendering

Use simplified OpenGL rendering

--verbose

Enable verbose mode (printing of log messages).

Examples

$ mne coreg

mne flash_bem

Create 3-layer BEM model from Flash MRI images.

Usage: mne flash_bem [options]

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

--copy

Use copies instead of symlinks for surfaces

-p FLASH_PATH, --flash-path=FLASH_PATH

The directory containing flash05.mgz and flash30.mgz files (defaults to $SUBJECTS_DIR/$SUBJECT/mri/flash/parameter_maps

Examples

$ mne flash_bem --subject=sample

Notes

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

mne freeview_bem_surfaces

View the 3-Layers BEM model using Freeview.

Usage: mne freeview_bem_surfaces [options]

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.

Examples

$ mne freeview_bem_surfaces -s sample

mne kit2fiff

Import KIT / NYU data to fif file.

Usage: mne kit2fiff [options]

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

Examples

$ mne kit2fiff --input input.sqd --output output.fif

Use without arguments to invoke GUI:

$ mne kt2fiff

mne make_scalp_surfaces

Create high-resolution head surfaces for coordinate alignment.

Usage: mne make_scalp_surfaces [options]

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.

-d SUBJECTS_DIR, --subjects-dir=SUBJECTS_DIR

Subjects directory

-n, --no-decimate

Disable medium and sparse decimations (dense only)

--verbose

Enable verbose mode (printing of log messages).

Examples

$ mne make_scalp_surfaces --overwrite --subject sample

mne maxfilter

Apply MaxFilter.

Usage: mne maxfilter [options]

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

Examples

$ 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

Create mne report for a folder.

Usage: mne report [options]

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

--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

--image-format=IMAGE_FORMAT

Image format to use (can be ‘png’ or ‘svg’)

--verbose

Enable verbose mode (printing of log messages).

Examples

Before getting started with mne report, make sure the files you want to render follow the filename conventions defined by MNE:

Data object

Filename convention (ends with)

raw

-raw.fif(.gz), -raw_sss.fif(.gz), -raw_tsss.fif(.gz), _meg.fif

events

-eve.fif(.gz)

epochs

-epo.fif(.gz)

evoked

-ave.fif(.gz)

covariance

-cov.fif(.gz)

trans

-trans.fif(.gz)

forward

-fwd.fif(.gz)

inverse

-inv.fif(.gz)

To generate a barebones report from all the *.fif files in the sample dataset, invoke the following command in a system (e.g., Bash) shell:

$ mne report --path MNE-sample-data/ --verbose

On successful creation of the report, it will open the HTML in a new tab in the browser. To disable this, use the --no-browser option.

TO generate a report for a single subject, give the SUBJECT name and the SUBJECTS_DIR and this will generate the MRI slices (with BEM contours overlaid on top if available):

$ mne report --path MNE-sample-data/ --subject sample --subjects-dir \
    MNE-sample-data/subjects --verbose

To properly render trans and covariance files, add the measurement information:

$ mne report --path MNE-sample-data/ \
    --info MNE-sample-data/MEG/sample/sample_audvis-ave.fif \
    --subject sample --subjects-dir MNE-sample-data/subjects --verbose

To render whitened evoked files with baseline correction, add the noise covariance file:

$ mne report --path MNE-sample-data/ \
    --info MNE-sample-data/MEG/sample/sample_audvis-ave.fif \
    --cov MNE-sample-data/MEG/sample/sample_audvis-cov.fif --bmax 0 \
    --subject sample --subjects-dir MNE-sample-data/subjects --verbose

To generate the report in parallel:

$ mne report --path MNE-sample-data/ \
    --info MNE-sample-data/MEG/sample/sample_audvis-ave.fif \
    --subject sample --subjects-dir MNE-sample-data/subjects \
    --verbose --jobs 6

For help on all the available options, do:

$ mne report --help

mne show_fiff

Show the contents of a FIFF file.

Usage: mne show_fiff <file>

Options

--version

show program’s version number and exit

-h, --help

show this help message and exit

-t TAG, --tag=TAG

provide information about this tag

Examples

$ mne show_fiff test_raw.fif

To see only tag 102:

$ mne show_fiff test_raw.fif --tag=102

mne show_info

Show measurement info from .fif file.

Usage: mne show_info <file>

Options

--version

show program’s version number and exit

-h, --help

show this help message and exit

Examples

$ mne show_info sample_audvis_raw.fif

mne surf2bem

Convert surface to BEM FIF file.

Usage: mne surf2bem [options]

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)

Examples

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

mne watershed_bem

Create BEM surfaces using the watershed algorithm included with FreeSurfer.

Usage: mne watershed_bem [options]

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

Specify the –brain_atlas option for mri_watershed

-p PREFLOOD, --preflood=PREFLOOD

Change the preflood height

--copy

Use copies instead of symlinks for surfaces

-t T1, --T1=T1

Whether or not to pass the -T1 flag (can be true, false, 0, or 1). By default it takes the same value as gcaatlas.

-b BRAINMASK, --brainmask=BRAINMASK

The filename for the brainmask output file relative to the $SUBJECTS_DIR/$SUBJECT/bem/watershed/ directory.

--verbose

Enable verbose mode (printing of log messages).

Examples

$ mne watershed_bem -s sample

mne what

Check type of FIF file.

Usage: mne what fname [fname2 ...]

Options

--version

show program’s version number and exit

-h, --help

show this help message and exit

Examples

$ mne what sample_audvis_raw.fif
raw