BidsFileGroup

class BidsFileGroup(root_path, suffix='_events', obj_type='tabular', exclude_dirs=['sourcedata', 'derivatives', 'code', 'stimuli'])[source]

Container for BIDS files with a specified suffix.

root_path

Real root path of the Bids dataset.

Type:

str

suffix

The file suffix specifying the class of file represented in this group (e.g., events).

Type:

str

obj_type

Type of file in this group (e.g., Tabular or Timeseries).

Type:

str

sidecar_dict

A dictionary of sidecars associated with this suffix .

Type:

dict

datafile_dict

A dictionary with values either BidsTabularFile or BidsTimeseriesFile.

Type:

dict

sidecar_dir_dict

Dictionary whose keys are directory paths and values are list of sidecars in the corresponding directory.

Type:

dict

Methods

BidsFileGroup.__init__(root_path[, suffix, ...])

Constructor for a BidsFileGroup.

BidsFileGroup.get_sidecars_from_path(obj)

Return applicable sidecars for the object.

BidsFileGroup.summarize([value_cols, skip_cols])

Return a BidsTabularSummary of group files.

BidsFileGroup.validate_datafiles(hed_schema)

Validate the datafiles and return an error list.

BidsFileGroup.validate_sidecars(hed_schema)

Validate merged sidecars.

Attributes

BidsFileGroup.__init__(root_path, suffix='_events', obj_type='tabular', exclude_dirs=['sourcedata', 'derivatives', 'code', 'stimuli'])[source]

Constructor for a BidsFileGroup.

Parameters:
  • root_path (str) – Path of the root of the BIDS dataset.

  • suffix (str) – Suffix indicating the type this group represents (e.g. events, or channels, etc.).

  • obj_type (str) – Indicates the type of underlying file represents the contents.

  • exclude_dirs (list) – Directories to exclude.

BidsFileGroup.get_sidecars_from_path(obj)[source]

Return applicable sidecars for the object.

Parameters:

obj (BidsTabularFile or BidsSidecarFile) – The BIDS file object to get the sidecars for.

Returns:

A list of the paths for applicable sidecars for obj starting at the root.

Return type:

list

BidsFileGroup.summarize(value_cols=None, skip_cols=None)[source]

Return a BidsTabularSummary of group files.

Parameters:
  • value_cols (list) – Column names designated as value columns.

  • skip_cols (list) – Column names designated as columns to skip.

Returns:

A summary of the number of values in different columns if tabular group.

Return type:

TabularSummary or None

Notes

  • The columns that are not value_cols or skip_col are summarized by counting

the number of times each unique value appears in that column.

BidsFileGroup.validate_datafiles(hed_schema, extra_def_dicts=None, check_for_warnings=True, keep_contents=False)[source]

Validate the datafiles and return an error list.

Parameters:
  • hed_schema (HedSchema) – Schema to apply to the validation.

  • extra_def_dicts (DefinitionDict) – Extra definitions that come from outside.

  • check_for_warnings (bool) – If True, include warnings in the check.

  • keep_contents (bool) – If True, the underlying data files are read and their contents retained.

Returns:

A list of validation issues found. Each issue is a dictionary.

Return type:

list

BidsFileGroup.validate_sidecars(hed_schema, extra_def_dicts=None, check_for_warnings=True)[source]

Validate merged sidecars.

Parameters:
  • hed_schema (HedSchema) – HED schema for validation.

  • extra_def_dicts (DefinitionDict) – Extra definitions.

  • check_for_warnings (bool) – If True, include warnings in the check.

Returns:

A list of validation issues found. Each issue is a dictionary.

Return type:

list