Exemple #1
0
def resources(tmpdir_factory):
    """Set up."""
    r = namedtuple("resources", "data_path")
    r.features = rois[:3]
    r.regression_features = [
        "Age",
        "summary_gm_median",
        "spacing_x",
        "summary_gm_p95",
        "cnr",
        "size_x",
        "cjv",
        "summary_wm_mean",
        "icvs_gm",
        "wm2max",
    ]
    r.covariates = ["Gender", "scanner", "Age"]
    r.eliminate_variance = ["scanner"]
    r.original_data = fetch_sample()
    exclude_vars = r.original_data.columns[
        r.original_data.isna().sum() != 0].to_list()
    r.original_data = r.original_data[[
        var for var in r.original_data.columns if var not in exclude_vars
    ]]
    r.original_data = r.original_data[~r.original_data[r.covariates].isna().
                                      any(axis=1)]
    r.original_data.Age = r.original_data.Age.astype(int)
    scanners = r.original_data.scanner.unique()
    train_bool = r.original_data.scanner.isin(scanners[1:])
    test_bool = r.original_data.scanner.isin(scanners[:1])
    r.X_train_split = r.original_data[train_bool]
    r.X_train_split = exclude_single_subject_groups(r.X_train_split,
                                                    r.covariates)
    r.X_test_split = r.original_data[test_bool]
    r.n_scanners = len(r.original_data.scanner.unique())
    return r
def test_fetch_sample():
    data = collect_tools.fetch_sample()
    assert isinstance(data, NDFrame)
def test_fetch_model():
    """Test a trained model can be retrained."""
    neuroharmony = fetch_trained_model()
    X = fetch_sample()
    neuroharmony.transform(X)
    assert isinstance(neuroharmony.coverage_, NDFrame)