Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[HOTFIX] Fix UnboundLocalError in utils.bids #285

Merged
merged 7 commits into from Jan 24, 2019
Merged
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
28 changes: 12 additions & 16 deletions niworkflows/utils/bids.py
Expand Up @@ -167,22 +167,18 @@ def collect_data(dataset, participant_label, task=None, echo=None):
subj_data = {modality: [x.filename for x in layout.get(**query)]
for modality, query in queries.items()}

def _grp_echos(x):
if '_echo-' not in x:
return x
echo = re.search("_echo-\\d*", x).group(0)
return x.replace(echo, "_echo-?")

if subj_data["bold"]:
bold_sess = subj_data["bold"]

if any(['_echo-' in bold for bold in bold_sess]):
ses_uids = [list(bold) for _, bold in groupby(bold_sess, key=_grp_echos)]
ses_uids = [x[0] if len(x) == 1 else x for x in ses_uids]
else:
ses_uids = bold_sess

subj_data.update({"bold": ses_uids})
if any(['_echo-' in bold for bold in subj_data['bold']]):
# Special case: multi-echo BOLD, grouping echos
def _grp_echos(x):
if '_echo-' not in x:
return x
echo = re.search("_echo-\\d*", x).group(0)
return x.replace(echo, "_echo-?")

bold_sess = subj_data['bold']
ses_uids = [list(bold) for _, bold in groupby(bold_sess, key=_grp_echos)]
ses_uids = [x[0] if len(x) <= 2 else x for x in ses_uids]
oesteban marked this conversation as resolved.
Show resolved Hide resolved
subj_data.update({"bold": ses_uids})

return subj_data, layout

Expand Down