Exemple #1
0
def test_vessel_particles_mask_workflow():
    # Get the path to the this test so that we can reference the test data
    this_dir = os.path.dirname(os.path.realpath(__file__))

    # Set up the inputs and run the workflow
    ct_file_name = this_dir + '/../../../../Testing/Data/Input/vessel.nrrd'
    label_map_file_name = \
      this_dir + '/../../../../Testing/Data/Input/vessel_volumeMask.nrrd'
    seeds_mask_file_name = \
      this_dir + '/../../../../Testing/Data/Input/vessel_vesselSeedsMask.nrrd'
    tmp_dir = tempfile.mkdtemp()
    vessel_seeds_mask_file_name = os.path.join(tmp_dir, 'vesselSeedsMask.nrrd')

    wf = VesselParticlesMaskWorkflow(ct_file_name, label_map_file_name, 
                                     tmp_dir, vessel_seeds_mask_file_name)
    wf.run()

    ref, ref_header = nrrd.read(seeds_mask_file_name)
    test, test_header = nrrd.read(vessel_seeds_mask_file_name)    
    dice = compute_dice_coefficient(ref, test, 1)
    shutil.rmtree(tmp_dir)
    
    assert dice > 0.995, "Dice coefficient lower than expected"
    #print "------------- iteration {0} -------------".format(i)
    #print params

    # Get the path to the this test so that we can reference the test data
    this_dir = os.path.dirname(os.path.realpath(__file__))

    # Set up the inputs and run the workflow
    ct_file_name = '/Users/jinho/Github/ChestImagingPlatform/Testing/Data/Input/vessel.nrrd'
    label_map_file_name = '/Users/jinho/Github/ChestImagingPlatform/Testing/Data/Input/vessel_volumeMask.nrrd'
    seeds_mask_file_name = '/Users/jinho/Github/ChestImagingPlatform/Testing/Data/Input/vessel_vesselSeedsMask.nrrd'
    tmp_dir = tempfile.mkdtemp()
    vessel_seeds_mask_file_name = os.path.join(tmp_dir, 'vesselSeedsMask.nrrd')

    gaussianStd = [0.7, 4.0, params['num_steps']]

    wf = VesselParticlesMaskWorkflow(ct_file_name, label_map_file_name,
                                     tmp_dir, vessel_seeds_mask_file_name)
    wf.get_node('compute_feature_strength').inputs.alpha = params['alpha']
    wf.get_node('compute_feature_strength').inputs.beta = params['beta']
    wf.get_node('compute_feature_strength').inputs.C = params['C']
    wf.get_node('compute_feature_strength').inputs.std = gaussianStd
    wf.get_node('unu_heq').inputs.amount = params['amount']
    wf.get_node('unu_heq').inputs.smart = params['smart']
    wf.run()

    ref, ref_header = nrrd.read(seeds_mask_file_name)
    test, test_header = nrrd.read(vessel_seeds_mask_file_name)
    score = compute_dice_coefficient(ref, test, 1)
    #print vessel_seeds_mask_file_name

    scientist.update(params, score)