BidsSidecarFile¶
- class BidsSidecarFile(file_path)[source]
A BIDS sidecar file.
Methods
|
Constructs a bids sidecar from a file. |
Set the contents attribute of this object to None. |
|
|
Return the entity value for the specified entity. |
|
Return a key for this BIDS file given a list of entities. |
|
Return True if the json has HED. |
Return True if this is a sidecar for obj. |
|
|
Set the contents of the sidecar. |
Attributes
Return the current contents of this object. |
- BidsSidecarFile.__init__(file_path)[source]¶
Constructs a bids sidecar from a file.
- Parameters:
file_path (str) – The real path of the sidecar.
- BidsSidecarFile.clear_contents()¶
Set the contents attribute of this object to None.
- BidsSidecarFile.get_entity(entity_name)¶
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
- BidsSidecarFile.get_key(entities=None)¶
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.
- static BidsSidecarFile.is_hed(json_dict)[source]¶
Return True if the json has HED.
- Parameters:
json_dict (dict) – A dictionary representing a JSON file or merged file.
- Returns:
True if the dictionary has HED or HED_assembled as a first or second-level key.
- Return type:
bool
- BidsSidecarFile.is_sidecar_for(obj)[source]¶
Return True if this is a sidecar for obj.
- Parameters:
obj (BidsFile) – A BidsFile object to check.
- Returns:
True if this is a BIDS parent of obj and False otherwise.
- Return type:
bool
Notes
A sidecar is a sidecar for itself.
- BidsSidecarFile.set_contents(content_info=None, overwrite=False)[source]¶
Set the contents of the sidecar.
- Parameters:
content_info (list, str, or None) – If None, create a Sidecar from the object’s file-path.
overwrite (bool) – If True, overwrite contents if already set.
Notes
- The handling of content_info is as follows:
None: This object’s file_path is used.
str: The string is interpreted as a path of the JSON.
list: The list is of paths.
- BidsSidecarFile.contents¶
Return the current contents of this object.