File size: 1,603 Bytes
967a3ab
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import os
import sys

# Add the topology directory to Python path
sys.path.insert(0, os.path.join(os.path.dirname(__file__), '../..'))

from topologyScoring import partitionTopologicalDiceScore

def evaluateMoleculeSegmentation(gtFilename : str, reconFilename : str, verbose : bool = False) -> int:
    """
    Given two Morse-Smale segmentations of the same domain, return a similarity score from 0-10.
    A score of 0 is considered bad and a score of 10 is considered good. The segmentations should be
    represented by a point array called "Segmentation" that assigs a region identifier to each point in 
    the domain. The region identifiers between the ground truth and reconstructed files do not need to match. 
    Args:
        gtFilename: The name of a file storing VTK image data (.vti) storing the ground truth MS segmentation.
                    each point's region ID should be stored in a point array called "Segmentation".
        reconFilename: The name of a file storing VTK image data (.vti) storing the reconstructed MS segmentation.
        verbose: Should error messages be printed if there are issues with the input files.
    """

    return partitionTopologicalDiceScore(gtFilename, "Segmentation", reconFilename, "Segmentation", verbose)

if __name__ == "__main__":

    if len(sys.argv) != 3:
        print(f"{os.path.basename(__file__)}: usage is 'python3 {os.path.basename(__file__)} gt_filename.vti recon_filename.vti")
        exit(1)

    score = evaluateMoleculeSegmentation(sys.argv[1], sys.argv[2], verbose=True)

    print(f"This MS segmentation scored: {score}")