mne_bids/write.py
def make_dataset_description(path, name, data_license=None,
                             authors=None, acknowledgements=None,
                             how_to_acknowledge=None, funding=None,
                             references_and_links=None, doi=None,
                             dataset_type='raw',
                             overwrite=False, verbose=None):
    """Create json for a dataset description.

    BIDS datasets may have one or more fields, this function allows you to
    specify which you wish to include in the description. See the BIDS
    documentation for information about what each field means.

    Parameters
    ----------
    path : str
        A path to a folder where the description will be created.
    name : str
        The name of this BIDS dataset.
    data_license : str | None
        The license under which this dataset is published.
    authors : list | str | None
        List of individuals who contributed to the creation/curation of the
        dataset. Must be a list of str or a single comma separated str
        like ['a', 'b', 'c'].
    acknowledgements : list | str | None
        Either a str acknowledging individuals who contributed to the
        creation/curation of this dataset OR a list of the individuals'
        names as str.
    how_to_acknowledge : list | str | None
        Either a str describing how to acknowledge this dataset OR a list of
        publications that should be cited.
    funding : list | str | None
        List of sources of funding (e.g., grant numbers). Must be a list of
        str or a single comma separated str like ['a', 'b', 'c'].
    references_and_links : list | str | None
        List of references to publication that contain information on the
        dataset, or links.  Must be a list of str or a single comma
        separated str like ['a', 'b', 'c'].
    doi : str | None
        The DOI for the dataset.
    dataset_type : str
        Must be either "raw" or "derivative". Defaults to "raw".
    overwrite : bool
        Whether to overwrite existing files or data in files.
        Defaults to False.
        If overwrite is True, provided fields will overwrite previous data.
        If overwrite is False, no existing data will be overwritten or
        replaced.
    %(verbose)s

    Notes
    -----
    The required field BIDSVersion will be automatically filled by mne_bids.

    """
    # Put potential string input into list of strings
    if isinstance(authors, str):
        authors = authors.split(', ')
    if isinstance(funding, str):
        funding = funding.split(', ')
    if isinstance(references_and_links, str):
        references_and_links = references_and_links.split(', ')
    if dataset_type not in ['raw', 'derivative']:
        raise ValueError('`dataset_type` must be either "raw" or '
                         '"derivative."')

    fname = op.join(path, 'dataset_description.json')
    description = OrderedDict([
        ('Name', name),
        ('BIDSVersion', BIDS_VERSION),
        ('DatasetType', dataset_type),
        ('License', data_license),
        ('Authors', authors),
        ('Acknowledgements', acknowledgements),
        ('HowToAcknowledge', how_to_acknowledge),
        ('Funding', funding),
        ('ReferencesAndLinks', references_and_links),
        ('DatasetDOI', doi)])
    if op.isfile(fname):
        with open(fname, 'r', encoding='utf-8-sig') as fin:
            orig_cols = json.load(fin)
        if 'BIDSVersion' in orig_cols and \
                orig_cols['BIDSVersion'] != BIDS_VERSION:
            raise ValueError('Previous BIDS version used, please redo the '
                             'conversion to BIDS in a new directory '
                             'after ensuring all software is updated')
        for key in description:
            if description[key] is None or not overwrite:
                description[key] = orig_cols.get(key, None)
    # default author to make dataset description BIDS compliant
    # if the user passed an author don't overwrite,
    # if there was an author there, only overwrite if `overwrite=True`
    if authors is None and (description['Authors'] is None or overwrite):
        description['Authors'] = ["[Unspecified]"]

    pop_keys = [key for key, val in description.items() if val is None]
    for key in pop_keys:
        description.pop(key)
    _write_json(fname, description, overwrite=True)
