def import_datasets(method_list, out_dir, subjects, classes, feature_path, feature_type='dir_of_dirs'):
    "\n    Imports all the specified feature sets and organizes them into datasets.\n\n    Parameters\n    ----------\n    method_list : list of callables\n        Set of predefined methods returning a vector of features for a given sample id and location\n    out_dir : str\n        Path to the output folder\n\n    subjects : list of str\n        List of sample ids\n    classes : dict\n        Dict identifying the class for each sample id in the dataset.\n    feature_path : list of str\n        List of paths to the root directory containing the features (pre- or user-defined).\n        Must be of same length as method_list\n    feature_type : str\n        a string identifying the structure of feature set.\n        Choices = ('dir_of_dirs', 'data_matrix')\n\n    Returns\n    -------\n    method_names : list of str\n        List of method names used for annotation.\n    dataset_paths_file : str\n        Path to the file containing paths to imported feature sets.\n\n    "

    def clean_str(string):
        return ' '.join(string.strip().split(' _-:\n\r\t'))
    method_names = list()
    outpath_list = list()
    for (mm, cur_method) in enumerate(method_list):
        if (cur_method in [get_dir_of_dirs]):
            method_name = basename(feature_path[mm])
        elif (cur_method in [get_data_matrix]):
            method_name = os.path.splitext(basename(feature_path[mm]))[0]
        elif (cur_method in [get_pyradigm]):
            if (feature_type in ['pyradigm']):
                loaded_dataset = MLDataset(filepath=feature_path[mm])
            else:
                raise ValueError('Invalid state of the program!')
            if (len(loaded_dataset.description) > 1):
                method_name = loaded_dataset.description
            else:
                method_name = basename(feature_path[mm])
            method_names.append(clean_str(method_name))
            if saved_dataset_matches(loaded_dataset, subjects, classes):
                outpath_list.append(feature_path[mm])
                continue
            else:
                raise ValueError('supplied pyradigm dataset does not match samples in the meta data.')
        elif (cur_method in [get_arff]):
            loaded_dataset = MLDataset(arff_path=feature_path[mm])
            if (len(loaded_dataset.description) > 1):
                method_name = loaded_dataset.description
            else:
                method_name = basename(feature_path[mm])
            method_names.append(clean_str(method_name))
            out_name = make_dataset_filename(method_name)
            outpath_dataset = pjoin(out_dir, out_name)
            loaded_dataset.save(outpath_dataset)
            outpath_list.append(outpath_dataset)
            continue
        else:
            method_name = cur_method.__name__
        method_names.append(clean_str(method_name))
        out_name = make_dataset_filename(method_name)
        outpath_dataset = pjoin(out_dir, out_name)
        if (not saved_dataset_matches(outpath_dataset, subjects, classes)):
            outpath_dataset = get_features(subjects, classes, feature_path[mm], out_dir, out_name, cur_method, feature_type)
        outpath_list.append(outpath_dataset)
    combined_name = uniq_combined_name(method_names)
    dataset_paths_file = pjoin(out_dir, (('datasetlist.' + combined_name) + '.txt'))
    with open(dataset_paths_file, 'w') as dpf:
        dpf.writelines('\n'.join(outpath_list))
    return (method_names, dataset_paths_file)
Imports all the specified feature sets and organizes them into datasets.

Parameters
----------
method_list : list of callables
    Set of predefined methods returning a vector of features for a given sample id and location
out_dir : str
    Path to the output folder

subjects : list of str
    List of sample ids
classes : dict
    Dict identifying the class for each sample id in the dataset.
feature_path : list of str
    List of paths to the root directory containing the features (pre- or user-defined).
    Must be of same length as method_list
feature_type : str
    a string identifying the structure of feature set.
    Choices = ('dir_of_dirs', 'data_matrix')

Returns
-------
method_names : list of str
    List of method names used for annotation.
dataset_paths_file : str
    Path to the file containing paths to imported feature sets.
def import_datasets(method_list, out_dir, subjects, classes, feature_path, feature_type='dir_of_dirs'):
    "\n    Imports all the specified feature sets and organizes them into datasets.\n\n    Parameters\n    ----------\n    method_list : list of callables\n        Set of predefined methods returning a vector of features for a given sample id and location\n    out_dir : str\n        Path to the output folder\n\n    subjects : list of str\n        List of sample ids\n    classes : dict\n        Dict identifying the class for each sample id in the dataset.\n    feature_path : list of str\n        List of paths to the root directory containing the features (pre- or user-defined).\n        Must be of same length as method_list\n    feature_type : str\n        a string identifying the structure of feature set.\n        Choices = ('dir_of_dirs', 'data_matrix')\n\n    Returns\n    -------\n    method_names : list of str\n        List of method names used for annotation.\n    dataset_paths_file : str\n        Path to the file containing paths to imported feature sets.\n\n    "

    def clean_str(string):
        return ' '.join(string.strip().split(' _-:\n\r\t'))
    method_names = list()
    outpath_list = list()
    for (mm, cur_method) in enumerate(method_list):
        if (cur_method in [get_dir_of_dirs]):
            method_name = basename(feature_path[mm])
        elif (cur_method in [get_data_matrix]):
            method_name = os.path.splitext(basename(feature_path[mm]))[0]
        elif (cur_method in [get_pyradigm]):
            if (feature_type in ['pyradigm']):
                loaded_dataset = MLDataset(filepath=feature_path[mm])
            else:
                raise ValueError('Invalid state of the program!')
            if (len(loaded_dataset.description) > 1):
                method_name = loaded_dataset.description
            else:
                method_name = basename(feature_path[mm])
            method_names.append(clean_str(method_name))
            if saved_dataset_matches(loaded_dataset, subjects, classes):
                outpath_list.append(feature_path[mm])
                continue
            else:
                raise ValueError('supplied pyradigm dataset does not match samples in the meta data.')
        elif (cur_method in [get_arff]):
            loaded_dataset = MLDataset(arff_path=feature_path[mm])
            if (len(loaded_dataset.description) > 1):
                method_name = loaded_dataset.description
            else:
                method_name = basename(feature_path[mm])
            method_names.append(clean_str(method_name))
            out_name = make_dataset_filename(method_name)
            outpath_dataset = pjoin(out_dir, out_name)
            loaded_dataset.save(outpath_dataset)
            outpath_list.append(outpath_dataset)
            continue
        else:
            method_name = cur_method.__name__
        method_names.append(clean_str(method_name))
        out_name = make_dataset_filename(method_name)
        outpath_dataset = pjoin(out_dir, out_name)
        if (not saved_dataset_matches(outpath_dataset, subjects, classes)):
            outpath_dataset = get_features(subjects, classes, feature_path[mm], out_dir, out_name, cur_method, feature_type)
        outpath_list.append(outpath_dataset)
    combined_name = uniq_combined_name(method_names)
    dataset_paths_file = pjoin(out_dir, (('datasetlist.' + combined_name) + '.txt'))
    with open(dataset_paths_file, 'w') as dpf:
        dpf.writelines('\n'.join(outpath_list))
    return (method_names, dataset_paths_file)