Skip to content

Commit 33756d2

Browse files
committed
🔊 Improve dropped variant logging
1 parent 2bff2a5 commit 33756d2

File tree

4 files changed

+18
-7
lines changed

4 files changed

+18
-7
lines changed

CPAC/anat_preproc/anat_preproc.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -695,13 +695,15 @@ def afni_brain_connector(wf, cfg, strat_pool, pipe_num, opt):
695695

696696
wf.connect(anat_skullstrip, "out_file", anat_brain_mask, "in_file_a")
697697

698+
outputs = {}
699+
698700
if strat_pool.check_rpool("desc-preproc_T1w"):
699701
outputs = {"space-T1w_desc-brain_mask": (anat_brain_mask, "out_file")}
700702

701703
elif strat_pool.check_rpool("desc-preproc_T2w"):
702704
outputs = {"space-T2w_desc-brain_mask": (anat_brain_mask, "out_file")}
703705

704-
return (wf, outputs)
706+
return wf, outputs
705707

706708

707709
def fsl_brain_connector(wf, cfg, strat_pool, pipe_num, opt):
@@ -1392,9 +1394,8 @@ def mask_T2(wf_name="mask_T2"):
13921394
)
13931395
def anatomical_init(wf, cfg, strat_pool, pipe_num, opt=None):
13941396
if opt not in anatomical_init.option_val:
1395-
raise ValueError(
1396-
f"\n[!] Error: Invalid option for deoblique: {opt}. \nExpected one of {anatomical_init.option_val}"
1397-
)
1397+
msg = f"\n[!] Error: Invalid option for deoblique: {opt}. \nExpected one of {anatomical_init.option_val}"
1398+
raise ValueError(msg)
13981399

13991400
if opt == "warp":
14001401
anat_deoblique = pe.Node(
@@ -2004,6 +2005,7 @@ def brain_mask_acpc_freesurfer(wf, cfg, strat_pool, pipe_num, opt=None):
20042005
functions = {
20052006
"FreeSurfer-ABCD": freesurfer_abcd_brain_connector,
20062007
"FreeSurfer-Brainmask": freesurfer_brain_connector,
2008+
"FreeSurfer-BET-Loose": freesurfer_fsl_brain_connector,
20072009
"FreeSurfer-BET-Tight": freesurfer_fsl_brain_connector,
20082010
}
20092011
if opt in ["FreeSurfer-BET-Loose", "FreeSurfer-BET-Tight"]:

CPAC/anat_preproc/tests/test_anat_preproc.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ def test_anat_brain(self):
289289

290290
@pytest.mark.parametrize("opt", ["FreeSurfer-BET-Loose", "FreeSurfer-BET-Tight"])
291291
@pytest.mark.parametrize("t1w", ["desc-restore_T1w", "desc-preproc_T1w"])
292-
def test_brain_mask_freesurfer_fsl_real(opt: str, t1w: str):
292+
def test_brain_mask_freesurfer_fsl(opt: str, t1w: str):
293293
"""Test that brain_mask_freesurfer_fsl correctly generates output key using real code."""
294294
# Create minimal mocks for required workflow/config/strat_pool, but do not patch freesurfer_fsl_brain_connector
295295

CPAC/pipeline/engine.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
from CPAC.pipeline.nodeblock import NodeBlockFunction
4444
from CPAC.pipeline.utils import (
4545
CrossedVariantsError,
46+
find_variants,
4647
MOVEMENT_FILTER_KEYS,
4748
name_fork,
4849
short_circuit_crossed_variants,
@@ -860,7 +861,10 @@ def get_strats(self, resources, debug: bool | str = False):
860861
except CrossedVariantsError:
861862
if debug:
862863
verbose_logger = getLogger("CPAC.engine")
863-
verbose_logger.debug("Dropped crossed variants strat: %s", pipe_idx)
864+
verbose_logger.debug(
865+
"Dropped crossed variants strat: %s",
866+
find_variants(strat_pool, resources),
867+
)
864868
continue
865869
if debug:
866870
verbose_logger = getLogger("CPAC.engine")
@@ -1634,6 +1638,11 @@ def connect_block(self, wf, cfg, rpool):
16341638
opts.append(option_val)
16351639
else: # AND, if there are multiple option-val's (in a list) in the docstring, it gets iterated below in 'for opt in option' etc. AND THAT'S WHEN YOU HAVE TO DELINEATE WITHIN THE NODE BLOCK CODE!!!
16361640
opts = [None]
1641+
if debug:
1642+
verbose_logger = getLogger("CPAC.engine")
1643+
verbose_logger.debug(
1644+
f"[connect_block] opts resolved for {name}: {opts}"
1645+
)
16371646
all_opts += opts
16381647

16391648
sidecar_additions = {

CPAC/registration/registration.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3311,7 +3311,7 @@ def coregistration_prep_fmriprep(wf, cfg, strat_pool, pipe_num, opt=None):
33113311
),
33123312
(
33133313
"desc-preproc_T1w",
3314-
["desc-restore-brain_T1w", "desc-preproc_T1w"],
3314+
"desc-restore-brain_T1w",
33153315
"desc-preproc_T2w",
33163316
"desc-preproc_T2w",
33173317
"T2w",

0 commit comments

Comments
 (0)