Create json for a dataset description.

    BIDS datasets may have one or more fields, this function allows you to
    specify which you wish to include in the description. See the BIDS
    documentation for information about what each field means.

    Parameters
    ----------
    path : str
        A path to a folder where the description will be created.
    name : str
        The name of this BIDS dataset.
    data_license : str | None
        The license under which this dataset is published.
    authors : list | str | None
        List of individuals who contributed to the creation/curation of the
        dataset. Must be a list of str or a single comma separated str
        like ['a', 'b', 'c'].
    acknowledgements : list | str | None
        Either a str acknowledging individuals who contributed to the
        creation/curation of this dataset OR a list of the individuals'
        names as str.
    how_to_acknowledge : list | str | None
        Either a str describing how to acknowledge this dataset OR a list of
        publications that should be cited.
    funding : list | str | None
        List of sources of funding (e.g., grant numbers). Must be a list of
        str or a single comma separated str like ['a', 'b', 'c'].
    references_and_links : list | str | None
        List of references to publication that contain information on the
        dataset, or links.  Must be a list of str or a single comma
        separated str like ['a', 'b', 'c'].
    doi : str | None
        The DOI for the dataset.
    dataset_type : str
        Must be either "raw" or "derivative". Defaults to "raw".
    overwrite : bool
        Whether to overwrite existing files or data in files.
        Defaults to False.
        If overwrite is True, provided fields will overwrite previous data.
        If overwrite is False, no existing data will be overwritten or
        replaced.
    %(verbose)s

    Notes
    -----
    The required field BIDSVersion will be automatically filled by mne_bids.

    
Create json for a dataset description.
BIDS datasets may have one or more fields, this function allows you to
specify which you wish to include in the description. See the BIDS
documentation for information about what each field means.

Parameters

path : str
A path to a folder where the description will be created.
name : str
The name of this BIDS dataset.
data_license : str | None
The license under which this dataset is published.
authors : list | str | None
List of individuals who contributed to the creation/curation of the
dataset.

Notes

The required field BIDSVersion will be automatically filled by mne_bids.
Create json for a dataset description . BIDS datasets may have one or more fields this function allows you to specify which you wish to include in the description . See the BIDS documentation for information about what each field means . Parameters path : str A path to a folder where the description will be created . name : str The name of this BIDS dataset . data_license : str | None The license under which this dataset is published . authors : list | str | None List of individuals who contributed to the creation / curation of the dataset . Notes The required field BIDSVersion will be automatically filled by mne_bids .
def make_dataset_description(path, name, data_license=None,
                             authors=None, acknowledgements=None,
                             how_to_acknowledge=None, funding=None,
                             references_and_links=None, doi=None,
                             dataset_type='raw',
                             overwrite=False, verbose=None):
    if isinstance(authors, str):
        authors = authors.split(', ')
    if isinstance(funding, str):
        funding = funding.split(', ')
    if isinstance(references_and_links, str):
        references_and_links = references_and_links.split(', ')
    if dataset_type not in ['raw', 'derivative']:
        raise ValueError('`dataset_type` must be either "raw" or '
                         '"derivative."')
    fname = op.join(path, 'dataset_description.json')
    description = OrderedDict([
        ('Name', name),
        ('BIDSVersion', BIDS_VERSION),
        ('DatasetType', dataset_type),
        ('License', data_license),
        ('Authors', authors),
        ('Acknowledgements', acknowledgements),
        ('HowToAcknowledge', how_to_acknowledge),
        ('Funding', funding),
        ('ReferencesAndLinks', references_and_links),
        ('DatasetDOI', doi)])
    if op.isfile(fname):
        with open(fname, 'r', encoding='utf-8-sig') as fin:
            orig_cols = json.load(fin)
        if 'BIDSVersion' in orig_cols and \
                orig_cols['BIDSVersion'] != BIDS_VERSION:
            raise ValueError('Previous BIDS version used, please redo the '
                             'conversion to BIDS in a new directory '
                             'after ensuring all software is updated')
        for key in description:
            if description[key] is None or not overwrite:
                description[key] = orig_cols.get(key, None)
    if authors is None and (description['Authors'] is None or overwrite):
        description['Authors'] = ["[Unspecified]"]
    pop_keys = [key for key, val in description.items() if val is None]
    for key in pop_keys:
        description.pop(key)
    _write_json(fname, description, overwrite=True)
