BidsFile

class BidsFile(file_path)[source]

A BIDS file with entity dictionary.

file_path

Real path of the file.

Type:

str

suffix

Suffix part of the filename.

Type:

str

ext

Extension (including the .).

Type:

str

entity_dict

Dictionary of entity-names (keys) and entity-values (values).

Type:

dict

sidecar

Merged sidecar for this file.

Type:

BidsSidecarFile

Notes

  • This class may hold the merged sidecar giving metadata for this file as well as contents.

Methods

BidsFile.__init__(file_path)

Constructor for a file path.

BidsFile.clear_contents()

Set the contents attribute of this object to None.

BidsFile.get_entity(entity_name)

Return the entity value for the specified entity.

BidsFile.get_key([entities])

Return a key for this BIDS file given a list of entities.

BidsFile.set_contents([content_info, overwrite])

Set the contents of this object.

Attributes

BidsFile.contents

Return the current contents of this object.

BidsFile.__init__(file_path)[source]

Constructor for a file path.

Parameters:

file_path (str) – Full path of the file.

BidsFile.clear_contents()[source]

Set the contents attribute of this object to None.

BidsFile.get_entity(entity_name)[source]

Return the entity value for the specified entity.

Parameters:

entity_name (str) – Name of the BIDS entity, for example task, run, or sub.

Returns:

Entity value if any, otherwise None.

Return type:

str or None

BidsFile.get_key(entities=None)[source]

Return a key for this BIDS file given a list of entities.

Parameters:

entities (tuple) – A tuple of strings representing entities.

Returns:

A key based on this object.

Return type:

str

Notes

If entities is None, then the file path is used as the key.

BidsFile.set_contents(content_info=None, overwrite=False)[source]

Set the contents of this object.

Parameters:
  • content_info (Any) – The contents appropriate for this object.

  • overwrite (bool) – If False and the contents are not empty, do nothing.

Notes

  • Do not set if the contents are already set and no_overwrite is True.

BidsFile.contents

Return the current contents of this object.