Skip to content

Commit

Permalink
BUG: extract task info
Browse files Browse the repository at this point in the history
  • Loading branch information
jungheejung committed Sep 1, 2024
1 parent bed44e8 commit ba46559
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 11 deletions.
11 changes: 7 additions & 4 deletions spacetop_prep/events/bidsify_fractional_combine.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ def get_task_name(bids_string, metadata_df):
# Convert subject_id to integer by removing the 'sub-' prefix
fname = Path(bids_string).stem
sub = extract_bids(fname, 'sub')
run = extract_bids(fname, 'run')
run = re.search(r'run-\d+', fname).group(0)
# run = extract_bids(fname, 'run')
subject_number = int(sub.replace('sub-', ''))

# Map run_id to task1 or task2
Expand Down Expand Up @@ -134,7 +135,8 @@ def parse_args():

sub = extract_bids(basename, 'sub')
ses = extract_bids(basename, 'ses')
run = extract_bids(basename, 'run')
run = re.search(r'run-\d+', basename).group(0)
# run = extract_bids(basename, 'run')
saxe_flist = list(Path(beh_inputdir).rglob(f'{sub}/task-fractional/*{sub}*{ses}*task-fractional*{run}*.csv')) # Search for the CSV file corresponding to the bids_string within the specified directory

if not saxe_flist:
Expand Down Expand Up @@ -298,7 +300,7 @@ def parse_args():
if 'posner' in extract_task_name:
sub = extract_bids(basename, 'sub')
ses = extract_bids(basename, 'ses')
run = extract_bids(basename, 'run')
run = re.search(r'run-\d+', basename).group(0) #extract_bids(basename, 'run')
# Search for the CSV file corresponding to the bids_string within the specified directory
posner_flist = list(Path(beh_inputdir).rglob(f'{sub}/task-fractional/*{sub}*{ses}*task-fractional*{run}*.csv'))

Expand Down Expand Up @@ -810,7 +812,8 @@ def parse_args():
# Extract the subject identifier from the bids_string
sub = extract_bids(basename, 'sub')
ses = extract_bids(basename, 'ses')
run = extract_bids(basename, 'run')
run = re.search(r'run-\d+', basename).group(0)
# run = extract_bids(basename, 'run')
# Search for the CSV file corresponding to the bids_string within the specified directory
spunt_flist = list(Path(beh_inputdir).rglob(f'{sub}/task-fractional/*{sub}*{ses}*task-fractional*{run}*.csv'))

Expand Down
20 changes: 13 additions & 7 deletions spacetop_prep/events/bidsify_fractional_subtask.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ def get_task_name(bids_string, metadata_df):
# Convert subject_id to integer by removing the 'sub-' prefix
fname = Path(bids_string).stem
sub = extract_bids(fname, 'sub')
run = extract_bids(fname, 'run')
run = re.search(r'run-\d+', fname).group(0)
# run = extract_bids(fname, 'run')
subject_number = int(sub.replace('sub-', ''))

# Map run_id to task1 or task2
Expand Down Expand Up @@ -120,7 +121,8 @@ def parse_args():
# Extract the subject identifier from the bids_string
sub = extract_bids(basename, 'sub')
ses = extract_bids(basename, 'ses')
run = extract_bids(basename, 'run')
run = re.search(r'run-\d+', basename).group(0)
# run = extract_bids(basename, 'run')
saxe_flist = list(Path(beh_inputdir).rglob(f'{sub}/**/task-fractional/**/*{sub}*{ses}*task-fractional*{run}*.csv')) # Search for the CSV file corresponding to the bids_string within the specified directory

if not saxe_flist:
Expand Down Expand Up @@ -152,7 +154,7 @@ def parse_args():

sub_bids = extract_bids(saxe_fname, 'sub') # re.search(r'sub-\d+', saxe_fname).group(0)
ses_bids = extract_bids(saxe_fname, 'ses') # re.search(r'ses-\d+', saxe_fname).group(0)
run_bids = extract_bids(saxe_fname, 'run') # re.search(r'run-\d+', saxe_fname).group(0)
run_bids = re.search(r'run-\d+', saxe_fname).group(0)
bids_name= f"{sub_bids}_{ses_bids}_{run_bids}"
task_name = get_task_name(bids_name, metadata_df)
# task_name = re.search(r'run-\d+-(\w+)_beh', saxe_fname).group(1)
Expand Down Expand Up @@ -285,7 +287,8 @@ def parse_args():
if 'posner' in extract_task_name:
sub = extract_bids(basename, 'sub')
ses = extract_bids(basename, 'ses')
run = extract_bids(basename, 'run')
run = re.search(r'run-\d+', basename).group(0)
# run = extract_bids(basename, 'run')
# Search for the CSV file corresponding to the bids_string within the specified directory
posner_flist = list(Path(beh_inputdir).rglob(f'{sub}/**/task-fractional/**/*{sub}*{ses}*task-fractional*{run}*.csv'))

Expand Down Expand Up @@ -511,7 +514,8 @@ def parse_args():
if 'memory' in extract_task_name:
sub = extract_bids(basename, 'sub')
ses = extract_bids(basename, 'ses')
run = extract_bids(basename, 'run')
run = re.search(r'run-\d+', basename).group(0)
# run = extract_bids(basename, 'run')

# Search for the CSV file corresponding to the bids_string within the specified directory
memory_flist = list(Path(beh_inputdir).rglob(f'{sub}/**/task-fractional/**/*{sub}*{ses}*task-fractional*{run}*.csv'))
Expand Down Expand Up @@ -542,7 +546,8 @@ def parse_args():
memory_fname = os.path.basename(memory_fpath)
sub_bids = extract_bids(memory_fname, 'sub')
ses_bids = extract_bids(memory_fname, 'ses')
run_bids = extract_bids(memory_fname, 'run')
run_bids = re.search(r'run-\d+', memory_fname).group(0)
# run_bids = extract_bids(memory_fname, 'run')
bids_name= f"{sub_bids}_{ses_bids}_{run_bids}"
task_name = get_task_name(bids_name, metadata_df)
print(f"{sub_bids} {ses_bids} {run_bids} {task_name}")
Expand Down Expand Up @@ -731,7 +736,8 @@ def parse_args():
# Extract the subject identifier from the bids_string
sub = extract_bids(basename, 'sub')
ses = extract_bids(basename, 'ses')
run = extract_bids(basename, 'run')
run = re.search(r'run-\d+', basename).group(0)
# run = extract_bids(basename, 'run')


# Search for the CSV file corresponding to the bids_string within the specified directory
Expand Down

0 comments on commit ba46559

Please sign in to comment.