From 2284c1b187c6d68a592575698efd2afd6cf4b52b Mon Sep 17 00:00:00 2001 From: Michelle Wang Date: Thu, 11 Jul 2024 15:50:54 +0800 Subject: [PATCH] [ENH] Add descriptors and sample invocations for BIDScoin (#267) * add descriptors and sample invocations for BIDSCOIN * rename descriptors * expand on descriptions in Boutiques descriptors * update BIDScoin config/descriptor to not use container (difficult because of GUI components) * fix test --- .../data/descriptors/bidscoiner-4.3.2.json | 79 +++++++++++ .../data/descriptors/bidseditor-4.3.2.json | 42 ++++++ .../data/descriptors/bidsmapper-4.3.2.json | 123 ++++++++++++++++++ .../sample_global_config-all_pipelines.json | 21 +++ ...sample_global_config-latest_pipelines.json | 21 +++ .../bidscoin-4.3.2-convert.json | 7 + .../bidscoin-4.3.2-edit.json | 3 + .../bidscoin-4.3.2-prepare.json | 4 + nipoppy_cli/tests/test_default_config.py | 7 +- 9 files changed, 306 insertions(+), 1 deletion(-) create mode 100644 nipoppy_cli/nipoppy/data/descriptors/bidscoiner-4.3.2.json create mode 100644 nipoppy_cli/nipoppy/data/descriptors/bidseditor-4.3.2.json create mode 100644 nipoppy_cli/nipoppy/data/descriptors/bidsmapper-4.3.2.json create mode 100644 nipoppy_cli/nipoppy/data/examples/sample_invocations/bidscoin-4.3.2-convert.json create mode 100644 nipoppy_cli/nipoppy/data/examples/sample_invocations/bidscoin-4.3.2-edit.json create mode 100644 nipoppy_cli/nipoppy/data/examples/sample_invocations/bidscoin-4.3.2-prepare.json diff --git a/nipoppy_cli/nipoppy/data/descriptors/bidscoiner-4.3.2.json b/nipoppy_cli/nipoppy/data/descriptors/bidscoiner-4.3.2.json new file mode 100644 index 00000000..95cf9dad --- /dev/null +++ b/nipoppy_cli/nipoppy/data/descriptors/bidscoiner-4.3.2.json @@ -0,0 +1,79 @@ +{ + "name": "bidscoiner", + "description": "bidscoiner (part of BIDScoin) to run BIDS conversion based on a YAML configuration file (bidsmap). See https://bidscoin.readthedocs.io/en/latest/workflow.html#step-2-running-the-bidscoiner", + "tool-version": "4.3.2+qt5", + "schema-version": "0.5", + "command-line": "bidscoiner [SOURCEFOLDER] [BIDSFOLDER] [PARTICIPANT_LABEL] [BIDSMAP] [FORCE] [CLUSTER] [NATIVESPEC]", + "inputs": [ + { + "name": "sourcefolder", + "id": "sourcefolder", + "description": "The study root folder containing the raw source data", + "type": "String", + "optional": false, + "value-key": "[SOURCEFOLDER]" + }, + { + "name": "bidsfolder", + "id": "bidsfolder", + "description": "The destination / output folder with the bids data", + "type": "String", + "optional": false, + "value-key": "[BIDSFOLDER]" + }, + { + "name": "participant_label", + "id": "participant_label", + "description": "Space separated list of selected sub-# names / folders to be processed (the sub-prefix can be removed). Otherwise all subjects in the sourcefolder will be selected", + "type": "String", + "list": true, + "optional": true, + "command-line-flag": "-p", + "value-key": "[PARTICIPANT_LABEL]" + }, + { + "name": "bidsmap", + "id": "bidsmap", + "description": "The study bidsmap file with the mapping heuristics. If the bidsmap filename is just the basename (i.e. no \"/\" in the name) then it is assumed to be located in the current directory or in bidsfolder/code/bidscoin. Default: bidsmap.yaml", + "type": "String", + "optional": true, + "default-value": "bidsmap.yaml", + "command-line-flag": "-b", + "value-key": "[BIDSMAP]" + }, + { + "name": "force", + "id": "force", + "description": "Process all subjects, regardless of existing subject folders in the bidsfolder. Otherwise these subject folders will be skipped", + "type": "Flag", + "optional": true, + "command-line-flag": "-f", + "value-key": "[FORCE]" + }, + { + "name": "cluster", + "id": "cluster", + "description": "Use the DRMAA library to submit the bidscoiner jobs to a high-performance compute (HPC) cluster", + "type": "Flag", + "optional": true, + "command-line-flag": "-c", + "value-key": "[CLUSTER]" + }, + { + "name": "nativespec", + "id": "nativespec", + "description": "Opaque DRMAA argument with native specifications for submitting bidscoiner jobs to the HPC cluster. NB: Use quotes and include at least one space character to prevent premature parsing (default: -l walltime=00:30:00,mem=4gb)", + "type": "String", + "optional": true, + "default-value": "-l walltime=00:30:00,mem=4gb", + "command-line-flag": "-n", + "value-key": "[NATIVESPEC]" + } + ], + "tags": {}, + "suggested-resources": { + "cpu-cores": 1, + "ram": 1, + "walltime-estimate": 60 + } +} diff --git a/nipoppy_cli/nipoppy/data/descriptors/bidseditor-4.3.2.json b/nipoppy_cli/nipoppy/data/descriptors/bidseditor-4.3.2.json new file mode 100644 index 00000000..5d2edf3f --- /dev/null +++ b/nipoppy_cli/nipoppy/data/descriptors/bidseditor-4.3.2.json @@ -0,0 +1,42 @@ +{ + "name": "bidseditor", + "description": "bidseditor (part of BIDScoin) to edit an existing YAML configuration file (bidsmap). See https://bidscoin.readthedocs.io/en/latest/workflow.html#step-1b-running-the-bidseditor", + "tool-version": "4.3.2+qt5", + "schema-version": "0.5", + "command-line": "bidseditor [BIDSFOLDER] [BIDSMAP] [TEMPLATE]", + "inputs": [ + { + "name": "bidsfolder", + "id": "bidsfolder", + "description": "The destination folder with the (future) bids data", + "type": "String", + "optional": false, + "value-key": "[BIDSFOLDER]" + }, + { + "name": "bidsmap", + "id": "bidsmap", + "description": "The study bidsmap file with the mapping heuristics. If the bidsmap filename is just the basename (i.e. no \"/\" in the name) then it is assumed to be located in the current directory or in bidsfolder/code/bidscoin. Default: bidsmap.yaml", + "type": "String", + "optional": true, + "default-value": "bidsmap.yaml", + "command-line-flag": "-b", + "value-key": "[BIDSMAP]" + }, + { + "name": "template", + "id": "template", + "description": "The template bidsmap file with the default heuristics (this could be provided by your institute). If the bidsmap filename is just the basename (i.e. no \"/\" in the name) then it is assumed to be located in the bidscoin config folder. Default: bidsmap_dccn", + "type": "String", + "optional": true, + "command-line-flag": "-t", + "value-key": "[TEMPLATE]" + } + ], + "tags": {}, + "suggested-resources": { + "cpu-cores": 1, + "ram": 1, + "walltime-estimate": 60 + } +} diff --git a/nipoppy_cli/nipoppy/data/descriptors/bidsmapper-4.3.2.json b/nipoppy_cli/nipoppy/data/descriptors/bidsmapper-4.3.2.json new file mode 100644 index 00000000..2c3b8a3f --- /dev/null +++ b/nipoppy_cli/nipoppy/data/descriptors/bidsmapper-4.3.2.json @@ -0,0 +1,123 @@ +{ + "name": "bidsmapper", + "description": "bidsmapper (part of BIDScoin) to create/edit a YAML configuration file (bidsmap). See https://bidscoin.readthedocs.io/en/latest/workflow.html#step-1a-running-the-bidsmapper", + "tool-version": "4.3.2+qt5", + "schema-version": "0.5", + "command-line": "bidsmapper [SOURCEFOLDER] [BIDSFOLDER] [BIDSMAP] [TEMPLATE] [PLUGINS] [SUBPREFIX] [SESPREFIX] [UNZIP] [STORE] [AUTOMATED] [FORCE] [NO_UPDATE]", + "inputs": [ + { + "name": "sourcefolder", + "id": "sourcefolder", + "description": "The study root folder containing the raw source data folders", + "type": "String", + "optional": false, + "value-key": "[SOURCEFOLDER]" + }, + { + "name": "bidsfolder", + "id": "bidsfolder", + "description": "The destination folder with the (future) bids data and the bidsfolder/code/bidscoin/bidsmap.yaml output file", + "type": "String", + "optional": false, + "value-key": "[BIDSFOLDER]" + }, + { + "name": "bidsmap", + "id": "bidsmap", + "description": "The study bidsmap file with the mapping heuristics. If the bidsmap filename is just the basename (i.e. no '/' in the name) then it is assumed to be located in the current directory or in bidsfolder/code/bidscoin. Default: bidsmap.yaml", + "type": "String", + "optional": true, + "default-value": "bidsmap.yaml", + "command-line-flag": "-b", + "value-key": "[BIDSMAP]" + }, + { + "name": "template", + "id": "template", + "description": "The bidsmap template file with the default heuristics (this could be provided by your institute). If the bidsmap filename is just the basename (i.e. no '/' in the name) then it is assumed to be located in the bidscoin config folder. Default: bidsmap_dccn", + "type": "String", + "optional": true, + "command-line-flag": "-t", + "value-key": "[TEMPLATE]" + }, + { + "name": "plugins", + "id": "plugins", + "description": "List of plugins to be used. Default: the plugin list of the study/template bidsmap)", + "type": "String", + "list": true, + "optional": true, + "command-line-flag": "-p", + "value-key": "[PLUGINS]" + }, + { + "name": "subprefix", + "id": "subprefix", + "description": "The prefix common for all the source subject-folders (e.g. 'Pt' is the subprefix if subject folders are named 'Pt018', 'Pt019', ...). Use '*' when your subject folders do not have a prefix. Default: the value of the study/template bidsmap, e.g. 'sub-'", + "type": "String", + "optional": true, + "command-line-flag": "-n", + "value-key": "[SUBPREFIX]" + }, + { + "name": "sesprefix", + "id": "sesprefix", + "description": "The prefix common for all the source session-folders (e.g. 'M_' is the subprefix if session folders are named 'M_pre', 'M_post', ..). Use '*' when your session folders do not have a prefix. Default: the value of the study/template bidsmap, e.g. 'ses-'", + "type": "String", + "optional": true, + "command-line-flag": "-m", + "value-key": "[SESPREFIX]" + }, + { + "name": "unzip", + "id": "unzip", + "description": "Wildcard pattern to unpack tarball/zip-files in the sub/ses sourcefolder that need to be unzipped (in a tempdir) to make the data readable. Default: the value of the study/template bidsmap", + "type": "String", + "optional": true, + "command-line-flag": "-u", + "value-key": "[UNZIP]" + }, + { + "name": "store", + "id": "store", + "description": "Store provenance data samples in the bidsfolder/code/provenance folder (useful for inspecting e.g. zipped or transferred datasets)", + "type": "Flag", + "optional": true, + "command-line-flag": "-s", + "value-key": "[STORE]" + }, + { + "name": "automated", + "id": "automated", + "description": "Save the automatically generated bidsmap to disk and without interactively tweaking it with the bidseditor", + "type": "Flag", + "optional": true, + "command-line-flag": "-a", + "value-key": "[AUTOMATED]" + }, + { + "name": "force", + "id": "force", + "description": "Discard the previously saved bidsmap and logfile", + "type": "Flag", + "optional": true, + "command-line-flag": "-f", + "value-key": "[FORCE]" + }, + { + "name": "no_update", + "id": "no_update", + "description": "Do not update any sub/sesprefixes in or prepend the sourcefolder name to the <> expression that extracts the subject/session labels. This is normally done to make the extraction more robust, but could cause problems for certain use cases", + "type": "Flag", + "optional": true, + "command-line-flag": "--no-update", + "value-key": "[NO_UPDATE]" + } + ], + "tags": {}, + "suggested-resources": { + "cpu-cores": 1, + "ram": 1, + "walltime-estimate": 60 + } +} diff --git a/nipoppy_cli/nipoppy/data/examples/sample_global_config-all_pipelines.json b/nipoppy_cli/nipoppy/data/examples/sample_global_config-all_pipelines.json index f49574a4..be1c14f8 100644 --- a/nipoppy_cli/nipoppy/data/examples/sample_global_config-all_pipelines.json +++ b/nipoppy_cli/nipoppy/data/examples/sample_global_config-all_pipelines.json @@ -75,6 +75,27 @@ "UPDATE_DOUGHNUT": true } ] + }, + { + "NAME": "bidscoin", + "VERSION": "4.3.2", + "STEPS": [ + { + "NAME": "prepare", + "INVOCATION_FILE": "[[NIPOPPY_DPATH_INVOCATIONS]]/[[NIPOPPY_PIPELINE_NAME]]-[[NIPOPPY_PIPELINE_VERSION]]-prepare.json", + "DESCRIPTOR_FILE": "[[NIPOPPY_DPATH_DESCRIPTORS]]/bidsmapper-[[NIPOPPY_PIPELINE_VERSION]].json" + }, + { + "NAME": "edit", + "INVOCATION_FILE": "[[NIPOPPY_DPATH_INVOCATIONS]]/[[NIPOPPY_PIPELINE_NAME]]-[[NIPOPPY_PIPELINE_VERSION]]-edit.json", + "DESCRIPTOR_FILE": "[[NIPOPPY_DPATH_DESCRIPTORS]]/bidseditor-[[NIPOPPY_PIPELINE_VERSION]].json" + }, + { + "NAME": "convert", + "INVOCATION_FILE": "[[NIPOPPY_DPATH_INVOCATIONS]]/[[NIPOPPY_PIPELINE_NAME]]-[[NIPOPPY_PIPELINE_VERSION]]-convert.json", + "DESCRIPTOR_FILE": "[[NIPOPPY_DPATH_DESCRIPTORS]]/bidscoiner-[[NIPOPPY_PIPELINE_VERSION]].json" + } + ] } ], "PROC_PIPELINES": [ diff --git a/nipoppy_cli/nipoppy/data/examples/sample_global_config-latest_pipelines.json b/nipoppy_cli/nipoppy/data/examples/sample_global_config-latest_pipelines.json index 95689247..e8221dd8 100644 --- a/nipoppy_cli/nipoppy/data/examples/sample_global_config-latest_pipelines.json +++ b/nipoppy_cli/nipoppy/data/examples/sample_global_config-latest_pipelines.json @@ -75,6 +75,27 @@ "UPDATE_DOUGHNUT": true } ] + }, + { + "NAME": "bidscoin", + "VERSION": "4.3.2", + "STEPS": [ + { + "NAME": "prepare", + "INVOCATION_FILE": "[[NIPOPPY_DPATH_INVOCATIONS]]/[[NIPOPPY_PIPELINE_NAME]]-[[NIPOPPY_PIPELINE_VERSION]]-prepare.json", + "DESCRIPTOR_FILE": "[[NIPOPPY_DPATH_DESCRIPTORS]]/bidsmapper-[[NIPOPPY_PIPELINE_VERSION]].json" + }, + { + "NAME": "edit", + "INVOCATION_FILE": "[[NIPOPPY_DPATH_INVOCATIONS]]/[[NIPOPPY_PIPELINE_NAME]]-[[NIPOPPY_PIPELINE_VERSION]]-edit.json", + "DESCRIPTOR_FILE": "[[NIPOPPY_DPATH_DESCRIPTORS]]/bidseditor-[[NIPOPPY_PIPELINE_VERSION]].json" + }, + { + "NAME": "convert", + "INVOCATION_FILE": "[[NIPOPPY_DPATH_INVOCATIONS]]/[[NIPOPPY_PIPELINE_NAME]]-[[NIPOPPY_PIPELINE_VERSION]]-convert.json", + "DESCRIPTOR_FILE": "[[NIPOPPY_DPATH_DESCRIPTORS]]/bidscoiner-[[NIPOPPY_PIPELINE_VERSION]].json" + } + ] } ], "PROC_PIPELINES": [ diff --git a/nipoppy_cli/nipoppy/data/examples/sample_invocations/bidscoin-4.3.2-convert.json b/nipoppy_cli/nipoppy/data/examples/sample_invocations/bidscoin-4.3.2-convert.json new file mode 100644 index 00000000..a6d709db --- /dev/null +++ b/nipoppy_cli/nipoppy/data/examples/sample_invocations/bidscoin-4.3.2-convert.json @@ -0,0 +1,7 @@ +{ + "sourcefolder": "[[NIPOPPY_DPATH_SOURCEDATA]]", + "bidsfolder": "[[NIPOPPY_DPATH_BIDS]]", + "participant_label": [ + "[[NIPOPPY_PARTICIPANT_ID]]" + ] +} diff --git a/nipoppy_cli/nipoppy/data/examples/sample_invocations/bidscoin-4.3.2-edit.json b/nipoppy_cli/nipoppy/data/examples/sample_invocations/bidscoin-4.3.2-edit.json new file mode 100644 index 00000000..748fbde8 --- /dev/null +++ b/nipoppy_cli/nipoppy/data/examples/sample_invocations/bidscoin-4.3.2-edit.json @@ -0,0 +1,3 @@ +{ + "bidsfolder": "[[NIPOPPY_DPATH_BIDS]]" +} diff --git a/nipoppy_cli/nipoppy/data/examples/sample_invocations/bidscoin-4.3.2-prepare.json b/nipoppy_cli/nipoppy/data/examples/sample_invocations/bidscoin-4.3.2-prepare.json new file mode 100644 index 00000000..2a8f6060 --- /dev/null +++ b/nipoppy_cli/nipoppy/data/examples/sample_invocations/bidscoin-4.3.2-prepare.json @@ -0,0 +1,4 @@ +{ + "sourcefolder": "[[NIPOPPY_DPATH_SOURCEDATA]]", + "bidsfolder": "[[NIPOPPY_DPATH_BIDS]]" +} diff --git a/nipoppy_cli/tests/test_default_config.py b/nipoppy_cli/tests/test_default_config.py index 62c99308..ce5e5a47 100644 --- a/nipoppy_cli/tests/test_default_config.py +++ b/nipoppy_cli/tests/test_default_config.py @@ -116,6 +116,9 @@ def test_pipeline_runner( ("heudiconv", "0.12.2", "convert"), ("dcm2bids", "3.1.0", "prepare"), ("dcm2bids", "3.1.0", "convert"), + ("bidscoin", "4.3.2", "prepare"), + ("bidscoin", "4.3.2", "edit"), + ("bidscoin", "4.3.2", "convert"), ], ) def test_bids_conversion_runner( @@ -131,7 +134,9 @@ def test_bids_conversion_runner( simulate=True, ) - runner.pipeline_config.get_fpath_container().touch() + fpath_container = runner.pipeline_config.get_fpath_container() + if fpath_container is not None: + runner.pipeline_config.get_fpath_container().touch() invocation_str, descriptor_str = runner.run_single( participant_id=participant_id, session_id=session_id