def get_script_sub_ses_and_task_from_cmd(cmd_parts):
    """
    :param cmd_parts: List of string parts of complete command calling pipeline
    :return: Dictionary mapping each of several pipeline .py script flags 
             to the index of its value in split_cmd
    """
    flags_to_find = ['-subject', '-ses', '-task']
    flags_found = dict()
    for cmd_ix in range(len(cmd_parts)):
        each_flag = cmd_parts[cmd_ix]
        if 'script' not in flags_found and each_flag[-2:] == '.py':
            flags_found['script'] = cmd_ix
        for each_flag in flags_to_find:
            if cmd_parts[cmd_ix][-len(each_flag):] == each_flag:
                flags_to_find.pop(flags_to_find.index(each_flag))
                flags_found[each_flag[1:]] = cmd_ix + 1
    return flags_found