bidshandler.Subject¶
-
class
bidshandler.
Subject
(id_, project, initialize=True)[source]¶ Bases:
bidshandler.querymixin.QueryMixin
Subject-level object.
Parameters: - id (str) – Id of the subject. This is the sequence of characters after ‘sub-‘.
- project (
bidshandler.Project
) – Parent Project object containing this Subject. - initialize (bool, optional) – Whether to parse the folder and load any child structures.
-
__init__
(id_, project, initialize=True)[source]¶ Initialize self. See help(type(self)) for accurate signature.
Methods
__init__
(id_, project[, initialize])Initialize self. add
(other[, copier])Add another Scan, Session or Subject to this object. contained_files
()Get the list of contained files. delete
()Delete the subject from the parent Project. query
(obj, token, condition, value)Query the BIDS object and return the appropriate data. rename
(id_)Change the subjects’ id. session
(id_)Return the Session corresponding to the provided id. Attributes
ID
ID with ‘sub’ prefix. bids_tree
Parent bidshandler.BIDSTree
object.inheritable_files
List of files that are able to be inherited by child objects. path
Path of Subject folder. projects
scans
List of all contained bidshandler.Scan
’s.sessions
List of all contained bidshandler.Session
’s.subjects
-
ID
¶ ID with ‘sub’ prefix.
-
__contains__
(other)[source]¶ Determine if the Subject contains a certain Scan or Session.
Parameters: other (Instance of bidshandler.Scan
orbidshandler.Session
) – Object to check whether it is contained in this Subject.Returns: Returns True if the object is contained within this Subject. Return type: bool
-
add
(other, copier=<function _copyfiles>)[source]¶ Add another Scan, Session or Subject to this object.
Parameters: - other (Instance of
bidshandler.Scan
,bidshandler.Session
orbidshandler.Subject
) – Object to be added to this Subject. 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.
- other (Instance of
-
bids_tree
¶ Parent
bidshandler.BIDSTree
object.
-
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
-
inheritable_files
¶ List of files that are able to be inherited by child objects.
-
path
¶ Path of Subject 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:
-
scans
¶ List of all contained
bidshandler.Scan
’s.Returns: All Scans within this Subject. Return type: list of bidshandler.Scan
-
session
(id_)[source]¶ Return the Session corresponding to the provided id.
Parameters: id (str) – Id of the session to return. This doesn’t need the ‘ses’ prefix. Returns: Contained Session with the specified id_. Return type: bidshandler.Session
-
sessions
¶ List of all contained
bidshandler.Session
’s.Returns: All Sessions within this Subject. Return type: list of bidshandler.Session
-
subjects
¶