Repository: mne-tools/mne-python

Issue:
Epoch-ing too slow when #events is large..
So I have several ABR dataset where I have about 8000 trials.  Epoching is way too slow and I suspect that the issue is related to not pre-allocating memory in ```_get_data_from_disk``` and growing the ```_data``` array one epoch at a time. When I don't do ```preload=True```,  when I eventually have to average, ```epochs.average()``` is too slow. 

Am I missing something or is there room to speed things up?

Discussion:

Patch:
diff --git a/.gitignore b/.gitignore
old mode 100644
new mode 100755
index a32ce2aea..cdad72a3d
--- a/.gitignore
+++ b/.gitignore
@@ -1,6 +1,5 @@
 *.pyc
 *.pyo
-*.sh
 *.so
 *.fif
 *.tar.gz
diff --git a/Makefile b/Makefile
index 7b7102444..484275006 100755
--- a/Makefile
+++ b/Makefile
@@ -108,10 +108,3 @@ manpages:
 			>| ../build/manpages/$$f.1; \
 	done
 
-build-doc-dev:
-	cd doc; make clean
-	cd doc; DISPLAY=:1.0 xvfb-run -n 1 -s "-screen 0 1280x1024x24 -noreset -ac +extension GLX +render" make html_dev
-
-build-doc-stable:
-	cd doc; make clean
-	cd doc; DISPLAY=:1.0 xvfb-run -n 1 -s "-screen 0 1280x1024x24 -noreset -ac +extension GLX +render" make html
diff --git a/doc/source/_static/navy.css b/doc/source/_static/navy.css
index c8419184a..04912f9ad 100755
--- a/doc/source/_static/navy.css
+++ b/doc/source/_static/navy.css
@@ -4,7 +4,7 @@
  */
 
 body {
-    font-family: 'Open Sans', 'Lucida Grande', 'Lucida Sans Unicode', 'Geneva', 'Verdana', sans-serif;
+    font-family: 'Lucida Grande', 'Lucida Sans Unicode', 'Geneva', 'Verdana', sans-serif;
     font-size: 14px;
     letter-spacing: -0.01em;
     line-height: 150%;
diff --git a/doc/source/_templates/layout.html b/doc/source/_templates/layout.html
index 7178e1f11..c71a45092 100755
--- a/doc/source/_templates/layout.html
+++ b/doc/source/_templates/layout.html
@@ -1,9 +1,6 @@
 {% extends "!layout.html" %}
 
 {% block extrahead %}
-
-<link href='http://fonts.googleapis.com/css?family=Open+Sans:400italic,700italic,400,700' rel='stylesheet' type='text/css'>
-
 {% if use_google_analytics|tobool %}
     <script type="text/javascript">
     var _gaq = _gaq || [];
diff --git a/examples/README.txt b/examples/README.txt
index 75dff2db0..aebe56991 100644
--- a/examples/README.txt
+++ b/examples/README.txt
@@ -1,4 +1,6 @@
-Introductory examples
----------------------
 
-Introductory examples to MNE.
+General examples
+-------------------
+
+General-purpose and introductory examples to MNE.
+
diff --git a/examples/connectivity/plot_mne_inverse_coherence_epochs.py b/examples/connectivity/plot_mne_inverse_coherence_epochs.py
index d09357237..c8c973e7b 100644
--- a/examples/connectivity/plot_mne_inverse_coherence_epochs.py
+++ b/examples/connectivity/plot_mne_inverse_coherence_epochs.py
@@ -5,7 +5,7 @@ Compute coherence in source space using a MNE inverse solution
 
 This examples computes the coherence between a seed in the left
 auditory cortex and the rest of the brain based on single-trial
-MNE-dSPM inverse solutions.
+MNE-dSPM inverse soltions.
 
 """
 # Author: Martin Luessi <mluessi@nmr.mgh.harvard.edu>
diff --git a/examples/forward/README.txt b/examples/forward/README.txt
deleted file mode 100644
index 89db5587d..000000000
--- a/examples/forward/README.txt
+++ /dev/null
@@ -1,6 +0,0 @@
-
-Forward modeling
-----------------
-
-From BEM segmentation, coregistration, setting up source spaces
-to actual computation of forward solution.
diff --git a/examples/plot_compute_mne_inverse.py b/examples/inverse/plot_compute_mne_inverse.py
similarity index 100%
rename from examples/plot_compute_mne_inverse.py
rename to examples/inverse/plot_compute_mne_inverse.py
diff --git a/examples/io/README.txt b/examples/io/README.txt
deleted file mode 100644
index 45f88d173..000000000
--- a/examples/io/README.txt
+++ /dev/null
@@ -1,5 +0,0 @@
-
-Input/Ouput
------------
-
-Reading and writing files.
diff --git a/examples/forward/plot_bem_contour_mri.py b/examples/plot_bem_contour_mri.py
similarity index 100%
rename from examples/forward/plot_bem_contour_mri.py
rename to examples/plot_bem_contour_mri.py
diff --git a/examples/visualization/plot_channel_epochs_image.py b/examples/plot_channel_epochs_image.py
similarity index 100%
rename from examples/visualization/plot_channel_epochs_image.py
rename to examples/plot_channel_epochs_image.py
diff --git a/examples/visualization/plot_clickable_image.py b/examples/plot_clickable_image.py
similarity index 100%
rename from examples/visualization/plot_clickable_image.py
rename to examples/plot_clickable_image.py
diff --git a/examples/forward/plot_coregistration_transform.py b/examples/plot_coregistration_transform.py
similarity index 100%
rename from examples/forward/plot_coregistration_transform.py
rename to examples/plot_coregistration_transform.py
diff --git a/examples/forward/plot_decimate_head_surface.py b/examples/plot_decimate_head_surface.py
similarity index 100%
rename from examples/forward/plot_decimate_head_surface.py
rename to examples/plot_decimate_head_surface.py
diff --git a/examples/preprocessing/plot_define_target_events.py b/examples/plot_define_target_events.py
similarity index 100%
rename from examples/preprocessing/plot_define_target_events.py
rename to examples/plot_define_target_events.py
diff --git a/examples/io/plot_epochs_to_data_frame.py b/examples/plot_epochs_to_data_frame.py
similarity index 100%
rename from examples/io/plot_epochs_to_data_frame.py
rename to examples/plot_epochs_to_data_frame.py
diff --git a/examples/preprocessing/plot_estimate_covariance_matrix_baseline.py b/examples/plot_estimate_covariance_matrix_baseline.py
similarity index 100%
rename from examples/preprocessing/plot_estimate_covariance_matrix_baseline.py
rename to examples/plot_estimate_covariance_matrix_baseline.py
diff --git a/examples/preprocessing/plot_estimate_covariance_matrix_raw.py b/examples/plot_estimate_covariance_matrix_raw.py
similarity index 100%
rename from examples/preprocessing/plot_estimate_covariance_matrix_raw.py
rename to examples/plot_estimate_covariance_matrix_raw.py
diff --git a/examples/visualization/plot_evoked_delayed_ssp.py b/examples/plot_evoked_delayed_ssp.py
similarity index 100%
rename from examples/visualization/plot_evoked_delayed_ssp.py
rename to examples/plot_evoked_delayed_ssp.py
diff --git a/examples/visualization/plot_evoked_topomap.py b/examples/plot_evoked_topomap.py
similarity index 100%
rename from examples/visualization/plot_evoked_topomap.py
rename to examples/plot_evoked_topomap.py
diff --git a/examples/visualization/plot_evoked_topomap_delayed_ssp.py b/examples/plot_evoked_topomap_delayed_ssp.py
similarity index 100%
rename from examples/visualization/plot_evoked_topomap_delayed_ssp.py
rename to examples/plot_evoked_topomap_delayed_ssp.py
diff --git a/examples/visualization/plot_evoked_whitening.py b/examples/plot_evoked_whitening.py
similarity index 100%
rename from examples/visualization/plot_evoked_whitening.py
rename to examples/plot_evoked_whitening.py
diff --git a/examples/plot_extract_events_from_raw.py b/examples/plot_extract_events_from_raw.py
index 4d52daf6b..4d8c1a283 100644
--- a/examples/plot_extract_events_from_raw.py
+++ b/examples/plot_extract_events_from_raw.py
@@ -25,7 +25,7 @@ raw = Raw(fname)
 events = mne.find_events(raw, stim_channel='STI 014')
 
 # Writing events
-mne.write_events('sample_audvis_raw-eve.fif', events)
+mne.write_events('events.fif', events)
 
 for ind, before, after in events[:5]:
     print("At sample %d stim channel went from %d to %d"
diff --git a/examples/plot_from_raw_to_epochs_to_evoked.py b/examples/plot_from_raw_to_epochs_to_evoked.py
index d36bff025..c2934c685 100644
--- a/examples/plot_from_raw_to_epochs_to_evoked.py
+++ b/examples/plot_from_raw_to_epochs_to_evoked.py
@@ -16,6 +16,7 @@ data and then saved to disk.
 import mne
 from mne import io
 from mne.datasets import sample
+import matplotlib.pyplot as plt
 
 print(__doc__)
 
@@ -25,17 +26,14 @@ data_path = sample.data_path()
 # Set parameters
 raw_fname = data_path + '/MEG/sample/sample_audvis_filt-0-40_raw.fif'
 event_fname = data_path + '/MEG/sample/sample_audvis_filt-0-40_raw-eve.fif'
-tmin, tmax = -0.2, 0.5
-
-# Select events to extract epochs from.
-event_id = {'Auditory/Left': 1, 'Auditory/Right': 2}
+event_id, tmin, tmax = 1, -0.2, 0.5
 
 #   Setup for reading the raw data
 raw = io.Raw(raw_fname)
 events = mne.read_events(event_fname)
 
 #   Plot raw data
-fig = raw.plot(events=events, event_color={1: 'cyan', -1: 'lightgray'})
+fig = raw.plot(events=events, event_color={event_id: 'cyan', -1: 'lightgray'})
 
 #   Set up pick list: EEG + STI 014 - bad channels (modify to your needs)
 include = []  # or stim channels ['STI 014']
@@ -56,21 +54,26 @@ epochs.plot()
 epochs.drop_bad_epochs()
 epochs.plot_drop_log(subject='sample')
 
-# Average epochs and get evoked data corresponding to the left stimulation
-evoked = epochs['Left'].average()
+evoked = epochs.average()  # average epochs and get an Evoked dataset.
 
 evoked.save('sample_audvis_eeg-ave.fif')  # save evoked data to disk
 
 ###############################################################################
 # View evoked response
+times = 1e3 * epochs.times  # time in miliseconds
+
+ch_max_name, latency = evoked.get_peak(mode='neg')
 
 evoked.plot()
 
-###############################################################################
-# Save evoked responses for different conditions to disk
+plt.xlim([times[0], times[-1]])
+plt.xlabel('time (ms)')
+plt.ylabel('Potential (uV)')
+plt.title('EEG evoked potential')
 
-# average epochs and get Evoked datasets
-evokeds = [epochs[cond].average() for cond in ['Left', 'Right']]
+plt.axvline(latency * 1e3, color='red',
+            label=ch_max_name, linewidth=2,
+            linestyle='--')
+plt.legend(loc='best')
 
-# save evoked data to disk
-mne.write_evokeds('sample_auditory_and_visual_eeg-ave.fif', evokeds)
+plt.show()
diff --git a/examples/plot_from_raw_to_multiple_epochs_to_evoked.py b/examples/plot_from_raw_to_multiple_epochs_to_evoked.py
new file mode 100644
index 000000000..410239032
--- /dev/null
+++ b/examples/plot_from_raw_to_multiple_epochs_to_evoked.py
@@ -0,0 +1,72 @@
+"""
+====================================================================
+Extract epochs for multiple conditions, save evoked response to disk
+====================================================================
+
+This script shows how to read the epochs for multiple conditions from
+a raw file given a list of events. The epochs are averaged to produce
+evoked data and then saved to disk.
+
+"""
+# Authors: Alexandre Gramfort <alexandre.gramfort@telecom-paristech.fr>
+#          Eric Larson <larson.eric.d@gmail.com>
+#          Denis Engemann <denis.engemann@gmail.com>
+#
+# License: BSD (3-clause)
+
+import mne
+from mne import io
+from mne.datasets import sample
+from mne.epochs import combine_event_ids
+import matplotlib.pyplot as plt
+
+print(__doc__)
+
+data_path = sample.data_path()
+
+###############################################################################
+# Set parameters
+raw_fname = data_path + '/MEG/sample/sample_audvis_filt-0-40_raw.fif'
+event_fname = data_path + '/MEG/sample/sample_audvis_filt-0-40_raw-eve.fif'
+event_ids = {'AudL': 1, 'AudR': 2, 'VisL': 3, 'VisR': 4}
+tmin = -0.2
+tmax = 0.5
+
+#   Setup for reading the raw data
+raw = io.Raw(raw_fname)
+events = mne.read_events(event_fname)
+
+#   Set up pick list: EEG + STI 014 - bad channels (modify to your needs)
+include = []  # or stim channels ['STI 014']
+raw.info['bads'] += ['EEG 053']  # bads + 1 more
+
+# pick EEG channels
+picks = mne.pick_types(raw.info, meg=False, eeg=True, stim=False, eog=True,
+                       include=include, exclude='bads')
+# Read epochs
+epochs = mne.Epochs(raw, events, event_ids, tmin, tmax, picks=picks,
+                    baseline=(None, 0), reject=dict(eeg=80e-6, eog=150e-6))
+# Let's equalize the trial counts in each condition
+epochs.equalize_event_counts(['AudL', 'AudR', 'VisL', 'VisR'], copy=False)
+# Now let's combine some conditions
+combine_event_ids(epochs, ['AudL', 'AudR'], {'Auditory': 12}, copy=False)
+combine_event_ids(epochs, ['VisL', 'VisR'], {'Visual': 34}, copy=False)
+
+# average epochs and get Evoked datasets
+evokeds = [epochs[cond].average() for cond in ['Auditory', 'Visual']]
+
+# save evoked data to disk
+mne.write_evokeds('sample_auditory_and_visual_eeg-ave.fif', evokeds)
+
+###############################################################################
+# View evoked response
+plt.clf()
+ax = plt.subplot(2, 1, 1)
+evokeds[0].plot(axes=ax)
+plt.title('EEG evoked potential, auditory trials')
+plt.ylabel('Potential (uV)')
+ax = plt.subplot(2, 1, 2)
+evokeds[1].plot(axes=ax)
+plt.title('EEG evoked potential, visual trials')
+plt.ylabel('Potential (uV)')
+plt.show()
diff --git a/examples/preprocessing/plot_interpolate_bad_channels.py b/examples/plot_interpolate_bad_channels.py
similarity index 100%
rename from examples/preprocessing/plot_interpolate_bad_channels.py
rename to examples/plot_interpolate_bad_channels.py
diff --git a/examples/forward/plot_left_cerebellum_volume_source.py b/examples/plot_left_cerebellum_volume_source.py
similarity index 100%
rename from examples/forward/plot_left_cerebellum_volume_source.py
rename to examples/plot_left_cerebellum_volume_source.py
diff --git a/examples/forward/plot_make_forward.py b/examples/plot_make_forward.py
similarity index 100%
rename from examples/forward/plot_make_forward.py
rename to examples/plot_make_forward.py
diff --git a/examples/visualization/plot_meg_eeg_fields_3d.py b/examples/plot_meg_eeg_fields_3d.py
similarity index 100%
rename from examples/visualization/plot_meg_eeg_fields_3d.py
rename to examples/plot_meg_eeg_fields_3d.py
diff --git a/examples/io/plot_objects_from_arrays.py b/examples/plot_objects_from_arrays.py
similarity index 100%
rename from examples/io/plot_objects_from_arrays.py
rename to examples/plot_objects_from_arrays.py
diff --git a/examples/io/plot_read_and_write_raw_data.py b/examples/plot_read_and_write_raw_data.py
similarity index 100%
rename from examples/io/plot_read_and_write_raw_data.py
rename to examples/plot_read_and_write_raw_data.py
diff --git a/examples/forward/plot_read_bem_surfaces.py b/examples/plot_read_bem_surfaces.py
similarity index 100%
rename from examples/forward/plot_read_bem_surfaces.py
rename to examples/plot_read_bem_surfaces.py
diff --git a/examples/io/plot_read_epochs.py b/examples/plot_read_epochs.py
similarity index 100%
rename from examples/io/plot_read_epochs.py
rename to examples/plot_read_epochs.py
diff --git a/examples/io/plot_read_evoked.py b/examples/plot_read_evoked.py
similarity index 100%
rename from examples/io/plot_read_evoked.py
rename to examples/plot_read_evoked.py
diff --git a/examples/forward/plot_read_forward.py b/examples/plot_read_forward.py
similarity index 100%
rename from examples/forward/plot_read_forward.py
rename to examples/plot_read_forward.py
diff --git a/examples/io/plot_read_noise_covariance_matrix.py b/examples/plot_read_noise_covariance_matrix.py
similarity index 100%
rename from examples/io/plot_read_noise_covariance_matrix.py
rename to examples/plot_read_noise_covariance_matrix.py
diff --git a/examples/preprocessing/plot_rereference_eeg.py b/examples/plot_rereference_eeg.py
similarity index 100%
rename from examples/preprocessing/plot_rereference_eeg.py
rename to examples/plot_rereference_eeg.py
diff --git a/examples/preprocessing/plot_shift_evoked.py b/examples/plot_shift_evoked.py
similarity index 100%
rename from examples/preprocessing/plot_shift_evoked.py
rename to examples/plot_shift_evoked.py
diff --git a/examples/simulation/plot_simulate_evoked_data.py b/examples/plot_simulate_evoked_data.py
similarity index 100%
rename from examples/simulation/plot_simulate_evoked_data.py
rename to examples/plot_simulate_evoked_data.py
diff --git a/examples/visualization/plot_ssp_projs_sensitivity_map.py b/examples/plot_ssp_projs_sensitivity_map.py
similarity index 100%
rename from examples/visualization/plot_ssp_projs_sensitivity_map.py
rename to examples/plot_ssp_projs_sensitivity_map.py
diff --git a/examples/visualization/plot_ssp_projs_topomaps.py b/examples/plot_ssp_projs_topomaps.py
similarity index 100%
rename from examples/visualization/plot_ssp_projs_topomaps.py
rename to examples/plot_ssp_projs_topomaps.py
diff --git a/examples/visualization/plot_topo_channel_epochs_image.py b/examples/plot_topo_channel_epochs_image.py
similarity index 100%
rename from examples/visualization/plot_topo_channel_epochs_image.py
rename to examples/plot_topo_channel_epochs_image.py
diff --git a/examples/visualization/plot_topo_compare_conditions.py b/examples/plot_topo_compare_conditions.py
similarity index 100%
rename from examples/visualization/plot_topo_compare_conditions.py
rename to examples/plot_topo_compare_conditions.py
diff --git a/examples/visualization/plot_topo_customized.py b/examples/plot_topo_customized.py
similarity index 100%
rename from examples/visualization/plot_topo_customized.py
rename to examples/plot_topo_customized.py
diff --git a/examples/visualization/plot_topography.py b/examples/plot_topography.py
similarity index 100%
rename from examples/visualization/plot_topography.py
rename to examples/plot_topography.py
diff --git a/examples/preprocessing/plot_virtual_evoked.py b/examples/plot_virtual_evoked.py
similarity index 100%
rename from examples/preprocessing/plot_virtual_evoked.py
rename to examples/plot_virtual_evoked.py
diff --git a/examples/io/read_events.py b/examples/read_events.py
similarity index 100%
rename from examples/io/read_events.py
rename to examples/read_events.py
diff --git a/examples/simulation/README.txt b/examples/simulation/README.txt
deleted file mode 100644
index bec6bcce3..000000000
--- a/examples/simulation/README.txt
+++ /dev/null
@@ -1,5 +0,0 @@
-
-Data Simulation
----------------
-
-Tools to generate simulation data.
diff --git a/examples/visualization/README.txt b/examples/visualization/README.txt
deleted file mode 100644
index 25af47af5..000000000
--- a/examples/visualization/README.txt
+++ /dev/null
@@ -1,5 +0,0 @@
-
-Visualization
--------------
-
-Looking at data and processing output.
diff --git a/examples/visualization/plot_evoked_erf_erp.py b/examples/visualization/plot_evoked_erf_erp.py
deleted file mode 100644
index db9f68b01..000000000
--- a/examples/visualization/plot_evoked_erf_erp.py
+++ /dev/null
@@ -1,48 +0,0 @@
-"""
-=================================
-Plotting ERF/ERP with evoked data
-=================================
-
-Load evoked data and plot.
-
-"""
-# Authors: Alexandre Gramfort <alexandre.gramfort@telecom-paristech.fr>
-#
-# License: BSD (3-clause)
-
-import matplotlib.pyplot as plt
-from mne.datasets import sample
-from mne import read_evokeds
-
-print(__doc__)
-
-path = sample.data_path()
-fname = path + '/MEG/sample/sample_audvis-ave.fif'
-
-# load evoked and subtract baseline
-condition = 'Left Auditory'
-evoked = read_evokeds(fname, condition=condition, baseline=(None, 0))
-
-evoked.plot()
-
-###############################################################################
-# Or plot manually after extracting peak latency
-
-evoked = evoked.pick_types(meg=False, eeg=True)
-times = 1e3 * evoked.times  # time in miliseconds
-
-ch_max_name, latency = evoked.get_peak(mode='neg')
-
-plt.figure()
-plt.plot(times, 1e6 * evoked.data.T, 'k-')
-plt.xlim([times[0], times[-1]])
-plt.xlabel('time (ms)')
-plt.ylabel('Potential (uV)')
-plt.title('EEG evoked potential')
-
-plt.axvline(latency * 1e3, color='red',
-            label=ch_max_name, linewidth=2,
-            linestyle='--')
-plt.legend(loc='best')
-
-plt.show()
diff --git a/mne/connectivity/spectral.py b/mne/connectivity/spectral.py
index a1bc27bce..5c0c7cbd5 100644
--- a/mne/connectivity/spectral.py
+++ b/mne/connectivity/spectral.py
@@ -539,8 +539,8 @@ def spectral_connectivity(data, method='coh', indices=None, sfreq=2 * np.pi,
     to compute the connectivity between the signal with index 0 and signals
     "2, 3, 4" (a total of 3 connections) one can use the following::
 
-        indices = (np.array([0, 0, 0]),    # row indices
-                   np.array([2, 3, 4]))    # col indices
+        indices = (np.array([0, 0, 0],    # row indices
+                   np.array([2, 3, 4])))  # col indices
 
         con_flat = spectral_connectivity(data, method='coh',
                                          indices=indices, ...)
diff --git a/mne/datasets/utils.py b/mne/datasets/utils.py
index e7745e3e7..be6f5fb0d 100644
--- a/mne/datasets/utils.py
+++ b/mne/datasets/utils.py
@@ -120,7 +120,7 @@ def _data_path(path=None, force_update=False, update_path=True, download=True,
         archive_name = "MNE-sample-data-processed.tar.gz"
         folder_name = "MNE-sample-data"
         url = "ftp://surfer.nmr.mgh.harvard.edu/pub/data/MNE/" + archive_name
-        hash_ = 'f73186795af820428e5e8e779ce5bfcf'
+        hash_ = '1bb9f993bfba2057e0039c306a717109'
     elif name == 'spm':
         archive_name = 'MNE-spm-face.tar.bz2'
         folder_name = "MNE-spm-face"
diff --git a/mne/decoding/time_gen.py b/mne/decoding/time_gen.py
index 9332ae63a..c6598c8b6 100644
--- a/mne/decoding/time_gen.py
+++ b/mne/decoding/time_gen.py
@@ -119,12 +119,8 @@ class GeneralizationAcrossTime(object):
         The categories used for training.
     estimators_ : list of list of sklearn.base.BaseEstimator subclasses.
         The estimators for each time point and each fold.
-    y_pred_ : list of lists of arrays of floats,
-              shape (n_train_times, n_test_times, n_epochs, n_prediction_dims)
-        The single-trial predictions estimated by self.predict() at each
-        training time and each testing time. Note that the number of testing
-        times per training time need not be regular, else
-        np.shape(y_pred_) = [n_train_time, n_test_time, n_epochs].
+    y_pred_ : np.ndarray, shape (n_train_times, n_test_times, n_epochs, n_prediction_dims)
+        Class labels for samples in X.
     scores_ : list of lists of float
         The scores estimated by self.scorer_ at each training time and each
         testing time (e.g. mean accuracy of self.predict(X)). Note that the
@@ -307,12 +303,9 @@ class GeneralizationAcrossTime(object):
 
         Returns
         -------
-        y_pred : list of lists of arrays of floats,
-                 shape (n_train_t, n_test_t, n_epochs, n_prediction_dims)
-            The single-trial predictions at each training time and each testing
-            time. Note that the number of testing times per training time need
-            not be regular;
-            else, np.shape(y_pred_) = [n_train_time, n_test_time, n_epochs].
+        y_pred_ : np.ndarray, shape (n_train_time, n_test_time, n_epochs,
+                               n_prediction_dim)
+            Class labels for samples in X.
         """
 
         # clean in case gat.predict() is called at unexpected moments
@@ -365,10 +358,12 @@ class GeneralizationAcrossTime(object):
         parallel, p_time_gen, _ = parallel_func(_predict_time_loop, n_jobs)
 
         # Loop across estimators (i.e. training times)
-        self.y_pred_ = parallel(p_time_gen(X, self.estimators_[t_train], cv,
-                                slices, self.predict_mode)
-                                for t_train, slices in
-                                enumerate(test_times_['slices']))
+        packed = parallel(p_time_gen(X, self.estimators_[t_train], cv,
+                          slices, self.predict_mode)
+                          for t_train, slices in
+                          enumerate(test_times_['slices']))
+
+        self.y_pred_ = np.transpose(tuple(zip(*packed)), (1, 0, 2, 3))
         return self.y_pred_
 
     def score(self, epochs=None, y=None, scorer=None, test_times=None):
@@ -463,7 +458,7 @@ class GeneralizationAcrossTime(object):
         self.y_true_ = y  # true regressor to be compared with y_pred
 
         # Preprocessing for parallelization:
-        n_jobs = min(len(self.y_pred_[0][0]), check_n_jobs(self.n_jobs))
+        n_jobs = min(self.y_pred_.shape[2], check_n_jobs(self.n_jobs))
         parallel, p_time_gen, n_jobs = parallel_func(_score_loop, n_jobs)
 
         # Score each training and testing time point
diff --git a/mne/forward/forward.py b/mne/forward/forward.py
index c41a70fce..abacd7091 100644
--- a/mne/forward/forward.py
+++ b/mne/forward/forward.py
@@ -1226,6 +1226,7 @@ def apply_forward_raw(fwd, stc, raw_template, start=None, stop=None,
     raw.info = _fill_measurement_info(raw.info, fwd, sfreq)
     raw.info['projs'] = []
     raw._projector = None
+    raw._update_times()
     return raw
 
 
diff --git a/mne/io/base.py b/mne/io/base.py
index 578109de7..a2ab5b8b1 100644
--- a/mne/io/base.py
+++ b/mne/io/base.py
@@ -233,7 +233,7 @@ class _BaseRaw(ProjMixin, ContainsMixin, PickDropChannelsMixin,
                                    'not %s' % preload.dtype)
             self._data = preload
             self.preload = True
-            self._last_samps = np.array([self._data.shape[1] - 1])
+            last_samps = [self._data.shape[1] - 1]
             load_from_disk = False
         else:
             if last_samps is None:
@@ -246,7 +246,8 @@ class _BaseRaw(ProjMixin, ContainsMixin, PickDropChannelsMixin,
                 raise ValueError('bad preload: %s' % preload)
             else:
                 load_from_disk = True
-            self._last_samps = np.array(last_samps)
+        self._last_samps = np.array(last_samps)
+        self._first_samps = np.array(first_samps)
         self.info = info
         cals = np.empty(info['nchan'])
         for k in range(info['nchan']):
@@ -257,13 +258,13 @@ class _BaseRaw(ProjMixin, ContainsMixin, PickDropChannelsMixin,
         self.comp = comp
         self._orig_comp_grade = orig_comp_grade
         self._filenames = list(filenames)
-        self._first_samps = np.array(first_samps)
         self.orig_format = orig_format
         self._projectors = list()
         self._projector = None
         # If we have True or a string, actually do the preloading
         if load_from_disk:
             self._preload_data(preload)
+        self._update_times()
 
     def _read_segment(start, stop, sel, data_buffer, projector, verbose):
         """Read a chunk of raw data
@@ -321,6 +322,12 @@ class _BaseRaw(ProjMixin, ContainsMixin, PickDropChannelsMixin,
         self.preload = True
         self.close()
 
+    def _update_times(self):
+        """Helper to update times"""
+        self._times = np.arange(self.n_times) / float(self.info['sfreq'])
+        # make it immutable
+        self._times.flags.writeable = False
+
     @property
     def first_samp(self):
         return self._first_samps[0]
@@ -868,6 +875,7 @@ class _BaseRaw(ProjMixin, ContainsMixin, PickDropChannelsMixin,
         # adjust affected variables
         self._data = np.concatenate(new_data, axis=1)
         self.info['sfreq'] = sfreq
+        self._update_times()
 
     def crop(self, tmin=0.0, tmax=None, copy=True):
         """Crop raw data file.
@@ -922,6 +930,7 @@ class _BaseRaw(ProjMixin, ContainsMixin, PickDropChannelsMixin,
         if raw.preload:
             # slice and copy to avoid the reference to large array
             raw._data = raw._data[:, smin:smax + 1].copy()
+        raw._update_times()
         return raw
 
     @verbose
@@ -1355,7 +1364,7 @@ class _BaseRaw(ProjMixin, ContainsMixin, PickDropChannelsMixin,
     @property
     def times(self):
         """Time points"""
-        return np.arange(self.n_times) / float(self.info['sfreq'])
+        return self._times
 
     @property
     def n_times(self):
@@ -1477,6 +1486,7 @@ class _BaseRaw(ProjMixin, ContainsMixin, PickDropChannelsMixin,
             self._last_samps = np.r_[self._last_samps, r._last_samps]
             self._rawdirs += r._rawdirs
             self._filenames += r._filenames
+        self._update_times()
 
     def close(self):
         """Clean up the object.
diff --git a/mne/io/kit/kit.py b/mne/io/kit/kit.py
index 447715681..8de71ac9a 100644
--- a/mne/io/kit/kit.py
+++ b/mne/io/kit/kit.py
@@ -114,8 +114,7 @@ class RawKIT(_BaseRaw):
     def __repr__(self):
         s = ('%r' % op.basename(self._kit_info['fname']),
              "n_channels x n_times : %s x %s" % (len(self.info['ch_names']),
-                                                 self.last_samp + 1 -
-                                                 self.first_samp))
+                                                 self._kit_info['n_samples']))
         return "<RawKIT  |  %s>" % ', '.join(s)
 
     def read_stim_ch(self, buffer_size=1e5):
@@ -495,7 +494,7 @@ def _set_dig_kit(mrk, elp, hsp, auto_decimate=True):
         hsp = _read_dig_points(hsp)
     n_pts = len(hsp)
     if n_pts > KIT.DIG_POINTS:
-        hsp = _decimate_points(hsp, res=5)
+        hsp = _decimate_points(hsp, decim=5)
         n_new = len(hsp)
         msg = ("The selected head shape contained {n_in} points, which is "
                "more than recommended ({n_rec}), and was automatically "
@@ -550,8 +549,6 @@ def get_kit_info(rawfile):
 
     Returns
     -------
-    info : instance of Info
-        An Info for the instance.
     sqd : dict
         A dict containing all the sqd parameter settings.
     """
@@ -679,7 +676,7 @@ def get_kit_info(rawfile):
         info['sfreq'] = float(sqd['sfreq'])
         info['bads'] = []
         info['acq_pars'], info['acq_stim'] = None, None
-        info['filename'] = rawfile
+        info['filename'] = None
         info['ctf_head_t'] = None
         info['dev_ctf_t'] = []
         info['nchan'] = sqd['nchan']
diff --git a/mne/preprocessing/ica.py b/mne/preprocessing/ica.py
index c7ba1ef94..1db0a2678 100644
--- a/mne/preprocessing/ica.py
+++ b/mne/preprocessing/ica.py
@@ -666,6 +666,7 @@ class ICA(ContainsMixin):
 
         out._projector = None
         self._export_info(out.info, raw, add_channels)
+        out._update_times()
 
         return out
 


Test patch:
diff --git a/mne/decoding/tests/test_time_gen.py b/mne/decoding/tests/test_time_gen.py
index c1a2328a5..16ef8c904 100644
--- a/mne/decoding/tests/test_time_gen.py
+++ b/mne/decoding/tests/test_time_gen.py
@@ -124,7 +124,7 @@ def test_generalization_across_time():
     # --- number of trials
     assert_true(gat.y_train_.shape[0] ==
                 gat.y_true_.shape[0] ==
-                len(gat.y_pred_[0][0]) == 14)
+                gat.y_pred_.shape[2] == 14)
     # ---  number of folds
     assert_true(np.shape(gat.estimators_)[1] == gat.cv)
     # ---  length training size
diff --git a/mne/realtime/tests/test_mockclient.py b/mne/realtime/tests/test_mockclient.py
index 631ca003e..a16217f45 100644
--- a/mne/realtime/tests/test_mockclient.py
+++ b/mne/realtime/tests/test_mockclient.py
@@ -86,6 +86,7 @@ def test_find_events():
     raw._data[stim_channel_idx, 520:530] = 6
     raw._data[stim_channel_idx, 530:532] = 5
     raw._data[stim_channel_idx, 540] = 6
+    raw._update_times()
 
     # consecutive=False
     find_events = dict(consecutive=False)
diff --git a/mne/tests/test_event.py b/mne/tests/test_event.py
index 2cde41291..8bffa5e7a 100644
--- a/mne/tests/test_event.py
+++ b/mne/tests/test_event.py
@@ -150,6 +150,7 @@ def test_find_events():
     # Reset some data for ease of comparison
     raw._first_samps[0] = 0
     raw.info['sfreq'] = 1000
+    raw._update_times()
 
     stim_channel = 'STI 014'
     stim_channel_idx = pick_channels(raw.info['ch_names'],