def template_string(depth)
      template = false
      pixel_representation = self['0028,0103'].value.to_i
      # Number of bytes used per pixel will determine how to unpack this:
      case depth
      when 8 # (1 byte)
        template = 'BY' # Byte/Character/Integer
      when 16 # (2 bytes)
        if pixel_representation == 1
         template = 'SS' # Signed short
        else
          template = 'US' # Unsigned short
        end
      when 32 # (4 bytes)
        if pixel_representation == 1
          template = 'SL' # Signed long
        else
          template = 'UL' # Unsigned long
        end
      when 12
        # 12 BIT SIMPLY NOT IMPLEMENTED YET!
        # This one is a bit tricky. I havent really given this priority so far as 12 bit image data is rather rare.
        raise "Packing/unpacking pixel data of bit depth 12 is not implemented yet! Please contact the author (or edit the source code)."
      else
        raise ArgumentError, "Encoding/Decoding pixel data with this Bit Depth (#{depth}) is not implemented."
      end
      return template
    end
def template_string(depth)
      template = false
      pixel_representation = self['0028,0103'].value.to_i
      # Number of bytes used per pixel will determine how to unpack this:
      case depth
      when 8 # (1 byte)
        template = 'BY' # Byte/Character/Integer
      when 16 # (2 bytes)
        if pixel_representation == 1
         template = 'SS' # Signed short
        else
          template = 'US' # Unsigned short
        end
      when 32 # (4 bytes)
        if pixel_representation == 1
          template = 'SL' # Signed long
        else
          template = 'UL' # Unsigned long
        end
      when 12
        # 12 BIT SIMPLY NOT IMPLEMENTED YET!
        # This one is a bit tricky. I havent really given this priority so far as 12 bit image data is rather rare.
        raise "Packing/unpacking pixel data of bit depth 12 is not implemented yet! Please contact the author (or edit the source code)."
      else
        raise ArgumentError, "Encoding/Decoding pixel data with this Bit Depth (#{depth}) is not implemented."
      end
      return template
    end
Determines the template/format string for pack/unpacking pixel data, based on
 the number of bits per pixel as well as the pixel representation (signed or unsigned).

 @param [Integer] depth the number of allocated bits in the integers to be decoded/encoded
 @return [String] a format string