nipoppy.utils.bids¶
Utility functions for BIDS dataset manipulation.
Module Contents¶
- nipoppy.utils.bids.add_pybids_ignore_patterns(current, new)¶
Add pattern(s) to ignore for PyBIDS.
- Parameters:
current (List[re.Pattern])
new (Sequence[str | re.Pattern] | str | re.Pattern)
- nipoppy.utils.bids.check_participant_id(participant_id, raise_error=False)¶
Make sure a participant ID is valid.
Specifically: - Check that it does not have the sub- prefix, stripping it if it does - Check that it only has alphanumeric characters
- Parameters:
participant_id (Optional[str]) – The participant ID to check. If None, returns None.
raise_error (bool, optional) – Whether to raise an error if the participant ID has the sub- prefix, by default False. Note: an error is always raised if the participant ID contains non-alphanumeric characters after being stripped of the sub- prefix.
- Returns:
The participant ID without the BIDS prefix
- Return type:
- Raises:
- nipoppy.utils.bids.check_session_id(session_id, raise_error=False)¶
Make sure a session ID is valid.
Specifically: - Check that it does not have the ses- prefix, stripping it if it does - Check that it only has alphanumeric characters
- Parameters:
participant_id (Optional[str]) – The participant ID to check. If None, returns None.
raise_error (bool, optional) – Whether to raise an error if the session ID has the ses- prefix, by default False. Note: an error is always raised if the session ID contains non-alphanumeric characters even being stripped of the ses- prefix.
session_id (Optional[str])
- Returns:
The session ID without the BIDS prefix
- Return type:
- Raises:
- nipoppy.utils.bids.create_bids_db(dpath_bids, dpath_pybids_db=None, validate=False, reset_database=True, ignore_patterns=None, resolve_paths=True)¶
Create a BIDSLayout using an indexer.
- Parameters:
dpath_bids (nipoppy.env.StrOrPathLike)
dpath_pybids_db (Optional[nipoppy.env.StrOrPathLike])
ignore_patterns (Optional[list[str | re.Pattern] | str | re.Pattern])
- Return type:
bids.BIDSLayout
- nipoppy.utils.bids.participant_id_to_bids_participant_id(participant_id)¶
Add the BIDS prefix to a participant ID.