Skip to content

Commit 75bd720

Browse files
committed
fix cubids validate --participant-label
1 parent 9ab2c88 commit 75bd720

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

cubids/workflows.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ def _link_or_copy(src_path, dst_path):
128128
os.makedirs(subject_folder_path, exist_ok=True)
129129

130130
# Ensure participants.tsv is available in temp root
131-
# copy from original file list if missing
131+
# Always COPY (never link) to avoid modifying the original file when filtering
132132
participants_tsv_path = os.path.join(temporary_bids_dir, "participants.tsv")
133133
if not os.path.exists(participants_tsv_path):
134134
# Try to find a source participants.tsv in the provided file list
@@ -144,7 +144,8 @@ def _link_or_copy(src_path, dst_path):
144144
if os.path.exists(potential_path):
145145
source_participants_tsv_path = potential_path
146146
if source_participants_tsv_path:
147-
_link_or_copy(source_participants_tsv_path, participants_tsv_path)
147+
# Always copy (not link) to protect the original file from modification
148+
shutil.copy2(source_participants_tsv_path, participants_tsv_path)
148149
except Exception: # noqa: BLE001
149150
pass
150151

@@ -402,7 +403,7 @@ def _link_or_copy(src_path, dst_path):
402403
if not os.path.exists(subject_folder_path):
403404
os.makedirs(subject_folder_path, exist_ok=True)
404405

405-
# Ensure participants.tsv exists; copy if missing, then filter
406+
# Ensure participants.tsv exists
406407
participants_tsv_path = os.path.join(temporary_bids_dir, "participants.tsv")
407408
if not os.path.exists(participants_tsv_path):
408409
try:
@@ -417,7 +418,8 @@ def _link_or_copy(src_path, dst_path):
417418
if os.path.exists(potential_path):
418419
source_participants_tsv_path = potential_path
419420
if source_participants_tsv_path:
420-
_link_or_copy(source_participants_tsv_path, participants_tsv_path)
421+
# Always copy (not link) to protect original file
422+
shutil.copy2(source_participants_tsv_path, participants_tsv_path)
421423
except Exception: # noqa: BLE001
422424
pass
423425

0 commit comments

Comments
 (0)