def test_instantiate_DWIConnectome():
    from clinica.pipelines.dwi_connectome.dwi_connectome_pipeline import DwiConnectome
    from os.path import dirname, join, abspath

    root = dirname(abspath(join(abspath(__file__), pardir)))
    root = join(root, 'data', 'DWIConnectome')
    pipeline = DwiConnectome(caps_directory=join(root, 'in', 'caps'),
                             tsv_file=join(root, 'in', 'subjects.tsv'))
    pipeline.parameters = {'n_tracks': 1000}
    pipeline.build()
Esempio n. 2
0
def test_instantiate_DWIConnectome(cmdopt):

    from clinica.pipelines.dwi_connectome.dwi_connectome_pipeline import DwiConnectome

    input_dir = Path(cmdopt["input"])
    root = input_dir / "DWIConnectome"

    parameters = {"n_tracks": 1000}
    pipeline = DwiConnectome(
        caps_directory=fspath(root / "in" / "caps"),
        tsv_file=fspath(root / "in" / "subjects.tsv"),
        parameters=parameters,
    )
    pipeline.build()
Esempio n. 3
0
def test_instantiate_DWIConnectome():
    from os.path import abspath, dirname, join

    from clinica.pipelines.dwi_connectome.dwi_connectome_pipeline import DwiConnectome

    root = dirname(abspath(join(abspath(__file__), pardir)))
    root = join(root, "data", "DWIConnectome")

    parameters = {"n_tracks": 1000}
    pipeline = DwiConnectome(
        caps_directory=join(root, "in", "caps"),
        tsv_file=join(root, "in", "subjects.tsv"),
        parameters=parameters,
    )
    pipeline.build()
Esempio n. 4
0
def test_run_DWIConnectome(cmdopt):
    from os.path import dirname, join, abspath
    import shutil
    from clinica.pipelines.dwi_connectome.dwi_connectome_pipeline import DwiConnectome

    # Initialization
    working_dir = join(abspath(cmdopt), 'DWIConnectome')
    root = dirname(abspath(join(abspath(__file__), pardir)))
    root = join(root, 'data', 'DWIConnectome')
    in_tsv = join(root, 'in', 'subjects.tsv')
    out_caps_dir = join(root, 'out', 'caps')

    subject_id = 'sub-HMTC20110506MEMEPPAT27'
    session_id = 'ses-M00'

    clean_folder(out_caps_dir, recreate=False)
    clean_folder(working_dir)
    shutil.copytree(join(root, 'in', 'caps'), out_caps_dir)

    parameters = {'n_tracks': 1000}
    pipeline = DwiConnectome(caps_directory=out_caps_dir,
                             tsv_file=in_tsv,
                             base_dir=working_dir,
                             parameters=parameters)
    pipeline.build()
    pipeline.run(plugin='MultiProc',
                 plugin_args={'n_procs': 4},
                 bypass_check=True)

    # Check files
    atlases = ['desikan', 'destrieux']

    out_fod_file = join(
        root, 'out', 'caps', 'subjects', subject_id, session_id, 'dwi',
        'connectome_based_processing', subject_id + '_' + session_id +
        '_dwi_space-b0_model-CSD_diffmodel.nii.gz')
    ref_fod_file = join(
        root, 'ref', subject_id + '_' + session_id +
        '_dwi_space-b0_model-CSD_diffmodel.nii.gz')

    out_parc_files = [
        join(
            root, 'out', 'caps', 'subjects', subject_id, session_id, 'dwi',
            'connectome_based_processing', subject_id + '_' + session_id +
            '_dwi_space-b0_atlas-' + a + '_parcellation.nii.gz')
        for a in atlases
    ]
    ref_parc_files = [
        join(
            root, 'ref', subject_id + '_' + session_id +
            '_dwi_space-b0_atlas-' + a + '_parcellation.nii.gz')
        for a in atlases
    ]

    assert similarity_measure(out_fod_file, ref_fod_file, 0.97)

    for i in range(len(out_parc_files)):
        assert similarity_measure(out_parc_files[i], ref_parc_files[i], 0.955)

    clean_folder(join(root, 'out', 'caps'), recreate=False)
