Skip to content

Commit 932496f

Browse files
committed
not sure
1 parent 5a5644a commit 932496f

File tree

11 files changed

+464
-154
lines changed

11 files changed

+464
-154
lines changed

pyproject.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,11 @@ dependencies = [
2121
"acres",
2222
"datalad",
2323
"nipype",
24+
"nireports",
2425
"pandas",
2526
"pybids >= 0.15.6",
2627
"typer",
28+
"toml",
2729
"pyyaml",
2830
]
2931
dynamic = ["version"]

src/simbids/cli/parser.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,12 @@ def _bids_filter(value, parser):
146146
),
147147
)
148148

149+
parser.add_argument(
150+
'bids_app',
151+
choices=['qsiprep', 'qsirecon', 'xcp_d', 'fmriprep'],
152+
help=('BIDS-App to be simulated'),
153+
)
154+
149155
g_bids = parser.add_argument_group('Options for filtering BIDS queries')
150156
g_bids.add_argument(
151157
'--skip_bids_validation',
@@ -336,3 +342,4 @@ def parse_args(args=None, namespace=None):
336342
)
337343

338344
config.execution.participant_label = sorted(participant_label)
345+
return opts

src/simbids/cli/run.py

Lines changed: 6 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323
"""Simulated BIDS workflows."""
2424

2525
from simbids import config
26+
import sys
27+
import logging
2628

2729
EXITCODE: int = -1
2830

@@ -32,11 +34,11 @@ def main():
3234
import gc
3335
from multiprocessing import Manager, Process
3436

37+
from simbids.cli.parser import parse_args
3538
from simbids.cli.workflow import build_workflow
3639

37-
# Code Carbon
38-
if config.execution.track_carbon:
39-
pass
40+
# Parse arguments
41+
parse_args()
4042

4143
if 'pdb' in config.execution.debug:
4244
from simbids.utils.debug import setup_exceptionhook
@@ -51,22 +53,7 @@ def main():
5153
config_file.parent.mkdir(exist_ok=True, parents=True)
5254
config.to_filename(config_file)
5355

54-
# CRITICAL Call build_workflow(config_file, retval) in a subprocess.
55-
# Because Python on Linux does not ever free virtual memory (VM), running the
56-
# workflow construction jailed within a process preempts excessive VM buildup.
57-
if 'pdb' not in config.execution.debug:
58-
with Manager() as mgr:
59-
retval = mgr.dict()
60-
p = Process(target=build_workflow, args=(str(config_file), retval))
61-
p.start()
62-
p.join()
63-
retval = dict(retval.items()) # Convert to base dictionary
64-
65-
if p.exitcode:
66-
retval['return_code'] = p.exitcode
67-
68-
else:
69-
retval = build_workflow(str(config_file), {})
56+
retval = build_workflow(str(config_file), {})
7057

7158
global EXITCODE
7259
EXITCODE = retval.get('return_code', 0)

src/simbids/cli/workflow.py

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,6 @@ def build_workflow(config_file, retval):
3636
"""Create the Nipype Workflow that supports the whole execution graph."""
3737
from pathlib import Path
3838

39-
from fmriprep.utils.bids import check_pipeline_version
40-
from fmriprep.utils.misc import check_deps
4139
from niworkflows.utils.bids import collect_participants
4240
from pkg_resources import resource_filename as pkgrf
4341

@@ -64,15 +62,6 @@ def build_workflow(config_file, retval):
6462
banner += ['#' * len(banner[1])]
6563
build_log.log(25, f'\n{" " * 9}'.join(banner))
6664

67-
# warn if older results exist: check for dataset_description.json in output folder
68-
msg = check_pipeline_version(
69-
'SimBIDS',
70-
version,
71-
output_dir / 'dataset_description.json',
72-
)
73-
if msg is not None:
74-
build_log.warning(msg)
75-
7665
# Please note this is the input folder's dataset_description.json
7766
dset_desc_path = config.execution.bids_dir / 'dataset_description.json'
7867
if dset_desc_path.exists():
@@ -103,6 +92,7 @@ def build_workflow(config_file, retval):
10392
"Building SimBIDS's workflow:",
10493
f'BIDS dataset path: {config.execution.bids_dir}.',
10594
f'Participant list: {subject_list}.',
95+
f'BIDS-App: {config.workflow.bids_app}.',
10696
f'Run identifier: {config.execution.run_uuid}.',
10797
f'Output spaces: {config.execution.output_spaces}.',
10898
]
@@ -114,16 +104,6 @@ def build_workflow(config_file, retval):
114104

115105
retval['workflow'] = init_simbids_wf()
116106

117-
# Check workflow for missing commands
118-
missing = check_deps(retval['workflow'])
119-
if missing:
120-
build_log.critical(
121-
'Cannot run SimBIDS. Missing dependencies:%s',
122-
'\n\t* '.join([''] + [f'{cmd} (Interface: {iface})' for iface, cmd in missing]),
123-
)
124-
retval['return_code'] = 127 # 127 == command not found.
125-
return retval
126-
127107
config.to_filename(config_file)
128108
build_log.info(
129109
'SimBIDS workflow graph with %d nodes built successfully.',

src/simbids/config.py

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@
206206

207207
# Debug modes are names that influence the exposure of internal details to
208208
# the user, either through additional derivatives or increased verbosity
209-
DEBUG_MODES = 'pdb'
209+
DEBUG_MODES = ('pdb',)
210210

211211

212212
class _Config:
@@ -541,7 +541,7 @@ class workflow(_Config):
541541

542542
ignore = None
543543
"""Ignore particular steps for *SimBIDS*."""
544-
simulated_app = 'qsiprep'
544+
bids_app = 'qsiprep'
545545
"""The BIDS App to simulate."""
546546

547547

@@ -731,14 +731,6 @@ def init_spaces(checkpoint=True):
731731
if 'MNI152NLin6Asym' not in spaces.get_spaces(nonstandard=False, dim=(3,)):
732732
spaces.add(Reference('MNI152NLin6Asym', {}))
733733

734-
# Ensure user-defined spatial references for outputs are correctly parsed.
735-
# Certain options require normalization to a space not explicitly defined by users.
736-
# These spaces will not be included in the final outputs.
737-
cifti_output = workflow.cifti_output
738-
if cifti_output:
739-
# CIFTI grayordinates to corresponding FSL-MNI resolutions.
740-
vol_res = '2' if cifti_output == '91k' else '1'
741-
spaces.add(Reference('MNI152NLin6Asym', {'res': vol_res}))
742734

743735
# Make the SpatialReferences object available
744736
workflow.spaces = spaces

0 commit comments

Comments
 (0)