#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Fri Apr 3 14:29:04 2020 @author: lau """ from os import chdir from os.path import join import mne from mne.datasets import somato print(mne.__version__) ## 0.20.0 data_path = somato.data_path() load_path = join(data_path, 'sub-01', 'meg') save_path = join(data_path, 'derivatives', 'sub-01') chdir(load_path) raw = mne.io.read_raw_fif('sub-01_task-somato_meg.fif', preload=True) events = mne.find_events(raw) raw_hilbert = raw.copy() raw_hilbert.filter(8, 12) raw_hilbert.apply_hilbert() event_id, tmin, tmax = 1, -.2, 2 baseline = (-.2, -0.05) epochs_hilbert = mne.Epochs(raw_hilbert, events, event_id, tmin, tmax, baseline) print('Original has right dtype') print(epochs_hilbert.get_data().dtype) ## complex128 ## now checking when loading them again single_name = join(save_path, 'hilbert_single-epo.fif') double_name = join(save_path, 'hilbert_double-epo.fif') epochs_hilbert.save(single_name, fmt='single', overwrite=True) epochs_hilbert.save(double_name, fmt='double', overwrite=True) epochs_hilbert_read_single = mne.read_epochs(single_name, preload=True) epochs_hilbert_read_double = mne.read_epochs(double_name, preload=True) print('With preload=True') print(epochs_hilbert_read_single.get_data().dtype) ## complex128 print(epochs_hilbert_read_double.get_data().dtype) ## complex128 epochs_hilbert_read_single = mne.read_epochs(single_name, preload=False) epochs_hilbert_read_double = mne.read_epochs(double_name, preload=False) print('With preload=False') print(epochs_hilbert_read_single.get_data().dtype) ## float64 print(epochs_hilbert_read_double.get_data().dtype) ## float64