def make_dataset_description ( path , name , data_license = None , authors = None , acknowledgements = None , how_to_acknowledge = None , funding = None , references_and_links = None , doi = None , dataset_type = 'raw' , overwrite = False , verbose = None ) : if isinstance ( authors , str ) : authors = authors . split ( ', ' ) if isinstance ( funding , str ) : funding = funding . split ( ', ' ) if isinstance ( references_and_links , str ) : references_and_links = references_and_links . split ( ', ' ) if dataset_type not in [ 'raw' , 'derivative' ] : raise ValueError ( '`dataset_type` must be either "raw" or ' '"derivative."' ) fname = op . join ( path , 'dataset_description.json' ) description = OrderedDict ( [ ( 'Name' , name ) , ( 'BIDSVersion' , BIDS_VERSION ) , ( 'DatasetType' , dataset_type ) , ( 'License' , data_license ) , ( 'Authors' , authors ) , ( 'Acknowledgements' , acknowledgements ) , ( 'HowToAcknowledge' , how_to_acknowledge ) , ( 'Funding' , funding ) , ( 'ReferencesAndLinks' , references_and_links ) , ( 'DatasetDOI' , doi ) ] ) if op . isfile ( fname ) : with open ( fname , 'r' , encoding = 'utf-8-sig' ) as fin : orig_cols = json . load ( fin ) if 'BIDSVersion' in orig_cols and orig_cols [ 'BIDSVersion' ] != BIDS_VERSION : raise ValueError ( 'Previous BIDS version used, please redo the ' 'conversion to BIDS in a new directory ' 'after ensuring all software is updated' ) for key in description : if description [ key ] is None or not overwrite : description [ key ] = orig_cols . get ( key , None ) if authors is None and ( description [ 'Authors' ] is None or overwrite ) : description [ 'Authors' ] = [ "[Unspecified]" ] pop_keys = [ key for key , val in description . items ( ) if val is None ] for key in pop_keys : description . pop ( key ) _write_json ( fname , description , overwrite = True )
Create json for a dataset description.
Create json for a dataset description .
"""Create json for a dataset description.

    BIDS datasets may have one or more fields, this function allows you to
    specify which you wish to include in the description. See the BIDS
    documentation for information about what each field means.

    Parameters
    ----------
    path : str
        A path to a folder where the description will be created.
    name : str
        The name of this BIDS dataset.
    data_license : str | None
        The license under which this dataset is published.
    authors : list | str | None
        List of individuals who contributed to the creation/curation of the
        dataset. Must be a list of str or a single comma separated str
        like ['a', 'b', 'c'].
    acknowledgements : list | str | None
        Either a str acknowledging individuals who contributed to the
        creation/curation of this dataset OR a list of the individuals'
        names as str.
    how_to_acknowledge : list | str | None
        Either a str describing how to acknowledge this dataset OR a list of
        publications that should be cited.
    funding : list | str | None
        List of sources of funding (e.g., grant numbers). Must be a list of
        str or a single comma separated str like ['a', 'b', 'c'].
    references_and_links : list | str | None
        List of references to publication that contain information on the
        dataset, or links.  Must be a list of str or a single comma
        separated str like ['a', 'b', 'c'].
    doi : str | None
        The DOI for the dataset.
    dataset_type : str
        Must be either "raw" or "derivative". Defaults to "raw".
    overwrite : bool
        Whether to overwrite existing files or data in files.
        Defaults to False.
        If overwrite is True, provided fields will overwrite previous data.
        If overwrite is False, no existing data will be overwritten or
        replaced.
    %(verbose)s

    Notes
    -----
    The required field BIDSVersion will be automatically filled by mne_bids.

    """ # Put potential string input into list of strings # default author to make dataset description BIDS compliant # if the user passed an author don't overwrite, # if there was an author there, only overwrite if `overwrite=True`
path
name
data_license
authors
acknowledgements
how_to_acknowledge
funding
references_and_links
doi
dataset_type
overwrite
verbose