示例#1
0
void TestTubeSegmentationFramework::testLoadParameterFile()
{
	paramList preset = loadPreset(QString("Neuro-Vessels-USA"));

	INFO("sphere-segmentation not set to true in Neuro-Vessels-USA");
	REQUIRE(getParamBool(preset,"sphere-segmentation") == true);
}
TEST(ParameterTest, SetParameters) {
	paramList parameters = initParameters(PARAMETERS_DIR);

	setParameter(parameters, "display", "true");
	EXPECT_TRUE(getParamBool(parameters, "display"));
	setParameter(parameters, "cropping", "lung");
	EXPECT_EQ("lung", getParamStr(parameters, "cropping"));
	setParameter(parameters, "tdf-high", "0.9");
	EXPECT_EQ(0.9f, getParam(parameters, "tdf-high"));
}
TEST(ParameterTest, GetDefaultParameters) {
	paramList parameters = initParameters(PARAMETERS_DIR);

	EXPECT_FALSE(getParamBool(parameters, "display"));
	EXPECT_EQ("gpu", getParamStr(parameters, "device"));
	EXPECT_EQ(0.05f, getParam(parameters, "gvf-mu"));

	EXPECT_EQ("Display results", parameters.bools["display"].getDescription());
	EXPECT_EQ("Which type of processor to use", parameters.strings["device"].getDescription());
	EXPECT_EQ("Mu regularization constant of GVF", parameters.numerics["gvf-mu"].getDescription());
}
示例#4
0
			AND_WHEN("we load the parameter presets"){
				REQUIRE_NOTHROW(loadParameterPreset(neuroVesselsUSAParameters, path));

				THEN("we can check that the expected values are set"){
					CHECK(getParamStr(neuroVesselsUSAParameters, "minimum") == "50");
					CHECK(getParamStr(neuroVesselsUSAParameters, "maximum") == "200");
					CHECK(getParam(neuroVesselsUSAParameters, "fmax") == Approx(0.1));
					CHECK(getParam(neuroVesselsUSAParameters, "min-mean-tdf") == 0.5);
					CHECK(getParam(neuroVesselsUSAParameters, "radius-min") == 1.5);
					CHECK(getParam(neuroVesselsUSAParameters, "radius-max") == 7.0);
					CHECK(getParam(neuroVesselsUSAParameters, "small-blur") == 2.0);
					CHECK(getParam(neuroVesselsUSAParameters, "large-blur") == 3.0);
					CHECK(getParamStr(neuroVesselsUSAParameters, "cropping") == "threshold");
					CHECK(getParam(neuroVesselsUSAParameters, "cropping-threshold") == 50);
					CHECK(getParam(neuroVesselsUSAParameters, "min-tree-length") == 10);
					CHECK(getParamBool(neuroVesselsUSAParameters, "sphere-segmentation") == true);
					CHECK(getParam(neuroVesselsUSAParameters, "cube-size") == 4);
				}
				AND_WHEN("we try to set a bool parameter to false"){
					REQUIRE_NOTHROW(setParameter(neuroVesselsUSAParameters, "sphere-segmentation", "false"));

					THEN("we can check that it get the correct value"){
						CHECK(getParamBool(neuroVesselsUSAParameters, "sphere-segmentation") == false);
					}
				}
			}
		}
	}
}

SCENARIO("Loading the Phantom-Acc-US (gpu) preset", "[TSF][unit]"){
int main(int argc, char ** argv) {
    if(argc == 1 || strcmp(argv[1], "--help") == 0 || strcmp(argv[1], "-h") == 0) {
        // Print help message
        std::cout << std::endl;
        std::cout << "Tube Segmentation Framework" << std::endl;
        std::cout << "===========================" << std::endl;
        std::cout << "Copyright Erik Smistad 2013 - See file LICENSE for license information." << std::endl;
        std::cout << std::endl;
        std::cout << "Usage: " << argv[0] << " inputFilename.mhd <parameters>" << std::endl;
        std::cout << std::endl;
        std::cout << "Example: " << argv[0] << " tests/data/synthetic/dataset_1/noisy.mhd --parameters Synthetic-Vascusynth --display" << std::endl;
        std::cout << std::endl;
        std::cout << "Available parameter presets: " << std::endl;
        std::cout << "* Lung-Airways-CT" << std::endl;
        std::cout << "* Neuro-Vessels-USA" << std::endl;
        std::cout << "* Neuro-Vessels-MRA" << std::endl;
        std::cout << "* AAA-Vessels-CT" << std::endl;
        std::cout << "* Liver-Vessels-CT" << std::endl;
        std::cout << "* Synthetic-Vascusynth" << std::endl;
        std::cout << std::endl;
        std::cout << "The parameter preset is set with the program argument \"--parameters <name>\"." << std::endl;
        std::cout << std::endl;
        std::cout << "Available parameters: " << std::endl;
        printAllParameters();
        exit(-1);
    }

    // Load default parameters and parse parameters from program arguments
    paramList parameters = getParameters(argc, argv);
    std::string filename = argv[1];


    TSFOutput * output;
    try {
		output = run(filename, parameters, std::string(KERNELS_DIR));
    } catch(SIPL::SIPLException &e) {
    	std::cout << e.what() << std::endl;

    	return -1;
    }

    if(getParamBool(parameters, "display")) {
        // Visualize result
		SIPL::int3 * size = output->getSize();
        SIPL::Volume<SIPL::float3> * result = new SIPL::Volume<SIPL::float3>(size->x, size->y, size->z);
        float * TDF;
        char * centerline;
        char * segmentation;
        if(output->hasTDF())
        	TDF = output->getTDF();
        if(output->hasCenterlineVoxels())
        	centerline = output->getCenterlineVoxels();
        if(output->hasSegmentation())
        	segmentation = output->getSegmentation();
        for(int i = 0; i < result->getTotalSize(); i++) {
            SIPL::float3 v;
            if(output->hasTDF())
            	v.x = TDF[i];
            if(output->hasCenterlineVoxels())
				v.y = centerline[i] ? 1.0:0.0;
            if(output->hasSegmentation())
                v.z = segmentation[i] ? 1.0:0.0;
            result->set(i,v);
        }
        result->showMIP(SIPL::Y);
    }

    // free data
    output->~TSFOutput();

    return 0;
}