Skip to content

Commit ccfdb34

Browse files
authored
Apply suggestions from code review
- change participant_label and session_id to default to None - add accompanying flow control logic for using None as the default
1 parent 200c5e9 commit ccfdb34

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/dsst_defacing_wf.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,13 @@ def get_args():
2323
parser.add_argument('-n', '--n-cpus', type=int, default=1,
2424
help='Number of parallel processes to run when there is more than one folder. '
2525
'Defaults to 1, meaning "serial processing".')
26-
parser.add_argument('-p', '--participant-label', nargs="+", type=str,
26+
parser.add_argument('-p', '--participant-label', nargs="+", type=str, default=None,
2727
help='The label(s) of the participant(s) that should be defaced. The label '
2828
'corresponds to sub-<participant_label> from the BIDS spec '
2929
'(so it does not include "sub-"). If this parameter is not '
3030
'provided all subjects should be analyzed. Multiple '
3131
'participants can be specified with a space separated list.')
32-
parser.add_argument('-s', '--session-id', nargs="+", type=str,
32+
parser.add_argument('-s', '--session-id', nargs="+", type=str, default=None,
3333
help='The ID(s) of the session(s) that should be defaced. The label '
3434
'corresponds to ses-<session_id> from the BIDS spec '
3535
'(so it does not include "ses-"). If this parameter is not '
@@ -70,23 +70,23 @@ def main():
7070

7171
to_deface = []
7272
# for one subject or list of subjects (and all their sessions, if present)
73-
if args.participant_label:
73+
if args.participant_label != None:
7474
for p in args.participant_label:
7575
to_deface.extend(glob(os.path.join(args.bids_dir, f'sub-{p}', "ses-*")))
7676
if not to_deface:
7777
to_deface = glob(os.path.join(args.bids_dir, f'sub-{p}'))
7878

7979
# only for one subset of sessions
80-
if args.session_id:
80+
if args.session_id != None:
8181
for s in args.session_id:
8282
to_deface = glob(os.path.join(args.bids_dir, "sub-*", f'ses-{s}'))
8383
# for all sessions
84-
if not (args.participant_label or args.session_id):
84+
if args.participant_label == None and args.session_id == None:
8585
session_check = glob(os.path.join(args.bids_dir, "sub-*", "ses-*"))
8686
if session_check:
8787
to_deface = session_check
8888

89-
# for all subjects
89+
# for all subjects (without "ses-*" session directories)
9090
else:
9191
to_deface = glob(os.path.join(args.bids_dir, "sub-*"))
9292

0 commit comments

Comments
 (0)