Skip to content

Commit

Permalink
Merge pull request #8 from DCAN-Labs/hotfix/issue27
Browse files Browse the repository at this point in the history
replace hardcoded run number removal with regex
  • Loading branch information
kathy-snider authored Jan 26, 2021
2 parents 9fd8606 + 7c56a65 commit eda67d1
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions dcan_bold_proc.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
import subprocess
import shutil
import sys
import re

here = os.path.dirname(os.path.realpath(__file__))

Expand All @@ -46,7 +47,6 @@ def _cli():
"""
parser = generate_parser()
args = parser.parse_args()
print (args)

kwargs = {
'subject': args.subject,
Expand Down Expand Up @@ -216,7 +216,7 @@ def generate_parser(parser=None):
'determine motion filter parameters. Columns, start time, and '
'frequency will also need to be specified. NOT IMPLEMENTED.'
)


return parser

Expand Down Expand Up @@ -351,7 +351,9 @@ def interface(subject, output_folder, task=None, fd_threshold=None,
elif teardown:
output_results = os.path.join(output_folder, 'MNINonLinear', 'Results')
alltasks = os.listdir(output_results)
tasknames = sorted(list(set([d[:-2] for d in alltasks
expr = re.compile(r'.*(task-[^_]+).*([0-9]+).*')
#tasknames = sorted(list(set([d[:-2] for d in alltasks
tasknames = sorted(list(set([expr.match(d).group(1) for d in alltasks
if os.path.isdir(os.path.join(output_results,d))
and 'task-' in d])))

Expand All @@ -370,7 +372,9 @@ def interface(subject, output_folder, task=None, fd_threshold=None,
repetition_time = get_repetition_time(input_spec['fmri_volume'])
for concat in concatlist:
if len(concat) > 0:
taskset = concat[0][:-2]
#taskset = concat[0][:-2]
expr = re.compile(r'.*(task-[^_]+).*([0-9]+).*')
taskset = expr.match(concat[0]).group(1)

print('Running analyses_v2 on %s' % taskset)

Expand Down Expand Up @@ -582,7 +586,7 @@ def make_masks(segmentation, wm_mask_out, vent_mask_out, **kwargs):
'fslmaths {vent_mask_R} -add {vent_mask_L} -bin {vent_mask}',
'fslmaths {vent_mask} -kernel gauss {roi_res:g} -ero {vent_mask_out}'
]

# get params
defaults.update(kwargs)
kwargs.update(defaults)
Expand All @@ -602,7 +606,10 @@ def concatenate(concatlist, output_folder):

for concat in concatlist:
for i,task in enumerate(concat):
taskname = task[:-2]
#taskname = task[:-2]
expr = re.compile(r'.*(task-[^_]+).*([0-9]+).*')
taskname = expr.match(task).group(1)

base_results_folder = os.path.join(output_folder, 'MNINonLinear',
'Results')
input_task_dtseries = os.path.join(base_results_folder, task,
Expand Down

0 comments on commit eda67d1

Please sign in to comment.