def copyfile_kit(src, dest, subject_id, session_id, task, run, _init_kwargs): """Copy and rename KIT files to a new location. Parameters ---------- src : str Path to the source raw .con or .sqd folder. dest : str Path to the destination of the new bids folder. subject_id : str | None The subject ID. Corresponds to "sub". session_id : str | None The session identifier. Corresponds to "ses". task : str | None The task identifier. Corresponds to "task". run : int | None The run number. Corresponds to "run". _init_kwargs : dict Extract information of marker and headpoints """ # create parent directories in case it does not exist yet _mkdir_p(op.dirname(dest)) # KIT data requires the marker file to be copied over too sh.copyfile(src, dest) data_path = op.split(dest)[0] datatype = 'meg' if 'mrk' in _init_kwargs: hpi = _init_kwargs['mrk'] acq_map = dict() if isinstance(hpi, list): if _get_mrk_meas_date(hpi[0]) > _get_mrk_meas_date(hpi[1]): raise ValueError('Markers provided in incorrect order.') _, marker_ext = _parse_ext(hpi[0]) acq_map = dict(zip(['pre', 'post'], hpi)) else: _, marker_ext = _parse_ext(hpi) acq_map[None] = hpi for key, value in acq_map.items(): marker_path = BIDSPath( subject=subject_id, session=session_id, task=task, run=run, acquisition=key, suffix='markers', extension=marker_ext, datatype=datatype) sh.copyfile(value, op.join(data_path, marker_path.basename)) for acq in ['elp', 'hsp']: if acq in _init_kwargs: position_file = _init_kwargs[acq] task, run, acq = None, None, acq.upper() position_ext = '.pos' position_path = BIDSPath( subject=subject_id, session=session_id, task=task, run=run, acquisition=acq, suffix='headshape', extension=position_ext, datatype=datatype) sh.copyfile(position_file, op.join(data_path, position_path.basename))
def _get_sidecar_json_update_file(_get_bids_test_dir): """Return path to a sidecar JSON updating file.""" bids_root = _get_bids_test_dir sample_scripts = op.join(bids_root, 'sourcedata') sidecar_fpath = op.join(sample_scripts, 'sidecarjson_update.json') _mkdir_p(sample_scripts) update_json = { 'InstitutionName': 'mne-bids', 'InstitutionAddress': 'Internet', 'MEGChannelCount': 300, 'MEGREFChannelCount': 6, 'SEEGChannelCount': 0, } _write_json(sidecar_fpath, update_json, overwrite=True) return sidecar_fpath