Command line tools using Python#

mne anonymize#

Anonymize raw fif file.#

Usage: mne anonymize [options]

Options#

--version

show program’s version number and exit

-h, --help

show this help message and exit

-f FILE, --file=FILE

Name of file to modify.

-o OUTFILE, --output=OUTFILE

Name of anonymized output file.`anon-` prefix is added to FILE if not given

--keep_his

Keep the HIS tag (not advised)

-d N_DAYS, --daysback=N_DAYS

Move dates in file backwards by this many days.

--overwrite

Overwrite input file.

To anonymize other file types call mne.io.anonymize_info() on their Info objects and resave to disk.

Examples#

$ mne anonymize -f sample_audvis_raw.fif

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

--projoff

Disable all projectors

--eve=FILE

Events file

-d DURATION, --duration=DURATION

Time window for plotting (s)

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

-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. Can be ‘clamp’, ‘transparent’, a float, or ‘none’.

--filterchpi

Enable filtering cHPI signals.

--butterfly

Plot in butterfly mode

--verbose

Enable verbose mode (printing of log messages).

This uses mne.io.read_raw() so it supports the same formats (without keyword arguments).

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. Please 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 µV (peak to peak amplitude)

--rej-eog=REJ_EOG

EOG rejection parameter in µV (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" -a \
                       --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 µV (peak to peak amplitude)

--rej-eog=REJ_EOG

EOG rejection parameter in µV (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 -a \
                       --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 -a \
                       --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

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

--interaction=INTERACTION

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

--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, --flash30, --noflash30

The 30-degree flip angle data. If no argument do not use flash30. If arguments are given, them as file names.

-5, --flash5

Path to the multiecho flash 5 images. Can be one file or one per echo.

-r, --registered

Set if the Flash MRI images have already been registered with the T1.mgz file.

-n, --noconvert

[DEPRECATED] 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

[DEPRECATED] The directory containing flash5.mgz files (defaults to $SUBJECTS_DIR/$SUBJECT/mri/flash/parameter_maps

Examples#

$ mne flash_bem --subject=sample
$ mne flash_bem -s sample -n --registered -5 sample/mri/mef05.mgz -3 sample/mri/mef30.mgz
$ mne flash_bem -s sample -n --registered -5 sample/mri/flash/mef05_*.mgz -3 sample/mri/flash/mef30_*.mgz

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 can be input as .mgz or .nii files. 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.

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

-m MRI, --mri=MRI

The MRI file to process using mkheadsurf.

-f, --force

Force creation of the surface even if it has some topological defects.

-t THRESHOLD, --threshold=THRESHOLD

Threshold value to use with the MRI.

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

Create a BEM solution using the linear collocation approach.#

Usage: mne prepare_bem_model [options]

Options#

--version

show program’s version number and exit

-h, --help

show this help message and exit

--bem=FILE

The name of the file containing the triangulations of the BEM surfaces and the conductivities of the compartments. The standard ending for this file is -bem.fif.

--sol=FILE

The name of the resulting file containing BEM solution (geometry matrix). It uses the linear collocation approach. The file should end with -bem-sof.fif.

--verbose

Enable verbose mode (printing of log messages).

Examples#

$ mne prepare_bem_model --bem sample-5120-5120-5120-bem.fif

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(.gz), _eeg.fif(.gz), _ieeg.fif(.gz)

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

Create a BEM model for a subject.#

Usage: mne setup_forward_model [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)

--model=MODEL

Output file name. Use a name <dir>/<name>-bem.fif

--ico=ICO

The surface ico downsampling to use, e.g. 5=20484, 4=5120, 3=1280. If None, no subsampling is applied.

--brainc=BRAINC

Defines the brain compartment conductivity. The default value is 0.3 S/m.

--skullc=SKULLC

Defines the skull compartment conductivity. The default value is 0.006 S/m.

--scalpc=SCALPC

Defines the scalp compartment conductivity. The default value is 0.3 S/m.

--homog

Use a single compartment model (brain only) instead a three layer one (scalp, skull, and brain). If this flag is specified, the options –skullc and –scalpc are irrelevant.

-d SUBJECTS_DIR, --subjects-dir=SUBJECTS_DIR

Subjects directory

--verbose

Enable verbose mode (printing of log messages).

Examples#

$ mne setup_forward_model -s 'sample'

mne setup_source_space#

Set up bilateral hemisphere surface-based source space with subsampling.#

Usage: mne setup_source_space [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)

--src=FILE

Output file name. Use a name <dir>/<name>-src.fif

--morph=SUBJECT_TO

morph the source space to this subject

--surf=SURFACE

The surface to use. (default to white)

--spacing=SPACING

Specifies the approximate grid spacing of the source space in mm. (default to 7mm)

--ico=ICO

use the recursively subdivided icosahedron to create the source space.

--oct=OCT

use the recursively subdivided octahedron to create the source space.

-d SUBJECTS_DIR, --subjects-dir=SUBJECTS_DIR

Subjects directory

-n N_JOBS, --n-jobs=N_JOBS

The number of jobs to run in parallel (default 1). Requires the joblib package. Will use at most 2 jobs (one for each hemisphere).

--add-dist=ADD_DIST

Add distances. Can be “True”, “False”, or “patch” to only compute cortical patch statistics (like the –cps option in MNE-C)

-o, --overwrite

to write over existing files

--verbose

Enable verbose mode (printing of log messages).

Examples#

   $ mne setup_source_space --subject sample


.. note : Only one of --ico, --oct or --spacing options can be set at the same
          time. Default to oct6.

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

-b, --bytes

show the byte offset of each 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 for head surface)

Examples#

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

mne sys_info#

Show system information.#

Usage: mne sys_info

Options#

--version

show program’s version number and exit

-h, --help

show this help message and exit

-p, --show-paths

Show module paths

-d, --developer

Show additional developer module information

-a, --ascii

Use ASCII instead of unicode symbols

--no-check-version

Disable MNE-Python remote version checking.

Examples#

$ mne sys_info

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