Esempio n. 5
0
def run_DWIConnectome(input_dir: Path, output_dir: Path, ref_dir: Path,
                      working_dir: Path) -> None:
    import shutil

    from clinica.pipelines.dwi_connectome.dwi_connectome_pipeline import DwiConnectome

    caps_dir = output_dir / "caps"
    tsv = input_dir / "subjects.tsv"

    # Copy necessary data from in to out
    shutil.copytree(input_dir / "caps", caps_dir, copy_function=shutil.copy)

    parameters = {"n_tracks": 1000}
    pipeline = DwiConnectome(
        caps_directory=fspath(caps_dir),
        tsv_file=fspath(tsv),
        base_dir=fspath(working_dir),
        parameters=parameters,
    )
    pipeline.build()
    pipeline.run(plugin="MultiProc",
                 plugin_args={"n_procs": 4},
                 bypass_check=True)

    # Check files
    atlases = ["desikan", "destrieux"]
    subject_id = "sub-HMTC20110506MEMEPPAT27"
    session_id = "ses-M00"

    out_fod_file = fspath(caps_dir / "subjects" / subject_id / session_id /
                          "dwi" / "connectome_based_processing" /
                          (subject_id + "_" + session_id +
                           "_dwi_space-b0_model-CSD_diffmodel.nii.gz"))
    ref_fod_file = fspath(
        ref_dir / (subject_id + "_" + session_id +
                   "_dwi_space-b0_model-CSD_diffmodel.nii.gz"), )

    out_parc_files = [
        fspath(caps_dir / "subjects" / subject_id / session_id / "dwi" /
               "connectome_based_processing" /
               (subject_id + "_" + session_id + "_dwi_space-b0_atlas-" + a +
                "_parcellation.nii.gz")) for a in atlases
    ]
    ref_parc_files = [
        fspath(ref_dir / (subject_id + "_" + session_id +
                          "_dwi_space-b0_atlas-" + a + "_parcellation.nii.gz"))
        for a in atlases
    ]

    assert similarity_measure(out_fod_file, ref_fod_file, 0.97)

    for i in range(len(out_parc_files)):
        assert similarity_measure(out_parc_files[i], ref_parc_files[i], 0.955)
Esempio n. 6
0
def test_run_DWIConnectome(cmdopt):
    import shutil
    from os.path import abspath, dirname, join

    from clinica.pipelines.dwi_connectome.dwi_connectome_pipeline import DwiConnectome

    # Initialization
    working_dir = join(abspath(cmdopt), "DWIConnectome")
    root = dirname(abspath(join(abspath(__file__), pardir, pardir)))
    root = join(root, "data", "DWIConnectome")
    in_tsv = join(root, "in", "subjects.tsv")
    out_caps_dir = join(root, "out", "caps")

    subject_id = "sub-HMTC20110506MEMEPPAT27"
    session_id = "ses-M00"

    clean_folder(out_caps_dir, recreate=False)
    clean_folder(working_dir)
    shutil.copytree(join(root, "in", "caps"), out_caps_dir)

    parameters = {"n_tracks": 1000}
    pipeline = DwiConnectome(
        caps_directory=out_caps_dir,
        tsv_file=in_tsv,
        base_dir=working_dir,
        parameters=parameters,
    )
    pipeline.build()
    pipeline.run(plugin="MultiProc",
                 plugin_args={"n_procs": 4},
                 bypass_check=True)

    # Check files
    atlases = ["desikan", "destrieux"]

    out_fod_file = join(
        root,
        "out",
        "caps",
        "subjects",
        subject_id,
        session_id,
        "dwi",
        "connectome_based_processing",
        subject_id + "_" + session_id +
        "_dwi_space-b0_model-CSD_diffmodel.nii.gz",
    )
    ref_fod_file = join(
        root,
        "ref",
        subject_id + "_" + session_id +
        "_dwi_space-b0_model-CSD_diffmodel.nii.gz",
    )

    out_parc_files = [
        join(
            root,
            "out",
            "caps",
            "subjects",
            subject_id,
            session_id,
            "dwi",
            "connectome_based_processing",
            subject_id + "_" + session_id + "_dwi_space-b0_atlas-" + a +
            "_parcellation.nii.gz",
        ) for a in atlases
    ]
    ref_parc_files = [
        join(
            root,
            "ref",
            subject_id + "_" + session_id + "_dwi_space-b0_atlas-" + a +
            "_parcellation.nii.gz",
        ) for a in atlases
    ]

    assert similarity_measure(out_fod_file, ref_fod_file, 0.97)

    for i in range(len(out_parc_files)):
        assert similarity_measure(out_parc_files[i], ref_parc_files[i], 0.955)

    clean_folder(join(root, "out", "caps"), recreate=False)
    clean_folder(working_dir, recreate=False)