Skip to content

Commit ad54b9c

Browse files
authored
Add --force-unlock to copy-exemplars and fix path to script in apply (#346)
* added parsing of --force-unlock argument * added code lines to build exemplars_tsv path * modified naming of shell script used in apply function, to be saved into BIDS dir, as expected * Adjusted parser.add_argument help sections according to previous edits * removed whitespace
1 parent d90fdf3 commit ad54b9c

File tree

2 files changed

+18
-5
lines changed

2 files changed

+18
-5
lines changed

cubids/cli.py

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -443,8 +443,8 @@ def _parse_copy_exemplars():
443443
type=PathExists,
444444
action="store",
445445
help=(
446-
"absolute path to the root of a BIDS dataset "
447-
"containing one subject from each Acquisition Group. "
446+
"name of the directory to create where to store exemplar dataset. "
447+
"It will include one subject from each Acquisition Group. "
448448
"It should contain sub-X directories and "
449449
"dataset_description.json."
450450
),
@@ -454,9 +454,12 @@ def _parse_copy_exemplars():
454454
type=IsFile,
455455
action="store",
456456
help=(
457-
"absolute path to the .tsv file that lists one "
457+
"path to the .tsv that lists one "
458458
"subject from each Acquisition Group "
459-
"(*_AcqGrouping.tsv from the cubids-group output)"
459+
"(*_AcqGrouping.tsv from the cubids-group output). "
460+
"If the file is located in the code/CuBIDS "
461+
"directory, then users can just pass the .tsv "
462+
"filename instead of the full path "
460463
),
461464
)
462465
parser.add_argument(
@@ -489,6 +492,12 @@ def _parse_copy_exemplars():
489492
action="store",
490493
help="Docker image tag or Singularity image file.",
491494
)
495+
parser.add_argument(
496+
"--force-unlock",
497+
action="store_true",
498+
default=False,
499+
help="unlock dataset before adding nifti info ",
500+
)
492501
return parser
493502

494503

cubids/cubids.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -416,7 +416,7 @@ def apply_tsv_changes(self, summary_tsv, files_tsv, new_prefix, raise_on_error=T
416416

417417
full_cmd = "\n".join(merge_commands + move_ops)
418418
if full_cmd:
419-
renames = new_prefix + "_full_cmd.sh"
419+
renames = str(Path(self.path) / (new_prefix + "_full_cmd.sh"))
420420

421421
# write full_cmd to a .sh file
422422
with open(renames, "w") as fo:
@@ -683,6 +683,10 @@ def copy_exemplars(self, exemplars_dir, exemplars_tsv, min_group_size):
683683
exemplars_dir,
684684
]
685685
)
686+
if os.sep not in str(exemplars_tsv):
687+
if not self.cubids_code_dir:
688+
self.create_cubids_code_dir()
689+
exemplars_tsv = self.path + "/code/CuBIDS/" + exemplars_tsv
686690

687691
# load the exemplars tsv
688692
subs = pd.read_table(exemplars_tsv)

0 commit comments

Comments
 (0)