def score_dice
      if @master
        # Find the voxel-indices for the master where the decisions are 1 and 0:
        pos_indices_master = (@master.narray.eq 1).where
        @volumes.each do |bin_vol|
          pos_indices_vol = (bin_vol.narray.eq 1).where
          num_common = (@master.narray[pos_indices_vol].eq 1).where.length
          bin_vol.dice = 2 * num_common / (pos_indices_master.length + pos_indices_vol.length).to_f
        end
      end
    end
def score_dice
      if @master
        # Find the voxel-indices for the master where the decisions are 1 and 0:
        pos_indices_master = (@master.narray.eq 1).where
        @volumes.each do |bin_vol|
          pos_indices_vol = (bin_vol.narray.eq 1).where
          num_common = (@master.narray[pos_indices_vol].eq 1).where.length
          bin_vol.dice = 2 * num_common / (pos_indices_master.length + pos_indices_vol.length).to_f
        end
      end
    end
=begin
    # Along each dimension of the input binary volume(s), removes any index (i.e. slice, column or row)
    # which is empty in all volumes (including the master volume, if specified). This method results
    # in reduced volumes, corresponding to a clipbox which tightly encloses the defined (positive) volume
    # (indices with pixel value 1 in at least one of the volumes). Such a reduced volume may yield e.g.
    # specificity scores with better contrast.
    #
    def remove_empty_indices
      # It only makes sense to run this volume reduction if the number of dimensions are 2 or more:
      volumes = [*@volumes, master].compact
      # For each volume the indices typically correspond to the following
      # descriptions: slice, column & row
      volumes.first.narray.shape.each_with_index do |size, dim_index|
        extract = Array.new(volumes.first.narray.dim, true)
        positive_indices = Array.new
        size.times do |i|
          extract[dim_index] = i
          positive = false
          volumes.each do |volume|
            positive = true if volume.narray[*extract].max > 0
          end
          positive_indices << i if positive
        end
        extract[dim_index] = positive_indices
        if positive_indices.length < size
          volumes.each do |volume|
            volume.narr = volume.narr[*extract]
          end
        end
      end
      volumes.each {|vol| puts vol.narr.inspect}
      volumes.each {|vol| puts vol.narr.shape}
      @volumes.each {|vol| puts vol.narr.shape}
    end
=end
 Scores the volumes of the BinMatcher instance against the reference
 (master) volume, by using Dice's coeffecient. The score is
 stored in the 'dice' attribute of each binary volume instance.

 @see http://en.wikipedia.org/wiki/Dice%27s_coefficient