nvm.aux_bids package
Module contents
- nvm.aux_bids.dict_from_bids_filename(fn0, log0=<Logger dummy (WARNING)>)[source]
Extract tags, values, suffix(es) and extension(s) from BIDS-like filename.
- Parameters
fn0 (Union[str, pathlib.Path]) – BIDS-like filename (or path to such a file).
Examples
>>> from nvm.aux_bids import dict_from_bids_filename >>> >>> fn0_samp = ( >>> "../../data/" >>> "data-001/sub-sykamw18_ses-evening_" >>> "run-r0_date-20220725T202601." >>> "uuid-670f238a-1c15-4f7c-be1a-ea057756ac04.csv" >>> ) # WTF >>> >>> fn0_samp = ( >>> "../../data/" >>> "data-001/sub-s001__ses-morning_" >>> "insert_task-rest_space-T1w_desc-preproc_bold_info" >>> ".the.funky_ext.nii.gz" >>> ) >>> >>> dict0 = dict_from_bids_filename(fn0_samp) >>> dict0 {'props': {'sub': 's001', 'ses': 'morning', 'task': 'rest', 'space': 'T1w', 'desc': 'preproc'}, 'suff': ['insert', 'bold', 'info'], 'ext': '.the.funky_ext.nii.gz'}
>>> # Same example with added nice formatting >>> from nvm.aux_bids import dict_from_bids_filename >>> from nvm import jsonable >>> import srsly >>> import textwrap >>> >>> fn0_samp = ( >>> "../../data/" >>> "data-001/sub-sykamw18_ses-evening_" >>> "run-r0_date-20220725T202601." >>> "uuid-670f238a-1c15-4f7c-be1a-ea057756ac04.csv" >>> ) # WTF >>> >>> fn0_samp = ( >>> "../../data/" >>> "data-001/sub-s001__ses-morning_" >>> "insert_task-rest_space-T1w_desc-preproc_bold_info" >>> ".the.funky_ext.nii.gz" >>> ) >>> >>> dict0 = dict_from_bids_filename(fn0_samp) >>> >>> print( >>> "got:\n" \ >>> f"{textwrap.indent(srsly.yaml_dumps(jsonable(dict0)), 5*' ')}" >>> ) got: props: sub: s001 ses: morning task: rest space: T1w desc: preproc suff: - insert - bold - info ext: .the.funky_ext.nii.gz
- Return type
Dict