bidshandler.querylist.QueryList¶
-
class
bidshandler.querylist.QueryList(*iterable)[source]¶ Bases:
listList wrapper class to allow the list of return objects from a query to itself be queried.
Methods
__init__(*iterable)Initialize self. appendAppend object to the end of the list. clearRemove all items from list. copyReturn a shallow copy of the list. countReturn number of occurrences of value. extendExtend list by appending elements from the iterable. indexReturn first index of value. insertInsert object before index. popRemove and return item at index (default last). query(obj, token, condition, value)Query the BIDS object and return the appropriate data. removeRemove first occurrence of value. reverseReverse IN PLACE. sortStable sort IN PLACE. -
__contains__¶ Return key in self.
-
__getitem__()¶ x.__getitem__(y) <==> x[y]
-
__iter__¶ Implement iter(self).
-
append()¶ Append object to the end of the list.
-
clear()¶ Remove all items from list.
-
copy()¶ Return a shallow copy of the list.
-
count()¶ Return number of occurrences of value.
-
extend()¶ Extend list by appending elements from the iterable.
-
index()¶ Return first index of value.
Raises ValueError if the value is not present.
-
insert()¶ Insert object before index.
-
pop()¶ Remove and return item at index (default last).
Raises IndexError if list is empty or index is out of range.
-
query(obj, token, condition, value)[source]¶ 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:
-
remove()¶ Remove first occurrence of value.
Raises ValueError if the value is not present.
-
reverse()¶ Reverse IN PLACE.
-
sort()¶ Stable sort IN PLACE.
-