| import os |
| import sys |
|
|
| |
| 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}") |
|
|