Ejemplo n.º 1
0
    def test_modifyCfgs_modifesFlair_combination(self):
        print("ARRANGE - MODIFYCFGS (MODIFIESFLAIR_COMBINATION)")
        print("-" * 20)
        # make test data folder
        cwd = setup.os.getcwd()
        print("Current directory:", cwd)
        setup.os.chdir(PACKAGE_PATH)
        print("Changed directory to:", PACKAGE_PATH)
        print("Creating data directory")
        subjects = ["sub-01", "sub-02", "sub-03"]
        for subject in subjects:
            setup.os.mkdir("data/" + subject)
            setup.os.mkdir("data/" + subject + "/anat")
        setup.os.system("touch data/sub-01/anat/sub-01_FLAIR.nii.gz")
        setup.os.system("touch data/sub-01/anat/sub-01_T1W.nii.gz")
        setup.os.system("touch data/sub-02/anat/sub-02_FLAIR.nii.gz")
        setup.os.system("touch data/sub-03/anat/sub-03_T1W.nii.gz")
        setup.os.chdir(cwd)
        print("Changed directory to:", cwd)

        print("ACT - MODIFYCFGS (MODIFIESFLAIR_COMBINATION)")
        print("-" * 20)
        inference.modifyCfgs(DATA_PATH)

        print("ASSERT - MODIFYCFGS (MODIFIESFLAIR_COMBINATION)")
        print("-" * 20)
        path_flair = str(
            PACKAGE_PATH
        ) + "/deepmedic/inference_model/config/test/test_flair.cfg"
        with open(path_flair) as f:
            content = f.read()
        output = content.split("\n")
        output.pop()
        expected = [DATA_PATH + "/sub-01/anat/sub-01_FLAIR.nii.gz"]
        self.assertEqual(expected, output)
Ejemplo n.º 2
0
    def test_modifyCfgs_modifesT1w_all(self):
        print("ARRANGE - MODIFYCFGS (MODIFIEST1W_ALL)")
        print("-" * 20)
        # make test data folder
        cwd = setup.os.getcwd()
        print("Current directory:", cwd)
        setup.os.chdir(PACKAGE_PATH)
        print("Changed directory to:", PACKAGE_PATH)
        print("Creating data directory")
        subjects = ["sub-01", "sub-02", "sub-03"]
        for subject in subjects:
            setup.os.mkdir("data/" + subject)
            setup.os.mkdir("data/" + subject + "/anat")
            setup.os.system("touch data/" + subject + "/anat/" + subject +
                            "_FLAIR.nii.gz")
            setup.os.system("touch data/" + subject + "/anat/" + subject +
                            "_T1W.nii.gz")
        setup.os.chdir(cwd)
        print("Changed directory to:", cwd)

        print("ACT - MODIFYCFGS (MODIFIEST1W_ALL)")
        print("-" * 20)
        inference.modifyCfgs(DATA_PATH)

        print("ASSERT - MODIFYCFGS (MODIFIEST1W_ALL)")
        print("-" * 20)
        path_t1w = str(
            PACKAGE_PATH
        ) + "/deepmedic/inference_model/config/test/test_t1w.cfg"
        with open(path_t1w) as f:
            content = f.read()
        output = content.split("\n")
        output.pop()
        expected = []
        for subject in subjects:
            expected.append(DATA_PATH + "/" + subject + "/anat/" + subject +
                            "_T1W.nii.gz")
        self.assertEqual(expected, output)