Skip to content

DataSink: Add possibility to replace regex match with another regex match in #3586

Open
@JohannesWiesner

Description

@JohannesWiesner

Summary

I have a feature request: It would be nice if it was possible to replace one regex-match with another one from the same input string for the the regexp_substitutions argument of nipype.interfaces.io.Datasink. Then one wouldn't have to define one substitution for every possible case. E.g. when the parameterization puts out something like this:

_subject_100206_task_WM
_subject_100206_task_EMOTION
_subject_100206_task_FACES

and I would like to have the folders like this:

WM
EMOTION
FACES

Then I currently have to do this:

datasink.inputs.regexp_substitutions = [('subject_[a-zA-Z0-9]+',''),
                                         ('_task_EMOTION','EMOTION'),
                                         ('_task_WM','WM'),
                                         ('_task_FACES','FACES')
                                        ]

It would be nice if one could use regex groups to something like (pseudo-code!):

datasink.inputs.regexp_substitutions = [('subject_[a-zA-Z0-9]+',''),
                                         ('_task_\w+','_task_(\w+)'),
                                        ]

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions