bidshandler.Project

class bidshandler.Project(id_, bids_tree, initialize=True)[source]

Bases: bidshandler.querymixin.QueryMixin

Project-level object

Parameters:
  • id (str) – Id of the project. This is the name of the folder containing the data.
  • bids_tree (bidshandler.BIDSTree) – Parent BIDSTree object containing this Project.
  • initialize (bool, optional) – Whether to parse the folder and load any child structures.
__init__(id_, bids_tree, initialize=True)[source]

Initialize self. See help(type(self)) for accurate signature.

Methods

__init__(id_, bids_tree[, initialize]) Initialize self.
add(other[, copier]) Add another Scan, Session, Subject or Project to this object.
contained_files() Get the list of contained files.
query(obj, token, condition, value) Query the BIDS object and return the appropriate data.
subject(id_) Return the Subject in this project with the corresponding ID.

Attributes

ID ID of the Project.
description Path to the associated description if there is one.
inheritable_files List of files that are able to be inherited by child objects.
participants_json Path to the associated participants.tsv if there is one.
participants_tsv Path to the associated participants.tsv if there is one.
path Path to Project folder.
projects
readme Path to the associated README.txt if there is one.
scans List of all contained bidshandler.Scan’s.
sessions List of all contained bidshandler.Session’s.
subjects List of all contained bidshandler.Subject’s.
ID

ID of the Project.

__contains__(other)[source]

Determine if the Project contains a certain Scan, Session or Project.

Parameters:other (Instance of bidshandler.Scan, bidshandler.Session or bidshandler.Subject) – Object to check whether it is contained in this Project.
Returns:Returns True if the object is contained within this Project.
Return type:bool
__getitem__(item)[source]

Return the child subject with the corresponding name (if it exists).

__iter__()[source]

Iterable of the contained Subject objects.

add(other, copier=<function _copyfiles>)[source]

Add another Scan, Session, Subject or Project to this object.

Parameters:
  • other (Instance of bidshandler.Scan, bidshandler.Session, bidshandler.Subject or bidshandler.Project) – Object to be added to this Project. The added object must already exist in the same context as this object.
  • copier (function, optional) – A function to facilitate the copying of any applicable data. This function must have the call signature function(src_files: list, dst_files: list) Where src_files is the list of files to be moved and dst_files is the list of corresponding destinations. This will default to using utils._copyfiles which simply implements shutil.copy() and creates any directories that do not already exist.
contained_files()[source]

Get the list of contained files.

Returns:file_list – List with paths to all contained files relating to the BIDS structure.
Return type:list
description

Path to the associated description if there is one.

inheritable_files

List of files that are able to be inherited by child objects.

participants_json

Path to the associated participants.tsv if there is one.

participants_tsv

Path to the associated participants.tsv if there is one.

path

Path to Project folder.

projects
query(obj, token, condition, value)

Query the BIDS object and return the appropriate data.

Parameters:
  • obj (str) – The object type that should be returned. This can be one of (‘project’, ‘subject’, ‘session’, ‘scan’)
  • token (str) –

    The key to query for. This can be a value from the following list:

    • task: Corresponds to the task key in the BIDS filename.
    • acquisition or acq: Corresponds to the acq key in the BIDS filename.
    • run: Corresponds to the run key in the BIDS filename.
    • proc: Corresponds to the proc key in the BIDS filename.
    • age: Corresponds to the age of the participant. [Only available for obj=’subject’]
    • sex: Corresponds to the gender of the participant. [Only available for obj=’subject’]
    • group: Corresponds to the group of the participant. [Only available for obj=’subject’]
    • rec_date: Corresponds to the time and date of the recording. The value can either be formatted like “%Y-%m-%d” (ie. YYYY-MM-DD) to specify a single day, or it can be specified to the second by formatting it using the format string “%Y-%m-%dT%H:%M:%S” (ie. YYYY-MM-DDTHH:mm:ss).
    • subjects: Corresponds to the number of subjects contained. [Only available for obj=’project’]
    • sessions: Corresponds to the number of sessions contained. [Only available for obj=’project’ or ‘subject’]
    • scans: Corresponds to the number of scans contained. [Only available for obj=’project’, ‘subject’ or ‘session’]
    • Any other token will be considered to be a key in the sidecar.json file.
  • condition (str) – One of (‘<’, ‘<=’, ‘=’, ‘!=’, ‘!!=’ (none equal), ‘=>’, ‘>’). Used to perform comaprisons between the value provided and the values the data have. The ‘!!=’ operator here is used to distinguish between the case of when you want to determine if something contains something that isn’t the value you specify, and whether something doesn’t contain the value specified. This operator is currently only supported for the tokens ‘task’, ‘acquisition’/’acq’, `’run’ and ‘proc’.
  • value (str | int | float) – The value the token has (or the value to compare using the condition argument). The value provided must match exactly if the equality operator is used, and must have a type appropriate for comparison if an inequality operator is used. Currently regex is not supported, but this may come in the future.
Returns:

return_data – List of objects that satisfy the provided query conditions.

Return type:

bidshandler.querylist.QueryList

readme

Path to the associated README.txt if there is one.

scans

List of all contained bidshandler.Scan’s.

Returns:All Scans within this Project.
Return type:list of bidshandler.Scan
sessions

List of all contained bidshandler.Session’s.

Returns:All Sessions within this Project.
Return type:list of bidshandler.Session
subject(id_)[source]

Return the Subject in this project with the corresponding ID.

Parameters:id (str) – Id of the subject to return.
Returns:Contained Subject with the specified id_.
Return type:bidshandler.Subject
subjects

List of all contained bidshandler.Subject’s.

Returns:All Subjects within this Project.
Return type:list of bidshandler.Subject