Skip to content

Commit dc0487a

Browse files
committed
Add doctests.
1 parent 7bf8e12 commit dc0487a

File tree

1 file changed

+28
-1
lines changed

1 file changed

+28
-1
lines changed

cubids/cubids.py

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1735,7 +1735,34 @@ def get_key_name(path, key):
17351735

17361736

17371737
def build_path(filepath, entities, out_dir):
1738-
"""Build a new path for a file based on its BIDS entities."""
1738+
"""Build a new path for a file based on its BIDS entities.
1739+
1740+
Parameters
1741+
----------
1742+
filepath : str
1743+
The original file path.
1744+
entities : dict
1745+
A dictionary of BIDS entities.
1746+
out_dir : str
1747+
The output directory for the new file.
1748+
1749+
Returns
1750+
-------
1751+
new_path : str
1752+
The new file path.
1753+
1754+
Examples
1755+
--------
1756+
>>> build_path("sub-01/ses-01/anat/sub-01_ses-01_T1w.nii.gz", {"suffix": "T2w"}, "output")
1757+
'output/sub-01/ses-01/anat/sub-01_ses-01_T2w.nii.gz'
1758+
1759+
>>> build_path(
1760+
>>> "sub-01/ses-01/func/sub-01_ses-01_task-rest_run-01_bold.nii.gz",
1761+
>>> {"task": "rest", "run": "01", "acquisition": "VAR"},
1762+
>>> "output",
1763+
>>> )
1764+
'output/sub-01/ses-01/func/sub-01_ses-01_task-rest_acq-VAR_run-001_bold.nii.gz'
1765+
"""
17391766
exts = Path(filepath).suffixes
17401767
old_ext = "".join(exts)
17411768

0 commit comments

Comments
 (0)