From 5aff4f4a90ecb8bdb732be3b05576ad9d263ac4a Mon Sep 17 00:00:00 2001 From: Remi Gau Date: Wed, 10 Jul 2024 14:36:51 +0200 Subject: [PATCH] add temp script for boutiques and bids model graph --- WIP/boutiques/bidspm.json | 103 ----------------------------- WIP/boutiques/invocation.json | 9 --- WIP/create_boutiques_descriptor.py | 15 +++++ WIP/write_model_graph.py | 11 +++ src/bidspm/parsers.py | 2 +- 5 files changed, 27 insertions(+), 113 deletions(-) delete mode 100644 WIP/boutiques/bidspm.json delete mode 100644 WIP/boutiques/invocation.json create mode 100644 WIP/create_boutiques_descriptor.py create mode 100644 WIP/write_model_graph.py diff --git a/WIP/boutiques/bidspm.json b/WIP/boutiques/bidspm.json deleted file mode 100644 index 4768d4b9d..000000000 --- a/WIP/boutiques/bidspm.json +++ /dev/null @@ -1,103 +0,0 @@ -{ - "name": "bidspm", - "command-line": "bidspm [InputDataset] [OutputLocation] [AnalysisLevel] [ParticipantLabel] [Action]", - "container-image": { - "image": "bids/example", - "type": "docker" - }, - "description": "See https://github.com/cpp-lln-lab/bidspm.git", - "inputs": [ - { - "description": "The directory with the input dataset formatted according to the BIDS standard.", - "id": "InputDataset", - "name": "Input datasets", - "value-key": "[InputDataset]", - "type": "File", - "list": false, - "optional": false, - "command-line-flag": "--input-datasets" - }, - { - "description": "The directory where the output files should be stored. If you are running a group level analysis, this folder should be prepopulated with the results of the participant level analysis.", - "id": "OutputLocation", - "name": "Output location", - "value-key": "[OutputLocation]", - "type": "File", - "list": false, - "optional": false, - "command-line-flag": "--output-location" - }, - { - "description": "Level of the analysis that will be performed. Multiple participant level analyses can be run independently (in parallel).", - "id": "AnalysisLevel", - "name": "Analysis level", - "value-key": "[AnalysisLevel]", - "type": "String", - "optional": false, - "list": false, - "value-choices": [ - "subject", - "dataset" - ], - "default": "subject", - "command-line-flag": "--analysis-level" - }, - { - "description": "The label(s) of the participant(s) that should be analyzed. The label corresponds to sub- from the BIDS spec (so it does not include \"sub-\"). If this parameter is not provided all subjects will be analyzed. Multiple participants can be specified with a space separated list.", - "id": "SubjectLabel", - "name": "Subject labels", - "value-key": "[SubjectLabel]", - "type": "String", - "list": true, - "optional": false, - "command-line-flag": "--participant-label" - }, - { - "description": "Action to perform", - "id": "Action", - "name": "Action", - "value-key": "[Action]", - "type": "String", - "list": false, - "value-choices": [ - "preprocess", - "stats" - ], - "optional": false, - "command-line-flag": "--action" - }, - { - "description": " Path to a JSON file to filter input file", - "id": "BidsFileFilter", - "name": "Bids file filter", - "value-key": "[BidsFileFilter]", - "type": "File", - "default": "", - "list": false, - "optional": true, - "command-line-flag": "--bids-filter-file" - }, - { - "description": "for debugging", - "id": "DryRun", - "name": "Dry run", - "value-key": "[DryRun]", - "type": "File", - "default": false, - "list": false, - "optional": true, - "command-line-flag": "--dry-run" - } - ], - "output-files": [ - { - "description": "The directory where the output files should be stored. If you are running a group level analysis, this folder should be prepopulated with the results of the participant level analysis.", - "id": "OutputLocation", - "name": "Output location", - "optional": false, - "path-template": "OutputLocation" - } - ], - "schema-version": "0.5", - "tool-version": "dev" -} diff --git a/WIP/boutiques/invocation.json b/WIP/boutiques/invocation.json deleted file mode 100644 index 3c0c56832..000000000 --- a/WIP/boutiques/invocation.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "bids_dir": "ds001", - "output_dir_name": "example-output", - "analysis_level": "subject", - "participant_label": [ - "01" - ], - "action": "preprocess" -} diff --git a/WIP/create_boutiques_descriptor.py b/WIP/create_boutiques_descriptor.py new file mode 100644 index 000000000..313c7730a --- /dev/null +++ b/WIP/create_boutiques_descriptor.py @@ -0,0 +1,15 @@ +import boutiques.creator as bc + +from bidspm.parsers import common_parser + +newDescriptor = bc.CreateDescriptor(common_parser(), execname="bidspm") + +newDescriptor.save("my-new-descriptor.json") + +# args = common_parser.parse_args() +# invoc = newDescriptor.createInvocation(args) + +# # Then, if you want to save them to a file... +# import json +# with open('my-inputs.json', 'w') as fhandle: +# fhandle.write(json.dumps(invoc, indent=4)) diff --git a/WIP/write_model_graph.py b/WIP/write_model_graph.py new file mode 100644 index 000000000..798f99004 --- /dev/null +++ b/WIP/write_model_graph.py @@ -0,0 +1,11 @@ +from pathlib import Path + +from bids.modeling.statsmodels import BIDSStatsModelsGraph + +graph = BIDSStatsModelsGraph( + layout=Path("/home/remi/github/cpp-lln-lab/bidspm/demos/MoAE/inputs/raw"), + model="/home/remi/github/cpp-lln-lab/bidspm/demos/openneuro/models/model-narps_desc-U26C_smdl.json", +) + + +graph.write_graph() diff --git a/src/bidspm/parsers.py b/src/bidspm/parsers.py index c4dcd2a52..a89e8580c 100644 --- a/src/bidspm/parsers.py +++ b/src/bidspm/parsers.py @@ -289,7 +289,7 @@ def common_parser() -> argparse.ArgumentParser: type=str, nargs=1, default="neuromorphometrics", - choices=SUPPORTED_ATLASES, + choices=list(SUPPORTED_ATLASES), ) stats_only = parser.add_argument_group("stats only arguments")