コード例 #1
0
def visualize(bands=None, folder="", reduceSize = True):
    #emptyDir("figs/temp")
    
    print 1
    data_path = somato.data_path()
    raw_fname = data_path + '/MEG/somato/sef_raw_sss.fif'
    
    # read the raw data
    raw = mne.io.read_raw_fif(raw_fname)
     
    
    
    print 2
    global images
    #reduce the size of the data file for quick testing if specified
    if reduceSize:
        splitData = splitRaw(raw, 100) 
        sourceData=splitData[0]
    else:
        sourceData=raw
    
    #creates an mne interval object with no measurements inside
    streamedData = sourceData.crop(0,0)
    
    print folder

    print 3
    global t1
    streamInterval = 1
    # thread streams data from [sourceData] to [streamedData]
    t1 = threading.Thread(target=beginStreaming, args=([sourceData,streamedData,streamInterval]))
    t1.start()
         
    
    print 4
    global t2
    visInterval = 1
    initial = 1
    bufferSize = 5000
    # thread visualizes the contents of the streamed data interval object
    t2 = threading.Thread(target=beginVisualizing, args=([streamedData, images, bands, visInterval, initial, bufferSize, folder]))
    t2.start()     

    
    print 5
    # do not continue until both threads have terminated
    t1.join()
    t2.join()
    
    # reset the number of figures generated in the current stream
    global count
    count = 0

    print ("Done")
    return images
コード例 #2
0
def _get_somato_data():
    from mne.datasets import somato
    data_path = somato.data_path()
    raw_fname = data_path + '/MEG/somato/sef_raw_sss.fif'
    event_id, tmin, tmax = 1, -1., 3.

    # Setup for reading the raw data
    raw = io.Raw(raw_fname, preload=True)
    raw.filter(1, 40, n_jobs=-1)
    baseline = (None, 0)
    events = mne.find_events(raw, stim_channel='STI 014')

    # picks MEG gradiometers
    picks = mne.pick_types(raw.info, meg='grad', eeg=False, eog=True,
                           stim=False)

    epochs = mne.Epochs(raw, events, event_id, tmin, tmax, picks=picks,
                        baseline=baseline,
                        reject=dict(grad=4000e-13, eog=350e-6))

    return epochs, epochs.info['sfreq']
コード例 #3
0
###############################################################################
# First, we will import the packages needed for computing the inverse solution
# from the MNE somatosensory dataset. `MNE`_ can be installed with
# ``pip install mne``, and the somatosensory dataset can be downloaded by
# importing ``somato`` from ``mne.datasets``.
import os.path as op
import matplotlib.pyplot as plt

import mne
from mne.datasets import somato
from mne.minimum_norm import apply_inverse, make_inverse_operator

###############################################################################
# Now we set the the path of the ``somato`` dataset for subject ``'01'``.
data_path = somato.data_path()
subject = '01'
task = 'somato'
raw_fname = op.join(data_path, 'sub-{}'.format(subject), 'meg',
                    'sub-{}_task-{}_meg.fif'.format(subject, task))
fwd_fname = op.join(data_path, 'derivatives', 'sub-{}'.format(subject),
                    'sub-{}_task-{}-fwd.fif'.format(subject, task))
subjects_dir = op.join(data_path, 'derivatives', 'freesurfer', 'subjects')

###############################################################################
# Then, we load the raw data and estimate the inverse operator.

# Read and band-pass filter the raw data
raw = mne.io.read_raw_fif(raw_fname, preload=True)
l_freq, h_freq = 1, 40
raw.filter(l_freq, h_freq)
コード例 #4
0
We will use the somatosensory dataset that contains so-called
event related synchronizations (ERS) / desynchronizations (ERD) in
the beta band.
"""

import numpy as np
import matplotlib.pyplot as plt

import mne
from mne.time_frequency import tfr_morlet, psd_multitaper
from mne.datasets import somato

###############################################################################
# Set parameters
data_path = somato.data_path()
raw_fname = data_path + '/MEG/somato/sef_raw_sss.fif'

# Setup for reading the raw data
raw = mne.io.read_raw_fif(raw_fname)
events = mne.find_events(raw, stim_channel='STI 014')

# picks MEG gradiometers
picks = mne.pick_types(raw.info, meg='grad', eeg=False, eog=True, stim=False)

# Construct Epochs
event_id, tmin, tmax = 1, -1., 3.
baseline = (None, 0)
epochs = mne.Epochs(raw, events, event_id, tmin, tmax, picks=picks,
                    baseline=baseline, reject=dict(grad=4000e-13, eog=350e-6),
                    preload=True)
コード例 #5
0
from mne.datasets import somato

from mne_bids import (BIDSPath, read_raw_bids, print_dir_tree)

###############################################################################
# We will be using the `MNE somato data <mne_somato_data_>`_, which
# is already stored in BIDS format.
# For more information, you can checkout the
# respective :ref:`example <ex-convert-mne-sample>`.

###############################################################################
# Step 1: Download/Get a BIDS dataset
# -----------------------------------
#
# Get the MNE somato data
bids_root = somato.data_path()
subject_id = '01'
task = 'somato'
datatype = 'meg'

bids_path = BIDSPath(subject=subject_id,
                     task=task,
                     datatype=datatype,
                     suffix=datatype,
                     root=bids_root)

# bids basename is nicely formatted
print(bids_path)

###############################################################################
# Print the directory tree