import mne
import sys

from mne import compute_covariance

import matplotlib
matplotlib.use('Agg')
import matplotlib.pyplot as plt

from my_settings import *

reject = dict(grad=4000e-13,  # T / m (gradiometers)
              mag=4e-12,  # T (magnetometers)
              eeg=180e-6  #
              )


subject = sys.argv[1]

epochs = mne.read_epochs(epochs_folder + "%s_trial_start-epo.fif" % subject)
epochs.drop_bad_epochs(reject)

fig = epochs.plot_drop_log(subject=subject, show=False)
fig.savefig(epochs_folder + "pics/%s_drop_log.png" % subject)

# Make noise cov
cov = compute_covariance(epochs, tmin=None, tmax=0,
                         method="shrunk")
mne.write_cov(mne_folder + "%s-cov.fif" % subject, cov)


import mne
import sys

from mne import compute_covariance

import matplotlib
matplotlib.use('Agg')
import matplotlib.pyplot as plt

from my_settings import *

subject = sys.argv[1]

epochs = mne.read_epochs(epochs_folder + "%s_trial_start-epo.fif" % subject)
epochs.drop_bad_epochs(reject=reject_params)

fig = epochs.plot_drop_log(subject=subject, show=False)
fig.savefig(epochs_folder + "pics/%s_drop_log.png" % subject)

# Make noise cov
cov = compute_covariance(epochs, tmin=None, tmax=-0.2,
                         method="shrunk")
mne.write_cov(mne_folder + "%s-cov.fif" % subject, cov)

Clean up and change cov time
Clean up and change cov time

  import mne
  import sys
  
  from mne import compute_covariance
  
  import matplotlib
  matplotlib.use('Agg')
  import matplotlib.pyplot as plt
  
  from my_settings import *
  
- reject = dict(grad=4000e-13,  # T / m (gradiometers)
-               mag=4e-12,  # T (magnetometers)
-               eeg=180e-6  #
-               )
- 
- 
  subject = sys.argv[1]
  
  epochs = mne.read_epochs(epochs_folder + "%s_trial_start-epo.fif" % subject)
- epochs.drop_bad_epochs(reject)
+ epochs.drop_bad_epochs(reject=reject_params)
  
  fig = epochs.plot_drop_log(subject=subject, show=False)
  fig.savefig(epochs_folder + "pics/%s_drop_log.png" % subject)
  
  # Make noise cov
- cov = compute_covariance(epochs, tmin=None, tmax=0,
+ cov = compute_covariance(epochs, tmin=None, tmax=-0.2,
                           method="shrunk")
  mne.write_cov(mne_folder + "%s-cov.fif" % subject, cov)
  
- 
Clean up and change cov time
## Code Before:
import mne
import sys

from mne import compute_covariance

import matplotlib
matplotlib.use('Agg')
import matplotlib.pyplot as plt

from my_settings import *

reject = dict(grad=4000e-13,  # T / m (gradiometers)
              mag=4e-12,  # T (magnetometers)
              eeg=180e-6  #
              )


subject = sys.argv[1]

epochs = mne.read_epochs(epochs_folder + "%s_trial_start-epo.fif" % subject)
epochs.drop_bad_epochs(reject)

fig = epochs.plot_drop_log(subject=subject, show=False)
fig.savefig(epochs_folder + "pics/%s_drop_log.png" % subject)

# Make noise cov
cov = compute_covariance(epochs, tmin=None, tmax=0,
                         method="shrunk")
mne.write_cov(mne_folder + "%s-cov.fif" % subject, cov)


## Instruction:
Clean up and change cov time
## Code After:
import mne
import sys

from mne import compute_covariance

import matplotlib
matplotlib.use('Agg')
import matplotlib.pyplot as plt

from my_settings import *

subject = sys.argv[1]

epochs = mne.read_epochs(epochs_folder + "%s_trial_start-epo.fif" % subject)
epochs.drop_bad_epochs(reject=reject_params)

fig = epochs.plot_drop_log(subject=subject, show=False)
fig.savefig(epochs_folder + "pics/%s_drop_log.png" % subject)

# Make noise cov
cov = compute_covariance(epochs, tmin=None, tmax=-0.2,
                         method="shrunk")
mne.write_cov(mne_folder + "%s-cov.fif" % subject, cov)
