Skip to content

Commit d4dc1b1

Browse files
updated path handling
1 parent 926b9c4 commit d4dc1b1

File tree

2 files changed

+28
-9
lines changed

2 files changed

+28
-9
lines changed

micaflow/cli.py

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1223,12 +1223,18 @@ def find_file(base, subfolder, suffix, desc):
12231223
cmd.extend(["--dwi-file", os.path.abspath(dwi)])
12241224
cmd.extend(["--bval-file", os.path.abspath(bval_file)])
12251225
cmd.extend(["--bvec-file", os.path.abspath(bvec_file)])
1226+
else:
1227+
# FIX: Explicitly pass empty strings to clear potential cache/defaults in pipeline
1228+
cmd.extend(["--dwi-file", ""])
1229+
cmd.extend(["--bval-file", ""])
1230+
cmd.extend(["--bvec-file", ""])
12261231

12271232
if inv_dwi:
12281233
cmd.extend(["--inverse-dwi-file", os.path.abspath(inv_dwi)])
1229-
if inv_bval_file:
1230-
cmd.extend(["--inverse-bval-file", os.path.abspath(inv_bval_file)])
1231-
cmd.extend(["--inverse-bvec-file", os.path.abspath(inv_bvec_file)])
1234+
cmd.extend(["--inverse-bval-file", os.path.abspath(inv_bval_file) if inv_bval_file else ""])
1235+
cmd.extend(["--inverse-bvec-file", os.path.abspath(inv_bvec_file) if inv_bvec_file else ""])
1236+
else:
1237+
cmd.extend(["--inverse-dwi-file", ""])
12321238

12331239
# Passthrough args
12341240
if args.gpu: cmd.append("--gpu")
@@ -1243,6 +1249,10 @@ def find_file(base, subfolder, suffix, desc):
12431249
cmd.extend(["--PED", args.PED])
12441250
cmd.extend(["--shell-dimension", str(args.shell_dimension)])
12451251

1252+
# FIX: Pass unknown arguments (like --unlock, --rerun-incomplete) to the pipeline
1253+
if unknown:
1254+
cmd.extend(unknown)
1255+
12461256
# 6. Execute and Log
12471257
print(f"{Fore.CYAN}Launching pipeline for {sub_ses_str}...{Style.RESET_ALL}")
12481258

@@ -1284,7 +1294,8 @@ def find_file(base, subfolder, suffix, desc):
12841294
"bval": bval_file,
12851295
"bvec": bvec_file,
12861296
"inverse_dwi": inv_dwi,
1287-
"inverse_bval": inv_bval_file
1297+
"inverse_bval": inv_bval_file,
1298+
"inverse_bvec": inv_bvec_file
12881299
},
12891300
"config": {
12901301
"linear": args.linear,
@@ -1359,8 +1370,10 @@ def find_file(base, subfolder, suffix, desc):
13591370
"linear",
13601371
"nonlinear"
13611372
]:
1362-
if getattr(args, param.replace("-", "_"), None):
1363-
config[param] = getattr(args, param.replace("-", "_"))
1373+
# FIX: Check if argument is strictly not None (allow empty strings to override cache)
1374+
val = getattr(args, param.replace("-", "_"), None)
1375+
if val is not None:
1376+
config[param] = val
13641377

13651378
# Add config parameters to command
13661379
if len(config) > 0:
@@ -1694,6 +1707,8 @@ def find_file(base, subfolder, suffix, desc):
16941707
sdc_args.append(f"--{arg_name_formatted}")
16951708
sdc_args.append(str(arg_value))
16961709

1710+
1711+
16971712
# Run the SDC script
16981713
try:
16991714
print(f"Running susceptibility distortion correction on {args.input}...")

micaflow/resources/Snakefile

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -133,10 +133,14 @@ def _get_validated_params():
133133
print("ATLAS_DIR: ", ATLAS_DIR)
134134
print(f"Temporary directory: {TEMP_DIR}")
135135

136+
# FIX: Ensure all file paths are strings (handle None -> "") before passing to check_paths
137+
def safe_str(val):
138+
return "" if val is None else str(val)
139+
136140
result = check_paths(
137-
DATA_DIRECTORY, OUT_DIR, SUBJECT, SESSION, GPU,
138-
FLAIR_FILE, T1W_FILE, DWI_FILE, BVAL_FILE, BVEC_FILE,
139-
INVERSE_DWI_FILE, INVERSE_BVAL_FILE, INVERSE_BVEC_FILE, THREADS
141+
safe_str(DATA_DIRECTORY), safe_str(OUT_DIR), safe_str(SUBJECT), safe_str(SESSION), safe_str(GPU),
142+
safe_str(FLAIR_FILE), safe_str(T1W_FILE), safe_str(DWI_FILE), safe_str(BVAL_FILE), safe_str(BVEC_FILE),
143+
safe_str(INVERSE_DWI_FILE), safe_str(INVERSE_BVAL_FILE), safe_str(INVERSE_BVEC_FILE), THREADS
140144
)
141145

142146
(data_dir, out_dir, subject, session, run_dwi, gpu,

0 commit comments

Comments
 (0)