BidsSidecarFile

class BidsSidecarFile(file_path)[source]

A BIDS sidecar file.

Methods

hed.tools.bids.bids_sidecar_file.BidsSidecarFile.__init__(...)

Constructs a bids sidecar from a file.

hed.tools.bids.bids_sidecar_file.BidsSidecarFile.clear_contents()

Set the contents attribute of this object to None.

hed.tools.bids.bids_sidecar_file.BidsSidecarFile.get_entity(...)

hed.tools.bids.bids_sidecar_file.BidsSidecarFile.get_key([...])

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

hed.tools.bids.bids_sidecar_file.BidsSidecarFile.is_hed(...)

Return True if the json has HED.

hed.tools.bids.bids_sidecar_file.BidsSidecarFile.is_sidecar_for(obj)

Return true if this is a sidecar for obj.

hed.tools.bids.bids_sidecar_file.BidsSidecarFile.set_contents([...])

Set the contents of the sidecar.

Attributes

hed.tools.bids.bids_sidecar_file.BidsSidecarFile.contents

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)
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.