Skip to main content
. 2022 Nov 23;22(23):9101. doi: 10.3390/s22239101
Algorithm A1 Copeland score calculation.
  • Require: 

    Survey data where each entry is a tuple (candidate1, candidate2, winning_candidate). Each candidate is one of the segmentation masks involved in the survey. Iwinning_candidate is one of the candidate1 or candidate2 images.

    % An algorithm to calculate the Copeland score based on candidate pairwise comparisons %

  • 1:

    function calculateCopelandScore(survey_data)

  • 2:

        candidates eight segmentation masks for the same fundus image

  • 3:

        candidate_pairsgetCombinations(candidates)

  • 4:

        

  • 5:

        ranking_tableempty_table

  • 6:

        for candidate in candidates do

  • 7:

            copeland_score0

  • 8:

            ranking_table.insert(candidate, copeland_score)

  • 9:

        end for

  • 10:

        

  • 11:

        for (c1, c2) in candidate_pairs do

  • 12:

            c1_winscountWins(candidate=c1)

  • 13:

            c2_winscountWins(candidate=c2)

  • 14:

            if c1_wins>c2_wins then

  • 15:

               ranking_table.where(candidate=c1).copeland_score += 1

  • 16:

            else if c1_wins<c2_wins then

  • 17:

               ranking_table.where(candidate=c1).copeland_score = 1

  • 18:

            end if

  • 19:

        end for

  • 20:

    end function 

    % Counts how many times has candidate won in pairwise comparisons according to survey data stored in survey_entries. %

  • 21:

    functioncountWins(survey_entries, candidate)

  • 22:

        counter0

  • 23:

        for entry in survey_entries do

  • 24:

            c1entry.candidate1

  • 25:

            c2entry.candidate2

  • 26:

            if candidate in (c1, c2) then

  • 27:

               if candidate is entry.winning_candidate then

  • 28:

                   counter += 1

  • 29:

               end if

  • 30:

            end if

  • 31:

        end for

  • 32:

        return counter

  • 33:

    end function 

    % Get all combinations of unique candidate pairs. That is 24 for 8 segmentation images. %

  • 34:

    functiongetCombinations(candidates)

  • 35:

        n8

  • 36:

        combinationsempty_list

  • 37:

        for i in (0 to n) do

  • 38:

            c1candidates.at_position(i)

  • 39:

            for j in(0 to n) do

  • 40:

               c2candidates.at_position(j)

  • 41:

               combinations.insert((c1, c2))

  • 42:

            end for

  • 43:

        end for

  • 44:

    end function