def _get_bf_data(save_fieldtrip=False): raw, epochs, evoked, data_cov, _, _, _, _, _, fwd = _get_data(proj=False) if save_fieldtrip is True: # raw needs to be saved with all channels and picked in FieldTrip raw.save(op.join(ft_data_path, 'raw.fif'), overwrite=True) # src (tris are not available in fwd['src'] once imported into MATLAB) src = fwd['src'].copy() mne.write_source_spaces(op.join(ft_data_path, 'src.fif'), src) # pick gradiometers only: epochs.pick_types(meg='grad') evoked.pick_types(meg='grad') # compute covariance matrix data_cov = mne.compute_covariance(epochs, tmin=0.04, tmax=0.145, method='empirical') if save_fieldtrip is True: # if the covariance matrix and epochs need resaving: # data covariance: cov_savepath = op.join(ft_data_path, 'sample_cov') sample_cov = {'sample_cov': data_cov['data']} savemat(cov_savepath, sample_cov) # evoked data: ev_savepath = op.join(ft_data_path, 'sample_evoked') data_ev = {'sample_evoked': evoked.data} savemat(ev_savepath, data_ev) return evoked, data_cov, fwd
def _get_bf_data(save_fieldtrip=False): raw, epochs, evoked, data_cov, _, _, _, _, _, fwd = _get_data(proj=False) if save_fieldtrip is True: # raw needs to be saved with all channels and picked in FieldTrip raw.save(op.join(ft_data_path, 'raw.fif'), overwrite=True) # src (tris are not available in fwd['src'] once imported into MATLAB) src = fwd['src'].copy() mne.write_source_spaces(op.join(ft_data_path, 'src.fif'), src) # pick gradiometers only: epochs.pick_types(meg='grad') evoked.pick_types(meg='grad') # compute covariance matrix data_cov = mne.compute_covariance(epochs, tmin=0.04, tmax=0.145, method='empirical') if save_fieldtrip is True: # if the covariance matrix and epochs need resaving: # data covariance: cov_savepath = op.join(ft_data_path, 'sample_cov') sample_cov = {'sample_cov': data_cov['data']} savemat(cov_savepath, sample_cov) # evoked data: ev_savepath = op.join(ft_data_path, 'sample_evoked') data_ev = {'sample_evoked': evoked.data} savemat(ev_savepath, data_ev) return evoked, data_cov, fwd