mne_bids/write.py
def _participants_json(fname, overwrite=False):
    """Create participants.json for non-default columns in accompanying TSV.

    Parameters
    ----------
    fname : str | mne_bids.BIDSPath
        Filename to save the scans.tsv to.
    overwrite : bool
        Defaults to False.
        Whether to overwrite the existing data in the file.
        If there is already data for the given `fname` and overwrite is False,
        an error will be raised.

    """
    cols = OrderedDict()
    cols['participant_id'] = {'Description': 'Unique participant identifier'}
    cols['age'] = {'Description': 'Age of the participant at time of testing',
                   'Units': 'years'}
    cols['sex'] = {'Description': 'Biological sex of the participant',
                   'Levels': {'F': 'female', 'M': 'male'}}
    cols['hand'] = {'Description': 'Handedness of the participant',
                    'Levels': {'R': 'right', 'L': 'left', 'A': 'ambidextrous'}}

    # make sure to append any JSON fields added by the user
    # Note: mne-bids will overwrite age, sex and hand fields
    # if `overwrite` is True
    if op.exists(fname):
        with open(fname, 'r', encoding='utf-8-sig') as fin:
            orig_cols = json.load(fin, object_pairs_hook=OrderedDict)
        for key, val in orig_cols.items():
            if key not in cols:
                cols[key] = val

    _write_json(fname, cols, overwrite)
Create participants.json for non-default columns in accompanying TSV.

    Parameters
    ----------
    fname : str | mne_bids.BIDSPath
        Filename to save the scans.tsv to.
    overwrite : bool
        Defaults to False.
        Whether to overwrite the existing data in the file.
        If there is already data for the given `fname` and overwrite is False,
        an error will be raised.

    
Create participants.json for non-default columns in accompanying TSV.
Parameters

fname : str | mne_bids.BIDSPath
Filename to save the scans.tsv to.
overwrite : bool
Defaults to False.
Whether to overwrite the existing data in the file.
If there is already data for the given `fname` and overwrite is False,
an error will be raised.
Create participants . json for non - default columns in accompanying TSV . Parameters fname : str | mne_bids . BIDSPath Filename to save the scans . tsv to . overwrite : bool Defaults to False . Whether to overwrite the existing data in the file . If there is already data for the given ` fname ` and overwrite is False an error will be raised .
def _participants_json(fname, overwrite=False):
    cols = OrderedDict()
    cols['participant_id'] = {'Description': 'Unique participant identifier'}
    cols['age'] = {'Description': 'Age of the participant at time of testing',
                   'Units': 'years'}
    cols['sex'] = {'Description': 'Biological sex of the participant',
                   'Levels': {'F': 'female', 'M': 'male'}}
    cols['hand'] = {'Description': 'Handedness of the participant',
                    'Levels': {'R': 'right', 'L': 'left', 'A': 'ambidextrous'}}
    if op.exists(fname):
        with open(fname, 'r', encoding='utf-8-sig') as fin:
            orig_cols = json.load(fin, object_pairs_hook=OrderedDict)
        for key, val in orig_cols.items():
            if key not in cols:
                cols[key] = val
    _write_json(fname, cols, overwrite)
def _participants_json ( fname , overwrite = False ) : cols = OrderedDict ( ) cols [ 'participant_id' ] = { 'Description' : 'Unique participant identifier' } cols [ 'age' ] = { 'Description' : 'Age of the participant at time of testing' , 'Units' : 'years' } cols [ 'sex' ] = { 'Description' : 'Biological sex of the participant' , 'Levels' : { 'F' : 'female' , 'M' : 'male' } } cols [ 'hand' ] = { 'Description' : 'Handedness of the participant' , 'Levels' : { 'R' : 'right' , 'L' : 'left' , 'A' : 'ambidextrous' } } if op . exists ( fname ) : with open ( fname , 'r' , encoding = 'utf-8-sig' ) as fin : orig_cols = json . load ( fin , object_pairs_hook = OrderedDict ) for key , val in orig_cols . items ( ) : if key not in cols : cols [ key ] = val _write_json ( fname , cols , overwrite )
Create participants.json for non-default columns in accompanying TSV.
Create participants . json for non - default columns in accompanying TSV .
"""Create participants.json for non-default columns in accompanying TSV.

    Parameters
    ----------
    fname : str | mne_bids.BIDSPath
        Filename to save the scans.tsv to.
    overwrite : bool
        Defaults to False.
        Whether to overwrite the existing data in the file.
        If there is already data for the given `fname` and overwrite is False,
        an error will be raised.

    """ # make sure to append any JSON fields added by the user # Note: mne-bids will overwrite age, sex and hand fields # if `overwrite` is True
fname
overwrite