parser.add_argument("set", type=int) parser.add_argument("time1", type=float) parser.add_argument("time2", type=float) args = parser.parse_args() ##script for creating average field map data_path = "/home/custine/MEG/data/krns_kr3/9367/s5/" evoked_fname = data_path + "ave_projon/9367_s5_Noun_Place_All-ave.fif" subjects_dir = "/mnt/file1/binder/KRNS/anatomies/surfaces/" trans_fname = "/mnt/file1/binder/KRNS/anatomies/surfaces/9367/mri/T1-neuromag/sets/COR-custine-140827-120918.fif" # If trans_fname is set to None then only MEG estimates can be visualized condition = 1 evoked = read_evoked(evoked_fname, baseline=(-0.2, 0.0)) # Compute the field maps to project MEG and EEG data to MEG helmet # and scalp surface maps = make_field_map(evoked, trans_fname=trans_fname, subject="9367", subjects_dir=subjects_dir, n_jobs=1) # explore several points in time [evoked.plot_field(maps, time=time) for time in [0.09, 0.11]] evoked.save( "/home/custine/MEG/data/krns_kr3/9367/s5/results/fieldmaps/9367_s5_" + str(args.ave_name) + "_All-" + "-" + str(args.time1) + "-"
np.mean(np.power( epochs2.get_data()[:, channelIDs, 500:3500], 2), axis=1)) else: data1 = np.mean(epochs1.get_data()[:, channelIDs, 500:3500], axis=1) data2 = np.mean(epochs2.get_data()[:, channelIDs, 500:3500], axis=1) #sprint data1.shape # trials x samples condition1[region].append(data1) condition2[region].append(data2) else: epochs1 = mne.read_evoked(fname=data_path + '/dh53a/Obj_average-ave.fif') # concatenate subject-specific trials for region in regions: tFilename = '{}{}-{}-{}-T_obs.pickle'.format( statsPath, groupNames[groupID], sensor, region) clusterFilename = '{}{}-{}-{}-clusters.pickle'.format( statsPath, groupNames[groupID], sensor, region) pFilename = '{}{}-{}-{}-cluster_p_values.pickle'.format( statsPath, groupNames[groupID], sensor, region) hFilename = '{}{}-{}-{}-H0.pickle'.format(statsPath, groupNames[groupID], sensor, region) diffFilename = '{}{}-{}-{}-diff.pickle'.format( statsPath, groupNames[groupID], sensor, region) if not allFilesExist:
def test_io_evoked(): """Test IO for evoked data (fif + gz) with integer and str args """ ave = read_evokeds(fname, 0) write_evokeds(op.join(tempdir, 'evoked-ave.fif'), ave) ave2 = read_evokeds(op.join(tempdir, 'evoked-ave.fif'))[0] # This not being assert_array_equal due to windows rounding assert_true(np.allclose(ave.data, ave2.data, atol=1e-16, rtol=1e-3)) assert_array_almost_equal(ave.times, ave2.times) assert_equal(ave.nave, ave2.nave) assert_equal(ave._aspect_kind, ave2._aspect_kind) assert_equal(ave.kind, ave2.kind) assert_equal(ave.last, ave2.last) assert_equal(ave.first, ave2.first) # test compressed i/o ave2 = read_evokeds(fname_gz, 0) assert_true(np.allclose(ave.data, ave2.data, atol=1e-16, rtol=1e-8)) # test str access condition = 'Left Auditory' assert_raises(ValueError, read_evokeds, fname, condition, kind='stderr') assert_raises(ValueError, read_evokeds, fname, condition, kind='standard_error') ave3 = read_evokeds(fname, condition) assert_array_almost_equal(ave.data, ave3.data, 19) # test deprecation warning for read_evoked and write_evoked # XXX should be deleted for 0.9 release with warnings.catch_warnings(record=True) as w: warnings.simplefilter('always') ave = read_evoked(fname, setno=0) assert_true(w[0].category == DeprecationWarning) with warnings.catch_warnings(record=True) as w: warnings.simplefilter('always') write_evoked(op.join(tempdir, 'evoked-ave.fif'), ave) assert_true(w[0].category == DeprecationWarning) # test read_evokeds and write_evokeds types = ['Left Auditory', 'Right Auditory', 'Left visual', 'Right visual'] aves1 = read_evokeds(fname) aves2 = read_evokeds(fname, [0, 1, 2, 3]) aves3 = read_evokeds(fname, types) write_evokeds(op.join(tempdir, 'evoked-ave.fif'), aves1) aves4 = read_evokeds(op.join(tempdir, 'evoked-ave.fif')) for aves in [aves2, aves3, aves4]: for [av1, av2] in zip(aves1, aves): assert_array_almost_equal(av1.data, av2.data) assert_array_almost_equal(av1.times, av2.times) assert_equal(av1.nave, av2.nave) assert_equal(av1.kind, av2.kind) assert_equal(av1._aspect_kind, av2._aspect_kind) assert_equal(av1.last, av2.last) assert_equal(av1.first, av2.first) assert_equal(av1.comment, av2.comment) # test warnings on bad filenames with warnings.catch_warnings(record=True) as w: warnings.simplefilter('always') fname2 = op.join(tempdir, 'test-bad-name.fif') write_evokeds(fname2, ave) read_evokeds(fname2) assert_true(len(w) == 2)