def test_instantiate_DWIDTI():
    from clinica.pipelines.dwi_dti.dwi_dti_pipeline import DwiDti
    from os.path import dirname, join, abspath

    root = dirname(abspath(join(abspath(__file__), pardir)))
    root = join(root, 'data', 'DWIDTI')
    pipeline = DwiDti(caps_directory=join(root, 'in', 'caps'),
                      tsv_file=join(root, 'in', 'subjects.tsv'))
    pipeline.build()
Beispiel #2
0
def test_instantiate_DWIDTI(cmdopt):

    from clinica.pipelines.dwi_dti.dwi_dti_pipeline import DwiDti

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

    pipeline = DwiDti(
        caps_directory=fspath(root / "in" / "caps"),
        tsv_file=fspath(root / "in" / "subjects.tsv"),
    )
    pipeline.build()
Beispiel #3
0
def test_instantiate_DWIDTI():
    from os.path import abspath, dirname, join

    from clinica.pipelines.dwi_dti.dwi_dti_pipeline import DwiDti

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

    pipeline = DwiDti(
        caps_directory=join(root, "in", "caps"),
        tsv_file=join(root, "in", "subjects.tsv"),
    )
    pipeline.build()
Beispiel #4
0
def test_run_DWIDTI(cmdopt):
    from clinica.pipelines.dwi_dti.dwi_dti_pipeline import DwiDti
    from os.path import dirname, join, abspath, exists
    import shutil
    import pandas as pds
    import numpy as np

    working_dir = cmdopt
    root = dirname(abspath(join(abspath(__file__), pardir)))
    root = join(root, 'data', 'DWIDTI')

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

    pipeline = DwiDti(caps_directory=join(root, 'out', 'caps'),
                      tsv_file=join(root, 'in', 'subjects.tsv'))
    pipeline.base_dir = join(working_dir, 'DWIDTI')
    pipeline.build()
    pipeline.run(plugin='MultiProc',
                 plugin_args={'n_procs': 4},
                 bypass_check=True)

    # Check files
    subject_id = 'sub-CAPP01001TMM'
    maps = ['AD', 'FA', 'MD', 'RD']
    out_files = [
        join(
            root, 'out', 'caps', 'subjects', subject_id, 'ses-M00', 'dwi',
            'dti_based_processing', 'atlas_statistics',
            subject_id + '_ses-M00_dwi_space-JHUDTI81_res-1x1x1_map-' + m +
            '_statistics.tsv') for m in maps
    ]
    ref_files = [
        join(
            root, 'ref',
            subject_id + '_ses-M00_dwi_space-JHUDTI81_res-1x1x1_map-' + m +
            '_statistics.tsv') for m in maps
    ]

    for i in range(len(out_files)):
        out_csv = pds.read_csv(out_files[i], sep='\t')
        out_mean_scalar = np.array(out_csv.mean_scalar)
        ref_csv = pds.read_csv(ref_files[i], sep='\t')
        ref_mean_scalar = np.array(ref_csv.mean_scalar)

        assert np.allclose(out_mean_scalar,
                           ref_mean_scalar,
                           rtol=0.025,
                           equal_nan=True)

    clean_folder(join(root, 'out', 'caps'), recreate=False)
Beispiel #5
0
def run_DWIDTI(input_dir: Path, output_dir: Path, ref_dir: Path,
               working_dir: Path) -> None:
    import shutil

    import numpy as np
    import pandas as pds

    from clinica.pipelines.dwi_dti.dwi_dti_pipeline import DwiDti

    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)

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

    # Check files
    subject_id = "sub-CAPP01001TMM"
    maps = ["AD", "FA", "MD", "RD"]
    out_files = [
        fspath(caps_dir / "subjects" / subject_id / "ses-M00" / "dwi" /
               "dti_based_processing" / "atlas_statistics" /
               (subject_id + "_ses-M00_dwi_space-JHUDTI81_res-1x1x1_map-" + m +
                "_statistics.tsv")) for m in maps
    ]
    ref_files = [
        fspath(ref_dir /
               (subject_id + "_ses-M00_dwi_space-JHUDTI81_res-1x1x1_map-" + m +
                "_statistics.tsv")) for m in maps
    ]

    for i in range(len(out_files)):
        out_csv = pds.read_csv(out_files[i], sep="\t")
        out_mean_scalar = np.array(out_csv.mean_scalar)
        ref_csv = pds.read_csv(ref_files[i], sep="\t")
        ref_mean_scalar = np.array(ref_csv.mean_scalar)

        assert np.allclose(out_mean_scalar,
                           ref_mean_scalar,
                           rtol=0.025,
                           equal_nan=True)
Beispiel #6
0
def test_run_DWIDTI(cmdopt):
    import shutil
    from os.path import abspath, dirname, join

    import numpy as np
    import pandas as pds

    from clinica.pipelines.dwi_dti.dwi_dti_pipeline import DwiDti

    working_dir = cmdopt
    root = dirname(abspath(join(abspath(__file__), pardir, pardir)))
    root = join(root, "data", "DWIDTI")

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

    pipeline = DwiDti(
        caps_directory=join(root, "out", "caps"),
        tsv_file=join(root, "in", "subjects.tsv"),
        base_dir=join(working_dir, "DWIDTI"),
    )
    pipeline.build()
    pipeline.run(plugin="MultiProc",
                 plugin_args={"n_procs": 4},
                 bypass_check=True)

    # Check files
    subject_id = "sub-CAPP01001TMM"
    maps = ["AD", "FA", "MD", "RD"]
    out_files = [
        join(
            root,
            "out",
            "caps",
            "subjects",
            subject_id,
            "ses-M00",
            "dwi",
            "dti_based_processing",
            "atlas_statistics",
            subject_id + "_ses-M00_dwi_space-JHUDTI81_res-1x1x1_map-" + m +
            "_statistics.tsv",
        ) for m in maps
    ]
    ref_files = [
        join(
            root,
            "ref",
            subject_id + "_ses-M00_dwi_space-JHUDTI81_res-1x1x1_map-" + m +
            "_statistics.tsv",
        ) for m in maps
    ]

    for i in range(len(out_files)):
        out_csv = pds.read_csv(out_files[i], sep="\t")
        out_mean_scalar = np.array(out_csv.mean_scalar)
        ref_csv = pds.read_csv(ref_files[i], sep="\t")
        ref_mean_scalar = np.array(ref_csv.mean_scalar)

        assert np.allclose(out_mean_scalar,
                           ref_mean_scalar,
                           rtol=0.025,
                           equal_nan=True)

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