def test_inspect(tmp_path): """Test mne_bids inspect.""" # Check that help is printed check_usage(mne_bids_inspect) # Create test dataset. bids_root = str(tmp_path) data_path = testing.data_path() subject = '01' task = 'test' datatype = 'meg' raw_fname = op.join(data_path, 'MEG', 'sample', 'sample_audvis_trunc_raw.fif') raw = mne.io.read_raw(raw_fname) raw.info['line_freq'] = 60. bids_path = BIDSPath(subject=subject, task=task, datatype=datatype, root=bids_root) write_raw_bids(raw, bids_path, overwrite=True, verbose=False) import matplotlib matplotlib.use('agg') h_freqs = (30.0, 30, '30') for h_freq in h_freqs: args = ('--bids_root', bids_root, '--h_freq', h_freq, '--find_flat', 0) with ArgvSetter(args): mne_bids_inspect.run()
def test_flash_bem(tmpdir): """Test mne flash_bem.""" check_usage(mne_flash_bem, force_help=True) # Using the sample dataset subjects_dir = op.join(sample.data_path(download=False), 'subjects') # Copy necessary files to tempdir tempdir = str(tmpdir) mridata_path = op.join(subjects_dir, 'sample', 'mri') subject_path_new = op.join(tempdir, 'sample') mridata_path_new = op.join(subject_path_new, 'mri') os.makedirs(op.join(mridata_path_new, 'flash')) os.makedirs(op.join(subject_path_new, 'bem')) shutil.copyfile(op.join(mridata_path, 'T1.mgz'), op.join(mridata_path_new, 'T1.mgz')) shutil.copyfile(op.join(mridata_path, 'brain.mgz'), op.join(mridata_path_new, 'brain.mgz')) # Copy the available mri/flash/mef*.mgz files from the dataset flash_path = op.join(mridata_path_new, 'flash') for kind in (5, 30): in_fname = op.join(mridata_path, 'flash', 'mef%02d.mgz' % kind) shutil.copyfile(in_fname, op.join(flash_path, op.basename(in_fname))) # Test mne flash_bem with --noconvert option # (since there are no DICOM Flash images in dataset) out_fnames = list() for kind in ('outer_skin', 'outer_skull', 'inner_skull'): out_fnames.append(op.join(subject_path_new, 'bem', 'outer_skin.surf')) assert not any(op.isfile(out_fname) for out_fname in out_fnames) with ArgvSetter(('-d', tempdir, '-s', 'sample', '-n'), disable_stdout=False, disable_stderr=False): mne_flash_bem.run() # do they exist and are expected size for out_fname in out_fnames: _, tris = read_surface(out_fname) assert len(tris) == 5120
def test_flash_bem(): """Test mne flash_bem.""" check_usage(mne_flash_bem, force_help=True) # Using the sample dataset subjects_dir = op.join(sample.data_path(download=False), 'subjects') # Copy necessary files to tempdir tempdir = _TempDir() mridata_path = op.join(subjects_dir, 'sample', 'mri') mridata_path_new = op.join(tempdir, 'sample', 'mri') os.makedirs(op.join(mridata_path_new, 'flash')) os.makedirs(op.join(tempdir, 'sample', 'bem')) shutil.copyfile(op.join(mridata_path, 'T1.mgz'), op.join(mridata_path_new, 'T1.mgz')) shutil.copyfile(op.join(mridata_path, 'brain.mgz'), op.join(mridata_path_new, 'brain.mgz')) # Copy the available mri/flash/mef*.mgz files from the dataset files = glob.glob(op.join(mridata_path, 'flash', 'mef*.mgz')) for infile in files: shutil.copyfile( infile, op.join(mridata_path_new, 'flash', op.basename(infile))) # Test mne flash_bem with --noconvert option # (since there are no DICOM Flash images in dataset) currdir = os.getcwd() with ArgvSetter(('-d', tempdir, '-s', 'sample', '-n'), disable_stdout=False, disable_stderr=False): mne_flash_bem.run() os.chdir(currdir)
def test_watershed_bem(tmpdir): """Test mne watershed bem.""" check_usage(mne_watershed_bem) # Copy necessary files to tempdir tempdir = str(tmpdir) mridata_path = op.join(subjects_dir, 'sample', 'mri') subject_path_new = op.join(tempdir, 'sample') mridata_path_new = op.join(subject_path_new, 'mri') os.mkdir(op.join(tempdir, 'sample')) os.mkdir(mridata_path_new) if op.exists(op.join(mridata_path, 'T1')): shutil.copytree(op.join(mridata_path, 'T1'), op.join(mridata_path_new, 'T1')) if op.exists(op.join(mridata_path, 'T1.mgz')): shutil.copyfile(op.join(mridata_path, 'T1.mgz'), op.join(mridata_path_new, 'T1.mgz')) out_fnames = list() for kind in ('outer_skin', 'outer_skull', 'inner_skull'): out_fnames.append(op.join(subject_path_new, 'bem', 'inner_skull.surf')) assert not any(op.isfile(out_fname) for out_fname in out_fnames) with ArgvSetter(('-d', tempdir, '-s', 'sample', '-o'), disable_stdout=False, disable_stderr=False): mne_watershed_bem.run() for out_fname in out_fnames: _, tris = read_surface(out_fname) assert len(tris) == 20480
def _test_fetch(url): """Helper to test URL retrieval.""" tempdir = _TempDir() with ArgvSetter(disable_stderr=False): # to capture stdout archive_name = op.join(tempdir, "download_test") _fetch_file(url, archive_name, timeout=30., verbose=False, resume=False) assert_raises(Exception, _fetch_file, 'NOT_AN_ADDRESS', op.join(tempdir, 'test'), verbose=False) resume_name = op.join(tempdir, "download_resume") # touch file with open(resume_name + '.part', 'w'): os.utime(resume_name + '.part', None) _fetch_file(url, resume_name, resume=True, timeout=30., verbose=False) assert_raises(ValueError, _fetch_file, url, archive_name, hash_='a', verbose=False) assert_raises(RuntimeError, _fetch_file, url, archive_name, hash_='a' * 32, verbose=False)
def test_make_scalp_surfaces(): """Test mne make_scalp_surfaces""" check_usage(mne_make_scalp_surfaces) # Copy necessary files to avoid FreeSurfer call tempdir = _TempDir() surf_path = op.join(subjects_dir, 'sample', 'surf') surf_path_new = op.join(tempdir, 'sample', 'surf') os.mkdir(op.join(tempdir, 'sample')) os.mkdir(surf_path_new) os.mkdir(op.join(tempdir, 'sample', 'bem')) shutil.copy(op.join(surf_path, 'lh.seghead'), surf_path_new) orig_fs = os.getenv('FREESURFER_HOME', None) orig_mne = os.getenv('MNE_ROOT') if orig_fs is not None: del os.environ['FREESURFER_HOME'] cmd = ('-s', 'sample', '--subjects-dir', tempdir) os.environ['_MNE_TESTING_SCALP'] = 'true' try: with ArgvSetter(cmd, disable_stdout=False, disable_stderr=False): assert_raises(RuntimeError, mne_make_scalp_surfaces.run) os.environ['FREESURFER_HOME'] = tempdir # don't need it del os.environ['MNE_ROOT'] assert_raises(RuntimeError, mne_make_scalp_surfaces.run) os.environ['MNE_ROOT'] = orig_mne mne_make_scalp_surfaces.run() assert_raises(IOError, mne_make_scalp_surfaces.run) # no overwrite finally: if orig_fs is not None: os.environ['FREESURFER_HOME'] = orig_fs os.environ['MNE_ROOT'] = orig_mne del os.environ['_MNE_TESTING_SCALP']
def test_fetch_file(): """Test file downloading """ tempdir = _TempDir() urls = [ 'http://martinos.org/mne/', 'ftp://surfer.nmr.mgh.harvard.edu/pub/data/bert.recon.md5sum.txt' ] with ArgvSetter(disable_stderr=False): # to capture stdout for url in urls: archive_name = op.join(tempdir, "download_test") _fetch_file(url, archive_name, verbose=False) assert_raises(Exception, _fetch_file, 'NOT_AN_ADDRESS', op.join(tempdir, 'test'), verbose=False) resume_name = op.join(tempdir, "download_resume") # touch file with open(resume_name + '.part', 'w'): os.utime(resume_name + '.part', None) _fetch_file(url, resume_name, resume=True, verbose=False) assert_raises(ValueError, _fetch_file, url, archive_name, hash_='a', verbose=False) assert_raises(RuntimeError, _fetch_file, url, archive_name, hash_='a' * 32, verbose=False)
def test_raw_to_bids(tmpdir): """Test mne_bids raw_to_bids.""" output_path = str(tmpdir) data_path = testing.data_path() raw_fname = op.join(data_path, 'MEG', 'sample', 'sample_audvis_trunc_raw.fif') # Check that help is printed check_usage(mne_bids_raw_to_bids) # Should work with ArgvSetter(('--subject_id', subject_id, '--task', task, '--raw', raw_fname, '--bids_root', output_path)): mne_bids_raw_to_bids.run() # Too few input args with pytest.raises(SystemExit): with ArgvSetter(('--subject_id', subject_id)): mne_bids_cp.run()
def check_usage(module, force_help=False): """Helper to ensure we print usage""" args = ('--help', ) if force_help else () with ArgvSetter(args) as out: try: module.run() except SystemExit: pass assert_true('Usage: ' in out.stdout.getvalue())
def test_cp(tmp_path): """Test mne_bids cp.""" output_path = str(tmp_path) data_path = op.join(base_path, 'brainvision', 'tests', 'data') raw_fname = op.join(data_path, 'test.vhdr') outname = op.join(output_path, 'test2.vhdr') # Check that help is printed check_usage(mne_bids_cp) # Should work with ArgvSetter(('--input', raw_fname, '--output', outname)): mne_bids_cp.run() # Too few input args with pytest.raises(SystemExit): with ArgvSetter(('--input', raw_fname)): mne_bids_cp.run()
def test_anonymize(tmp_path): """Test mne anonymize.""" check_usage(mne_anonymize) out_fname = op.join(tmp_path, 'anon_test_raw.fif') with ArgvSetter(('-f', raw_fname, '-o', out_fname)): mne_anonymize.run() info = read_info(out_fname) assert (op.exists(out_fname)) assert info['meas_date'] == _stamp_to_dt((946684800, 0))
def test_raw_to_bids(): """Test mne_bids raw_to_bids.""" output_path = _TempDir() data_path = testing.data_path() raw_fname = op.join(data_path, 'MEG', 'sample', 'sample_audvis_trunc_raw.fif') # check_usage(mne_bids_raw_to_bids) with ArgvSetter(('--subject_id', subject_id, '--task', task, '--raw', raw_fname, '--output_path', output_path)): mne_bids_raw_to_bids.run()
def generate_commands_rst(app=None): from sphinx_gallery import sphinx_compatibility out_dir = op.abspath(op.join(op.dirname(__file__), '..', 'generated')) if not op.isdir(out_dir): os.mkdir(out_dir) out_fname = op.join(out_dir, 'commands.rst.new') command_path = op.abspath( op.join(os.path.dirname(__file__), '..', '..', 'mne', 'commands')) fnames = sorted([ op.basename(fname) for fname in glob.glob(op.join(command_path, 'mne_*.py')) ]) iterator = sphinx_compatibility.status_iterator( fnames, 'generating MNE command help ... ', length=len(fnames)) with open(out_fname, 'w', encoding='utf8') as f: f.write(header) for fname in iterator: cmd_name = fname[:-3] module = import_module('.' + cmd_name, 'mne.commands') with ArgvSetter(('mne', cmd_name, '--help')) as out: try: module.run() except SystemExit: # this is how these terminate pass output = out.stdout.getvalue().splitlines() # Swap usage and title lines output[0], output[2] = output[2], output[0] # Add header marking for idx in (1, 0): output.insert(idx, '-' * len(output[0])) # Add code styling for the "Usage: " line for li, line in enumerate(output): if line.startswith('Usage: mne '): output[li] = 'Usage: ``%s``' % line[7:] break # Turn "Options:" into field list if 'Options:' in output: ii = output.index('Options:') output[ii] = 'Options' output.insert(ii + 1, '-------') output.insert(ii + 2, '') output.insert(ii + 3, '.. rst-class:: field-list cmd-list') output.insert(ii + 4, '') output = '\n'.join(output) cmd_name_space = cmd_name.replace('mne_', 'mne ') f.write( command_rst.format(cmd_name_space, '=' * len(cmd_name_space), output)) _replace_md5(out_fname)
def test_report(): """Test mne report.""" check_usage(mne_report) tempdir = _TempDir() use_fname = op.join(tempdir, op.basename(raw_fname)) shutil.copyfile(raw_fname, use_fname) with ArgvSetter(('-p', tempdir, '-i', use_fname, '-d', subjects_dir, '-s', 'sample', '--no-browser', '-m', '30')): mne_report.run() fnames = glob.glob(op.join(tempdir, '*.html')) assert_true(len(fnames) == 1)
def test_mne_prepare_bem_model(tmp_path): """Test mne setup_source_space.""" check_usage(mne_prepare_bem_model, force_help=True) # Using the sample dataset bem_solution_fname = op.join(tmp_path, "bem_solution-bem-sol.fif") # Test command with ArgvSetter( ('--bem', bem_model_fname, '--sol', bem_solution_fname, '--verbose')): mne_prepare_bem_model.run() bem_solution = read_bem_solution(bem_solution_fname) assert isinstance(bem_solution, ConductorModel)
def test_count_events(tmp_path): """Test mne_bids count_events.""" # Check that help is printed check_usage(mne_bids_count_events) # Create test dataset. output_path = str(tmp_path) data_path = testing.data_path() raw_fname = op.join(data_path, 'MEG', 'sample', 'sample_audvis_trunc_raw.fif') raw = mne.io.read_raw(raw_fname) raw.info['line_freq'] = 60. events = mne.find_events(raw) event_id = {'auditory/left': 1, 'auditory/right': 2, 'visual/left': 3, 'visual/right': 4, 'face': 5, 'button': 32} bids_path = BIDSPath(subject='01', root=output_path, task='foo') write_raw_bids(raw, bids_path, events, event_id, overwrite=True, verbose=False) with ArgvSetter(('--bids_root', output_path)): mne_bids_count_events.run() with ArgvSetter(('--bids_root', output_path, '--describe')): mne_bids_count_events.run() with ArgvSetter(('--bids_root', output_path, '--silent')): mne_bids_count_events.run() with ArgvSetter(('--bids_root', output_path, '--output', str(Path(output_path) / 'counts.csv'))): mne_bids_count_events.run() with ArgvSetter( ('--bids_root', output_path, '--output', str(Path(output_path) / 'counts.csv'), '--overwrite') ): mne_bids_count_events.run()
def test_report(tmpdir): """Test mne report.""" check_usage(mne_report) tempdir = str(tmpdir) use_fname = op.join(tempdir, op.basename(raw_fname)) shutil.copyfile(raw_fname, use_fname) with ArgvSetter(('-p', tempdir, '-i', use_fname, '-d', subjects_dir, '-s', 'sample', '--no-browser', '-m', '30')): with pytest.warns(None): # contour levels mne_report.run() fnames = glob.glob(op.join(tempdir, '*.html')) assert len(fnames) == 1
def test_setup_forward_model(tmpdir): """Test mne setup_source_space.""" check_usage(mne_setup_forward_model, force_help=True) # Using the sample dataset subjects_dir = op.join(testing.data_path(download=False), 'subjects') use_fname = op.join(tmpdir, "model-bem.fif") # Test command with ArgvSetter(('--model', use_fname, '-d', subjects_dir, '-s', 'sample', '--ico', '3', '--verbose')): mne_setup_forward_model.run() model = read_bem_surfaces(use_fname) assert len(model) == 3
def test_mark_bad_chanels_multiple_files(tmp_path): """Test mne_bids mark_channels.""" # Check that help is printed check_usage(mne_bids_mark_channels) # Create test dataset. output_path = str(tmp_path) data_path = testing.data_path() raw_fname = op.join(data_path, 'MEG', 'sample', 'sample_audvis_trunc_raw.fif') old_bads = mne.io.read_raw_fif(raw_fname).info['bads'] bids_path = BIDSPath(task=task, root=output_path, datatype=datatype) subjects = ['01', '02', '03'] for subject in subjects: with ArgvSetter(('--subject_id', subject, '--task', task, '--raw', raw_fname, '--bids_root', output_path, '--line_freq', 60)): mne_bids_raw_to_bids.run() # Update the dataset. ch_names = ['MEG 0112', 'MEG 0131'] descriptions = ['Really bad!', 'Even worse.'] args = ['--task', task, '--bids_root', output_path, '--type', datatype] for ch_name, description in zip(ch_names, descriptions): args.extend(['--ch_name', ch_name]) args.extend(['--description', description]) args = tuple(args) with ArgvSetter(args): mne_bids_mark_channels.run() # Check the data was properly written for subject in subjects: with pytest.warns(RuntimeWarning, match='The unit for chann*'): raw = read_raw_bids(bids_path=bids_path.copy() .update(subject=subject)) assert set(old_bads + ch_names) == set(raw.info['bads'])
def test_setup_forward_model(tmp_path): """Test mne setup_forward_model.""" check_usage(mne_setup_forward_model, force_help=True) # Using the sample dataset use_fname = op.join(tmp_path, "model-bem.fif") # Test command with ArgvSetter(('--model', use_fname, '-d', subjects_dir, '--homog', '-s', 'sample', '--ico', '3', '--verbose')): mne_setup_forward_model.run() model = read_bem_surfaces(use_fname) assert len(model) == 1 sol_fname = op.splitext(use_fname)[0] + '-sol.fif' read_bem_solution(sol_fname)
def test_mne_prepare_bem_model(tmpdir): """Test mne setup_source_space.""" check_usage(mne_prepare_bem_model, force_help=True) # Using the sample dataset bem_model_fname = op.join(testing.data_path(download=False), 'subjects', 'sample', 'bem', 'sample-320-320-320-bem.fif') bem_solution_fname = op.join(tmpdir, "bem_solution-bem-sol.fif") # Test command with ArgvSetter( ('--bem', bem_model_fname, '--sol', bem_solution_fname, '--verbose')): mne_prepare_bem_model.run() bem_solution = read_bem_solution(bem_solution_fname) assert isinstance(bem_solution, ConductorModel)
def test_report(tmp_path): """Test mne report.""" pytest.importorskip('nibabel') check_usage(mne_report) tempdir = str(tmp_path) use_fname = op.join(tempdir, op.basename(raw_fname)) shutil.copyfile(raw_fname, use_fname) with ArgvSetter(('-p', tempdir, '-i', use_fname, '-d', subjects_dir, '-s', 'sample', '--no-browser', '-m', '30')): with _record_warnings(): # contour levels mne_report.run() fnames = glob.glob(op.join(tempdir, '*.html')) assert len(fnames) == 1
def test_maxfilter(): """Test mne maxfilter.""" check_usage(mne_maxfilter) with ArgvSetter(('-i', raw_fname, '--st', '--movecomp', '--linefreq', '60', '--trans', raw_fname)) as out: with pytest.warns(RuntimeWarning, match="Don't use"): os.environ['_MNE_MAXFILTER_TEST'] = 'true' try: mne_maxfilter.run() finally: del os.environ['_MNE_MAXFILTER_TEST'] for check in ('maxfilter', '-trans', '-movecomp'): assert check in out.stdout.getvalue(), check
def test_watershed_bem(tmp_path): """Test mne watershed bem.""" check_usage(mne_watershed_bem) # from T1.mgz Mdc = np.array([[-1, 0, 0], [0, 0, -1], [0, 1, 0]]) Pxyz_c = np.array([-5.273613, 9.039085, -27.287964]) # Copy necessary files to tempdir tempdir = str(tmp_path) mridata_path = op.join(subjects_dir, 'sample', 'mri') subject_path_new = op.join(tempdir, 'sample') mridata_path_new = op.join(subject_path_new, 'mri') os.makedirs(mridata_path_new) new_fname = op.join(mridata_path_new, 'T1.mgz') shutil.copyfile(op.join(mridata_path, 'T1.mgz'), new_fname) old_mode = os.stat(new_fname).st_mode os.chmod(new_fname, 0) args = ('-d', tempdir, '-s', 'sample', '-o') with pytest.raises(PermissionError, match=r'read permissions.*T1\.mgz'): with ArgvSetter(args): mne_watershed_bem.run() os.chmod(new_fname, old_mode) for s in ('outer_skin', 'outer_skull', 'inner_skull'): assert not op.isfile(op.join(subject_path_new, 'bem', '%s.surf' % s)) with ArgvSetter(args): mne_watershed_bem.run() kwargs = dict(rtol=1e-5, atol=1e-5) for s in ('outer_skin', 'outer_skull', 'inner_skull'): rr, tris, vol_info = read_surface(op.join(subject_path_new, 'bem', '%s.surf' % s), read_metadata=True) assert_equal(len(tris), 20480) assert_equal(tris.min(), 0) assert_equal(rr.shape[0], tris.max() + 1) # compare the volume info to the mgz header assert_allclose(vol_info['xras'], Mdc[0], **kwargs) assert_allclose(vol_info['yras'], Mdc[1], **kwargs) assert_allclose(vol_info['zras'], Mdc[2], **kwargs) assert_allclose(vol_info['cras'], Pxyz_c, **kwargs)
def test_clean_eog_ecg(): """Test mne clean_eog_ecg""" check_usage(mne_clean_eog_ecg) tempdir = _TempDir() raw = concatenate_raws([Raw(f) for f in [raw_fname, raw_fname, raw_fname]]) raw.info['bads'] = ['MEG 2443'] use_fname = op.join(tempdir, op.basename(raw_fname)) raw.save(use_fname) with ArgvSetter(('-i', use_fname, '--quiet')): mne_clean_eog_ecg.run() fnames = glob.glob(op.join(tempdir, '*proj.fif')) assert_true(len(fnames) == 2) # two projs fnames = glob.glob(op.join(tempdir, '*-eve.fif')) assert_true(len(fnames) == 3) # raw plus two projs
def test_clean_eog_ecg(tmpdir): """Test mne clean_eog_ecg.""" check_usage(mne_clean_eog_ecg) tempdir = str(tmpdir) raw = concatenate_raws([read_raw_fif(f) for f in [raw_fname, raw_fname, raw_fname]]) raw.info['bads'] = ['MEG 2443'] use_fname = op.join(tempdir, op.basename(raw_fname)) raw.save(use_fname) with ArgvSetter(('-i', use_fname, '--quiet')): mne_clean_eog_ecg.run() for key, count in (('proj', 2), ('-eve', 3)): fnames = glob.glob(op.join(tempdir, '*%s.fif' % key)) assert len(fnames) == count
def test_maxfilter(): """Test mne maxfilter.""" check_usage(mne_maxfilter) with ArgvSetter(('-i', raw_fname, '--st', '--movecomp', '--linefreq', '60', '--trans', raw_fname)) as out: with warnings.catch_warnings(record=True) as w: warnings.simplefilter('always') os.environ['_MNE_MAXFILTER_TEST'] = 'true' try: mne_maxfilter.run() finally: del os.environ['_MNE_MAXFILTER_TEST'] assert_true(len(w) == 1) for check in ('maxfilter', '-trans', '-movecomp'): assert_true(check in out.stdout.getvalue(), check)
def test_compute_proj_exg(tmpdir, fun): """Test mne compute_proj_ecg/eog.""" check_usage(fun) tempdir = str(tmpdir) use_fname = op.join(tempdir, op.basename(raw_fname)) bad_fname = op.join(tempdir, 'bads.txt') with open(bad_fname, 'w') as fid: fid.write('MEG 2443\n') shutil.copyfile(raw_fname, use_fname) with ArgvSetter(('-i', use_fname, '--bad=' + bad_fname, '--rej-eeg', '150')): with pytest.warns(None): # samples, sometimes fun.run() fnames = glob.glob(op.join(tempdir, '*proj.fif')) assert len(fnames) == 1 fnames = glob.glob(op.join(tempdir, '*-eve.fif')) assert len(fnames) == 1
def test_compute_proj_ecg_eog(): """Test mne compute_proj_ecg/eog""" for fun in (mne_compute_proj_ecg, mne_compute_proj_eog): check_usage(fun) tempdir = _TempDir() use_fname = op.join(tempdir, op.basename(raw_fname)) bad_fname = op.join(tempdir, 'bads.txt') with open(bad_fname, 'w') as fid: fid.write('MEG 2443\n') shutil.copyfile(raw_fname, use_fname) with ArgvSetter( ('-i', use_fname, '--bad=' + bad_fname, '--rej-eeg', '150')): fun.run() fnames = glob.glob(op.join(tempdir, '*proj.fif')) assert_true(len(fnames) == 1) fnames = glob.glob(op.join(tempdir, '*-eve.fif')) assert_true(len(fnames) == 1)
def test_crosstalk_to_bids(tmp_path): """Test mne_bids crosstalk_to_bids.""" # Check that help is printed check_usage(mne_bids_crosstalk_to_bids) output_path = str(tmp_path) data_path = Path(testing.data_path()) crosstalk_fname = data_path / 'SSS' / 'ct_sparse.fif' bids_path = BIDSPath(subject=subject_id, root=output_path) # Write fine-calibration file and check that it was actually written. # Write fine-calibration file and check that it was actually written. args = ('--file', crosstalk_fname, '--subject', subject_id, '--bids_root', output_path) with ArgvSetter(args): mne_bids_crosstalk_to_bids.run() assert bids_path.meg_crosstalk_fpath.exists()