Skip to content

Commit

Permalink
Merge pull request #123 from eugenegkim/switch-subj-sess
Browse files Browse the repository at this point in the history
add options to switch subject/session/study IDs
  • Loading branch information
dvm-shlee authored Jan 31, 2024
2 parents 5f08c58 + 545fbba commit 2949556
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 5 deletions.
4 changes: 2 additions & 2 deletions brkraw/lib/pvobj.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ def _update_studyinfo(self):
subject = self._subject
self.user_account = subject.headers['OWNER']
self.subj_id = get_value(subject, 'SUBJECT_id')
self.study_id = get_value(subject, 'SUBJECT_study_nr')
self.session_id = get_value(subject, 'SUBJECT_study_name')
self.study_id = get_value(subject, 'SUBJECT_study_name')
self.session_id = get_value(subject, 'SUBJECT_study_nr')

# [20210820] Add-paravision 360 related.
title = subject.headers['TITLE']
Expand Down
21 changes: 18 additions & 3 deletions brkraw/scripts/brkraw.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,8 @@ def main():
bids_helper.add_argument("-f", "--format", help="file format of BIDS dataheets. Use this option if you did not specify the extension on output. The available options are (csv/tsv/xlsx) (default: csv)", type=str, default='csv')
bids_helper.add_argument("-j", "--json", help="create JSON syntax template for "
"parsing metadata from the header", action='store_true')
bids_helper.add_argument("-s", "--subj", help="switch subject and study IDs", action='store_true')
bids_helper.add_argument("-t", "--sess", help="switch session and study ID", action='store_true')

# bids_convert
bids_convert.add_argument("input", help=input_dir_str, type=str)
Expand Down Expand Up @@ -267,6 +269,12 @@ def main():
path = os.path.abspath(args.input)
ds_output = os.path.abspath(args.output)
make_json = args.json
swap_id = args.subj
swap_sess = args.sess

if swap_id and swap_sess:
import warnings
warnings.warn('\nBoth switch subject/study IDs and switch session/study ID options are on. You probably do not want this!\n')

# [220202] for back compatibility
ds_fname, ds_output_ext = os.path.splitext(ds_output)
Expand Down Expand Up @@ -301,12 +309,19 @@ def main():
pvobj = dset.pvobj

rawdata = pvobj.path
subj_id = pvobj.subj_id

if swap_id:
subj_id = pvobj.study_id
else:
subj_id = pvobj.subj_id

if swap_sess:
sess_id = pvobj.study_id
else:
sess_id = pvobj.session_id

# make subj_id bids appropriate
subj_id = cleanSubjectID(subj_id)

sess_id = pvobj.session_id

# make sess_id bids appropriate
sess_id = cleanSessionID(sess_id)
Expand Down

0 comments on commit 2949556

Please sign in to comment.