Skip to content

Error For Dice Score  #11

@LennyN95

Description

@LennyN95

Under certain circumstances, the parsing of the results of the dice score command result in an error:

Computing DC between the two images with 'plastimatch dice --dice'
... Done.
Traceback (most recent call last):
  File "/app/src/main.py", line 69, in <module>
    compare(src_path, ref_path, report=report)
  File "/app/src/main.py", line 34, in compare
    file_checker.compare(src_path, ref_path)
  File "/app/src/checks/FileCompare.py", line 25, in compare
    entry = check(src_path, ref_path).run()
  File "/app/src/checks/FileCompare.py", line 66, in run
    raise e
  File "/app/src/checks/FileCompare.py", line 63, in run
    check_passed = self.check()
  File "/app/src/checks/ImageFileCheck.py", line 37, in check
    return self.check_dice()
  File "/app/src/checks/ImageFileCheck.py", line 64, in check_dice
    dice_summary_dict = pypla.dice(
  File "/usr/local/lib/python3.8/dist-packages/pyplastimatch/pyplastimatch.py", line 171, in dice
    float(str(dice_summary[1]).split("\\t")[3][:-2])]
ValueError: could not convert string to float: ''

The error is caused by this line for an output that looks as such:

dice_summary = [b'CENTER_OF_MASS', b'ref\t       1.37534\t       13.5159\t       23.6297', 
                b'cmp\t       1.37534\t       13.5159\t       23.6297', 
                b'TP:        182496', b'TN:       3580704', b'FN:             0', 
                b'FP:             0', 
                b'DICE:      1.000000', 
                b'SE:      1.000000', b'SP:      1.000000'
]

The error seems to be that [:-2] on 0 effectively returns an empty string which then causes the float type casting to fail with the above error.

@denbonte can you elaborate what purpose the [:-1] is / was meant to serve and weather it's save to remove?

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinghelp wantedExtra attention is needed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions