diff --git a/AFQ/afq_bids_entities.json b/AFQ/afq_bids_entities.json new file mode 100644 index 000000000..32fbf771b --- /dev/null +++ b/AFQ/afq_bids_entities.json @@ -0,0 +1,22 @@ +{ + "name": "bidsafq", + "entities": [ + { + "name": "odfmodel", + "pattern": "[_/\\\\]+odfmodel-([a-zA-Z0-9]+)" + }, + { + "name": "coordsys", + "pattern": "[_/\\\\]+coordsys-([a-zA-Z0-9]+)" + }, + { + "name": "trkmethod", + "pattern": "[_/\\\\]+trkmethod-([a-zA-Z0-9]+)" + }, + { + "name": "recogmethod", + "pattern": "[_/\\\\]+recogmethod-([a-zA-Z0-9]+)" + } + ] + } + \ No newline at end of file diff --git a/AFQ/api/group.py b/AFQ/api/group.py index 7cdd2f1fb..0de25fab5 100644 --- a/AFQ/api/group.py +++ b/AFQ/api/group.py @@ -41,7 +41,7 @@ using_afqb = False -__all__ = ["GroupAFQ"] +__all__ = ["GroupAFQ", "get_afq_bids_entities_fname"] logger = logging.getLogger('AFQ') @@ -55,6 +55,11 @@ def clean_pandas_df(df): return df +def get_afq_bids_entities_fname(): + return op.dirname(op.dirname(op.abspath( + aus.__file__))) + "/afq_bids_entities.json" + + class GroupAFQ(object): f"""{AFQclass_doc}""" diff --git a/AFQ/api/participant.py b/AFQ/api/participant.py index d557ce3b6..11b95c483 100644 --- a/AFQ/api/participant.py +++ b/AFQ/api/participant.py @@ -1,6 +1,5 @@ import nibabel as nib import os.path as op -import os from time import time import logging from tqdm import tqdm @@ -20,7 +19,8 @@ from AFQ.tasks.tractography import get_tractography_plan from AFQ.tasks.segmentation import get_segmentation_plan from AFQ.tasks.viz import get_viz_plan -from AFQ.utils.path import drop_extension, apply_cmd_to_afq_derivs +from AFQ.tasks.utils import get_base_fname +from AFQ.utils.path import apply_cmd_to_afq_derivs from AFQ.viz.utils import BEST_BUNDLE_ORIENTATIONS, trim, get_eye @@ -104,9 +104,7 @@ def __init__(self, results_dir=output_dir, dwi_affine=nib.load(dwi_data_file).affine, bids_info=bids_info, - base_fname=op.join( - output_dir, - drop_extension(op.basename(dwi_data_file))), + base_fname=get_base_fname(output_dir, dwi_data_file), **kwargs) self.make_workflow() diff --git a/AFQ/data/fetch.py b/AFQ/data/fetch.py index ac1b965c7..c8040da5e 100644 --- a/AFQ/data/fetch.py +++ b/AFQ/data/fetch.py @@ -822,7 +822,8 @@ def read_cp_templates(as_img=True, resample_to=False): resample_to=resample_to) toc = time.perf_counter() - logger.debug(f'Cerebellar peduncles templates loaded in {toc - tic:0.4f} seconds') + logger.debug( + f'Cerebellar peduncles templates loaded in {toc - tic:0.4f} seconds') return template_dict @@ -1084,7 +1085,7 @@ def organize_stanford_data(path=None, clear_previous_afq=None): else: apply_cmd_to_afq_derivs( op.join(afq_folder, "sub-01/ses-01"), - op.join(afq_folder, "sub-01/ses-01/sub-01_ses-01_dwi"), + op.join(afq_folder, "sub-01/ses-01/sub-01_ses-01"), dependent_on=clear_previous_afq) if not op.exists(derivatives_path): diff --git a/AFQ/tasks/data.py b/AFQ/tasks/data.py index 488aabbfa..318233665 100644 --- a/AFQ/tasks/data.py +++ b/AFQ/tasks/data.py @@ -124,7 +124,7 @@ def dti_fit(dti_params, gtab): @pimms.calc("dti_params") -@as_file(suffix='_model-DTI_desc-diffmodel_dwi.nii.gz') +@as_file(suffix='_odfmodel-DTI_desc-diffmodel_dwi.nii.gz') @as_img def dti_params(brain_mask, data, gtab, bval, bvec, b0_threshold=50, robust_tensor_fitting=False): @@ -172,7 +172,7 @@ def fwdti_fit(fwdti_params, gtab): @pimms.calc("fwdti_params") -@as_file(suffix='_model-FWDTI_desc-diffmodel_dwi.nii.gz') +@as_file(suffix='_odfmodel-FWDTI_desc-diffmodel_dwi.nii.gz') @as_img def fwdti_params(brain_mask, data, gtab): """ @@ -200,7 +200,7 @@ def dki_fit(dki_params, gtab): @pimms.calc("dki_params") -@as_file(suffix='_model-DKI_desc-diffmodel_dwi.nii.gz') +@as_file(suffix='_odfmodel-DKI_desc-diffmodel_dwi.nii.gz') @as_img def dki_params(brain_mask, gtab, data): """ @@ -221,7 +221,7 @@ def dki_params(brain_mask, gtab, data): @pimms.calc("csd_params") -@as_file(suffix='_model-CSD_desc-diffmodel_dwi.nii.gz') +@as_file(suffix='_odfmodel-CSD_desc-diffmodel_dwi.nii.gz') @as_img def csd_params(dwi, brain_mask, gtab, data, csd_response=None, csd_sh_order=None, @@ -285,7 +285,7 @@ def csd_params(dwi, brain_mask, gtab, data, @pimms.calc("csd_pmap") -@as_file(suffix='_model-CSD_desc-APM_dwi.nii.gz') +@as_file(suffix='_odfmodel-CSD_desc-APM_dwi.nii.gz') @as_img def anisotropic_power_map(csd_params): """ @@ -298,7 +298,7 @@ def anisotropic_power_map(csd_params): @pimms.calc("csd_ai") -@as_file(suffix='_model-CSD_desc-AI_dwi.nii.gz') +@as_file(suffix='_odfmodel-CSD_desc-AI_dwi.nii.gz') @as_img def csd_anisotropic_index(csd_params): """ @@ -334,7 +334,7 @@ def gq(base_fname, gtab, dwi_affine, data, GQ_shm, ASO, ISO = extract_odf(odf) - params_suffix = "_model-GQ_desc-diffmodel_dwi.nii.gz" + params_suffix = "_odfmodel-GQ_desc-diffmodel_dwi.nii.gz" params_fname = get_fname(base_fname, params_suffix) nib.save(nib.Nifti1Image(GQ_shm, dwi_affine), params_fname) write_json( @@ -342,7 +342,7 @@ def gq(base_fname, gtab, dwi_affine, data, dict(GQSamplingLength=gq_sampling_length) ) - ASO_suffix = "_model-GQ_desc-ASO_dwi.nii.gz" + ASO_suffix = "_odfmodel-GQ_desc-ASO_dwi.nii.gz" ASO_fname = get_fname(base_fname, ASO_suffix) nib.save(nib.Nifti1Image(ASO, dwi_affine), ASO_fname) write_json( @@ -350,7 +350,7 @@ def gq(base_fname, gtab, dwi_affine, data, dict(GQSamplingLength=gq_sampling_length) ) - ISO_suffix = "_model-GQ_desc-ISO_dwi.nii.gz" + ISO_suffix = "_odfmodel-GQ_desc-ISO_dwi.nii.gz" ISO_fname = get_fname(base_fname, ISO_suffix) nib.save(nib.Nifti1Image(ISO, dwi_affine), ISO_fname) write_json( @@ -362,7 +362,7 @@ def gq(base_fname, gtab, dwi_affine, data, @pimms.calc("gq_pmap") -@as_file(suffix='_model-GQ_desc-APM_dwi.nii.gz') +@as_file(suffix='_odfmodel-GQ_desc-APM_dwi.nii.gz') @as_img def gq_pmap(gq_params): """ @@ -375,7 +375,7 @@ def gq_pmap(gq_params): @pimms.calc("gq_ai") -@as_file(suffix='_model-GQ_desc-AI_dwi.nii.gz') +@as_file(suffix='_odfmodel-GQ_desc-AI_dwi.nii.gz') @as_img def gq_ai(gq_params): """ @@ -406,7 +406,7 @@ def opdt_params(base_fname, data, gtab, opdt_model = shm.OpdtModel(gtab, opdt_sh_order) opdt_fit = opdt_model.fit(data, mask=brain_mask) - params_suffix = "_model-OPDT_desc-diffmodel_dwi.nii.gz" + params_suffix = "_odfmodel-OPDT_desc-diffmodel_dwi.nii.gz" params_fname = get_fname(base_fname, params_suffix) nib.save(nib.Nifti1Image(opdt_fit._shm_coef, dwi_affine), params_fname) write_json( @@ -414,7 +414,7 @@ def opdt_params(base_fname, data, gtab, dict(sh_order=opdt_sh_order) ) - GFA_suffix = "_model-OPDT_desc-GFA_dwi.nii.gz" + GFA_suffix = "_odfmodel-OPDT_desc-GFA_dwi.nii.gz" GFA_fname = get_fname(base_fname, GFA_suffix) nib.save(nib.Nifti1Image(opdt_fit.gfa, dwi_affine), GFA_fname) write_json( @@ -426,7 +426,7 @@ def opdt_params(base_fname, data, gtab, @pimms.calc("opdt_pmap") -@as_file(suffix='_model-OPDT_desc-APM_dwi.nii.gz') +@as_file(suffix='_odfmodel-OPDT_desc-APM_dwi.nii.gz') @as_img def opdt_pmap(opdt_params): """ @@ -439,7 +439,7 @@ def opdt_pmap(opdt_params): @pimms.calc("opdt_ai") -@as_file(suffix='_model-OPDT_desc-AI_dwi.nii.gz') +@as_file(suffix='_odfmodel-OPDT_desc-AI_dwi.nii.gz') @as_img def opdt_ai(opdt_params): """ @@ -470,7 +470,7 @@ def csa_params(base_fname, data, gtab, csa_model = shm.CsaOdfModel(gtab, csa_sh_order) csa_fit = csa_model.fit(data, mask=brain_mask) - params_suffix = "_model-CSA_desc-diffmodel_dwi.nii.gz" + params_suffix = "_odfmodel-CSA_desc-diffmodel_dwi.nii.gz" params_fname = get_fname(base_fname, params_suffix) nib.save(nib.Nifti1Image(csa_fit._shm_coef, dwi_affine), params_fname) write_json( @@ -478,7 +478,7 @@ def csa_params(base_fname, data, gtab, dict(sh_order=csa_sh_order) ) - GFA_suffix = "_model-CSA_desc-GFA_dwi.nii.gz" + GFA_suffix = "_odfmodel-CSA_desc-GFA_dwi.nii.gz" GFA_fname = get_fname(base_fname, GFA_suffix) nib.save(nib.Nifti1Image(csa_fit.gfa, dwi_affine), GFA_fname) write_json( @@ -490,7 +490,7 @@ def csa_params(base_fname, data, gtab, @pimms.calc("csa_pmap") -@as_file(suffix='_model-CSA_desc-APM_dwi.nii.gz') +@as_file(suffix='_odfmodel-CSA_desc-APM_dwi.nii.gz') @as_img def csa_pmap(csa_params): """ @@ -503,7 +503,7 @@ def csa_pmap(csa_params): @pimms.calc("csa_ai") -@as_file(suffix='_model-CSA_desc-AI_dwi.nii.gz') +@as_file(suffix='_odfmodel-CSA_desc-AI_dwi.nii.gz') @as_img def csa_ai(csa_params): """ @@ -516,7 +516,7 @@ def csa_ai(csa_params): @pimms.calc("fwdti_fa") -@as_file(suffix='_model-FWDTI_desc-FA_dwi.nii.gz') +@as_file(suffix='_odfmodel-FWDTI_desc-FA_dwi.nii.gz') @as_fit_deriv('FWDTI') def fwdti_fa(fwdti_tf): """ @@ -527,7 +527,7 @@ def fwdti_fa(fwdti_tf): @pimms.calc("fwdti_md") -@as_file(suffix='_model-FWDTI_desc-MD_dwi.nii.gz') +@as_file(suffix='_odfmodel-FWDTI_desc-MD_dwi.nii.gz') @as_fit_deriv('FWDTI') def fwdti_md(fwdti_tf): """ @@ -537,7 +537,7 @@ def fwdti_md(fwdti_tf): @pimms.calc("fwdti_fwf") -@as_file(suffix='_model-FWDTI_desc-FWF_dwi.nii.gz') +@as_file(suffix='_odfmodel-FWDTI_desc-FWF_dwi.nii.gz') @as_fit_deriv('FWDTI') def fwdti_fwf(fwdti_tf): """ @@ -547,7 +547,7 @@ def fwdti_fwf(fwdti_tf): @pimms.calc("dti_fa") -@as_file(suffix='_model-DTI_desc-FA_dwi.nii.gz') +@as_file(suffix='_odfmodel-DTI_desc-FA_dwi.nii.gz') @as_fit_deriv('DTI') def dti_fa(dti_tf): """ @@ -587,7 +587,7 @@ def dti_lt(dti_tf, dwi_affine): @pimms.calc("dti_cfa") -@as_file(suffix='_model-DTI_desc-CFA_dwi.nii.gz') +@as_file(suffix='_odfmodel-DTI_desc-CFA_dwi.nii.gz') @as_fit_deriv('DTI') def dti_cfa(dti_tf): """ @@ -598,7 +598,7 @@ def dti_cfa(dti_tf): @pimms.calc("dti_pdd") -@as_file(suffix='_model-DTI_desc-PDD_dwi.nii.gz') +@as_file(suffix='_odfmodel-DTI_desc-PDD_dwi.nii.gz') @as_fit_deriv('DTI') def dti_pdd(dti_tf): """ @@ -612,7 +612,7 @@ def dti_pdd(dti_tf): @pimms.calc("dti_md") -@as_file('_model-DTI_desc-MD_dwi.nii.gz') +@as_file('_odfmodel-DTI_desc-MD_dwi.nii.gz') @as_fit_deriv('DTI') def dti_md(dti_tf): """ @@ -623,7 +623,7 @@ def dti_md(dti_tf): @pimms.calc("dti_ga") -@as_file(suffix='_model-DTI_desc-GA_dwi.nii.gz') +@as_file(suffix='_odfmodel-DTI_desc-GA_dwi.nii.gz') @as_fit_deriv('DTI') def dti_ga(dti_tf): """ @@ -634,7 +634,7 @@ def dti_ga(dti_tf): @pimms.calc("dti_rd") -@as_file(suffix='_model-DTI_desc-RD_dwi.nii.gz') +@as_file(suffix='_odfmodel-DTI_desc-RD_dwi.nii.gz') @as_fit_deriv('DTI') def dti_rd(dti_tf): """ @@ -645,7 +645,7 @@ def dti_rd(dti_tf): @pimms.calc("dti_ad") -@as_file(suffix='_model-DTI_desc-AD_dwi.nii.gz') +@as_file(suffix='_odfmodel-DTI_desc-AD_dwi.nii.gz') @as_fit_deriv('DTI') def dti_ad(dti_tf): """ @@ -704,7 +704,7 @@ def dki_lt(dki_tf, dwi_affine): @pimms.calc("dki_fa") -@as_file('_model-DKI_desc-FA_dwi.nii.gz') +@as_file('_odfmodel-DKI_desc-FA_dwi.nii.gz') @as_fit_deriv('DKI') def dki_fa(dki_tf): """ @@ -715,7 +715,7 @@ def dki_fa(dki_tf): @pimms.calc("dki_md") -@as_file('_model-DKI_desc-MD_dwi.nii.gz') +@as_file('_odfmodel-DKI_desc-MD_dwi.nii.gz') @as_fit_deriv('DKI') def dki_md(dki_tf): """ @@ -726,7 +726,7 @@ def dki_md(dki_tf): @pimms.calc("dki_awf") -@as_file('_model-DKI_desc-AWF_dwi.nii.gz') +@as_file('_odfmodel-DKI_desc-AWF_dwi.nii.gz') @as_fit_deriv('DKI') def dki_awf(dki_params, sphere='repulsion100', gtol=1e-2): @@ -754,7 +754,7 @@ def dki_awf(dki_params, @pimms.calc("dki_mk") -@as_file('_model-DKI_desc-MK_dwi.nii.gz') +@as_file('_odfmodel-DKI_desc-MK_dwi.nii.gz') @as_fit_deriv('DKI') def dki_mk(dki_tf): """ @@ -765,7 +765,7 @@ def dki_mk(dki_tf): @pimms.calc("dki_ga") -@as_file(suffix='_model-DKI_desc-GA_dwi.nii.gz') +@as_file(suffix='_odfmodel-DKI_desc-GA_dwi.nii.gz') @as_fit_deriv('DKI') def dki_ga(dki_tf): """ @@ -776,7 +776,7 @@ def dki_ga(dki_tf): @pimms.calc("dki_rd") -@as_file(suffix='_model-DKI_desc-RD_dwi.nii.gz') +@as_file(suffix='_odfmodel-DKI_desc-RD_dwi.nii.gz') @as_fit_deriv('DKI') def dki_rd(dki_tf): """ @@ -787,7 +787,7 @@ def dki_rd(dki_tf): @pimms.calc("dki_ad") -@as_file(suffix='_model-DKI_desc-AD_dwi.nii.gz') +@as_file(suffix='_odfmodel-DKI_desc-AD_dwi.nii.gz') @as_fit_deriv('DKI') def dki_ad(dki_tf): """ @@ -798,7 +798,7 @@ def dki_ad(dki_tf): @pimms.calc("dki_rk") -@as_file(suffix='_model-DKI_desc-RK_dwi.nii.gz') +@as_file(suffix='_odfmodel-DKI_desc-RK_dwi.nii.gz') @as_fit_deriv('DKI') def dki_rk(dki_tf): """ @@ -809,7 +809,7 @@ def dki_rk(dki_tf): @pimms.calc("dki_ak") -@as_file(suffix='_model-DKI_desc-AK_dwi.nii.gz') +@as_file(suffix='_odfmodel-DKI_desc-AK_dwi.nii.gz') @as_fit_deriv('DKI') def dki_ak(dki_tf): """ diff --git a/AFQ/tasks/utils.py b/AFQ/tasks/utils.py index 1df2b3b39..d764f7dde 100644 --- a/AFQ/tasks/utils.py +++ b/AFQ/tasks/utils.py @@ -1,7 +1,25 @@ +from AFQ.utils.path import drop_extension import os.path as op import inspect -__all__ = ["get_fname", "with_name"] +__all__ = ["get_fname", "with_name", "get_base_fname"] + + +def get_base_fname(output_dir, dwi_data_file): + # setup up path and base file name for outputs + # remove suffix and desc from dwi data file name + used_key_list = ["desc", "space", "to", "from"] + dwi_dfile_no_ext = op.join( + output_dir, + drop_extension(op.basename(dwi_data_file))) + fname = op.dirname(dwi_dfile_no_ext) + "/" + for key_val_pair in op.basename(dwi_dfile_no_ext).split("_"): + if "-" in key_val_pair: + key = key_val_pair.split("-")[0] + if key not in used_key_list: + fname = fname + key_val_pair + "_" + fname = fname[:-1] + return fname def get_fname(base_fname, suffix, @@ -11,11 +29,11 @@ def get_fname(base_fname, suffix, odf_model = tracking_params['odf_model'] directions = tracking_params['directions'] fname = fname + ( - f'_space-RASMM_model-{directions+odf_model}' + f'_coordsys-RASMM_trkmethod-{directions+odf_model}' ) if segmentation_params is not None and 'seg_algo' in segmentation_params: seg_algo = segmentation_params['seg_algo'] - fname = fname + f"_algo-{seg_algo}" + fname = fname + f"_recogmethod-{seg_algo}" return fname + suffix diff --git a/AFQ/tests/test_api.py b/AFQ/tests/test_api.py index 788005895..c431888c8 100644 --- a/AFQ/tests/test_api.py +++ b/AFQ/tests/test_api.py @@ -427,7 +427,7 @@ def test_AFQ_anisotropic(): myafq.export("mapping") assert op.exists(op.join( myafq.export("results_dir")["01"], - 'sub-01_ses-01_dwi_model-CSD_desc-APM_dwi.nii.gz')) + 'sub-01_ses-01_odfmodel-CSD_desc-APM_dwi.nii.gz')) def test_API_type_checking(): @@ -822,11 +822,11 @@ def test_AFQ_data_waypoint(): mapping_file = op.join( myafq.export("results_dir"), - 'sub-01_ses-01_dwi_desc-mapping_from-DWI_to-MNI_xform.nii.gz') + 'sub-01_ses-01_desc-mapping_from-DWI_to-MNI_xform.nii.gz') nib.save(mapping, mapping_file) reg_prealign_file = op.join( myafq.export("results_dir"), - 'sub-01_ses-01_dwi_desc-prealign_from-DWI_to-MNI_xform.npy') + 'sub-01_ses-01_desc-prealign_from-DWI_to-MNI_xform.npy') np.save(reg_prealign_file, np.eye(4)) # Test ROI exporting: @@ -834,7 +834,7 @@ def test_AFQ_data_waypoint(): assert op.exists(op.join( myafq.export("results_dir"), 'ROIs', - 'sub-01_ses-01_dwi_space-subject_desc-CSTRinclude1_mask.json')) + 'sub-01_ses-01_space-subject_desc-CSTRinclude1_mask.json')) seg_sft = aus.SegmentedSFT.fromfile( myafq.export("bundles")) @@ -845,7 +845,7 @@ def test_AFQ_data_waypoint(): assert op.exists(op.join( myafq.export("results_dir"), 'bundles', - 'sub-01_ses-01_dwi_space-RASMM_model-probCSD_algo-AFQ_desc-SLFL_tractography.trk')) # noqa + 'sub-01_ses-01_coordsys-RASMM_trkmethod-probCSD_recogmethod-AFQ_desc-SLFL_tractography.trk')) # noqa tract_profile_fname = myafq.export("profiles") tract_profiles = pd.read_csv(tract_profile_fname) @@ -858,12 +858,12 @@ def test_AFQ_data_waypoint(): assert op.exists(op.join( myafq.export("results_dir"), "viz_bundles", - 'sub-01_ses-01_dwi_space-RASMM_model-probCSD_algo-AFQ_desc-SLFLviz_dwi.html')) # noqa + 'sub-01_ses-01_coordsys-RASMM_trkmethod-probCSD_recogmethod-AFQ_desc-SLFLviz_dwi.html')) # noqa assert op.exists(op.join( myafq.export("results_dir"), "viz_bundles", - 'sub-01_ses-01_dwi_space-RASMM_model-probCSD_algo-AFQ_desc-SLFLviz_dwi.html')) # noqa + 'sub-01_ses-01_coordsys-RASMM_trkmethod-probCSD_recogmethod-AFQ_desc-SLFLviz_dwi.html')) # noqa # Before we run the CLI, we'll remove the bundles and ROI folders, to see # that the CLI generates them @@ -936,9 +936,9 @@ def test_AFQ_data_waypoint(): assert op.exists(op.join( results_dir, 'ROIs', - 'sub-01_ses-01_dwi_space-subject_desc-SLFLinclude1_mask.json')) + 'sub-01_ses-01_space-subject_desc-SLFLinclude1_mask.json')) assert op.exists(op.join( results_dir, 'bundles', - 'sub-01_ses-01_dwi_space-RASMM_model-probCSD_algo-AFQ_desc-SLFL_tractography.trk')) # noqa + 'sub-01_ses-01_coordsys-RASMM_trkmethod-probCSD_recogmethod-AFQ_desc-SLFL_tractography.trk')) # noqa diff --git a/docs/source/conf.py b/docs/source/conf.py index 4692697be..bc3915cbb 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -235,5 +235,7 @@ # Auto API autoapi_type = 'python' autoapi_dirs = ['../../AFQ'] -autoapi_ignore = ['*test*', '*_fixes*', '*version*', 'pyAFQ', 'License'] +autoapi_ignore = [ + '*test*', '*_fixes*', '*version*', + 'pyAFQ', 'License', 'afq_bids_entities.json'] autoapi_root = 'reference/api' diff --git a/examples/tutorial_examples/plot_bids_layout.py b/examples/tutorial_examples/plot_bids_layout.py index d0c6e8ac1..4b9eb698b 100644 --- a/examples/tutorial_examples/plot_bids_layout.py +++ b/examples/tutorial_examples/plot_bids_layout.py @@ -25,8 +25,8 @@ import os import os.path as op -from AFQ.api.group import GroupAFQ import AFQ.api.bundle_dict as abd +from AFQ.api.group import GroupAFQ, get_afq_bids_entities_fname import AFQ.data.fetch as afd @@ -35,7 +35,7 @@ # `pyBIDS `_. import bids - +from bids.layout import BIDSLayout ########################################################################## # We start with some example data. The data we will use here is @@ -256,3 +256,16 @@ # file contains the right names for the pipeline. See above for an example # of that. # 2. File naming convention doesn't uniquely identify file with bids filters. + + +########################################################################## +# The outputs of AFQ are also BIDS compatible. However, we use some +# custom entities, which need to be loaded. Here we demonstrate how +# to load the afq entities with get_afq_bids_entities_fname() +# and then show all files with the key-value pair recogmethod-AFQ + +layout = BIDSLayout(bids_path) +layout.add_derivatives( + f'{bids_path}/derivatives/afq', + config=['bids', 'derivatives', get_afq_bids_entities_fname()]) +print(layout.get(recogmethod="AFQ", return_type="filename"))