def narray(options={})
      pixels = nil
      if exists?(PIXEL_TAG)
        unless color?
          # Decode the pixel values: For now we only support returning pixel data of the first frame (if the image is located in multiple pixel data items).
          if compression?
            pixels = decompress(image_strings.first)
          else
            pixels = decode_pixels(image_strings.first)
          end
          if pixels
            # Import the pixels to NArray and give it a proper shape:
            raise "Missing Rows and/or Columns Element. Unable to construct pixel data array." unless num_rows and num_cols
            if num_frames > 1 or options[:volume]
              # Create an empty 3D NArray. fill it with pixels frame by frame, then reassign the pixels variable to it:
              narr = Numo::Int16.zeros(num_frames, num_cols, num_rows)
              num_frames.times do |i|
                narr[i, true, true] = Numo::NArray[*pixels[(i * num_cols * num_rows)..((i + 1) * num_cols * num_rows - 1)]].reshape!(num_cols, num_rows)
              end
              pixels = narr
            else
              pixels = Numo::NArray[*pixels].reshape!(num_cols, num_rows)
            end
            # Remap the image from pixel values to presentation values if the user has requested this:
            pixels = process_presentation_values_narray(pixels, -65535, 65535, options[:level]) if options[:remap] or options[:level]
          else
            logger.warn("Decompressing the Pixel Data failed. Pixel values can not be extracted.")
          end
        else
          logger.warn("The DICOM object contains colored pixel data. Retrieval of colored pixels is not supported by this method yet.")
          pixels = false
        end
      end
      return pixels
    end
def narray(options={})
      pixels = nil
      if exists?(PIXEL_TAG)
        unless color?
          # Decode the pixel values: For now we only support returning pixel data of the first frame (if the image is located in multiple pixel data items).
          if compression?
            pixels = decompress(image_strings.first)
          else
            pixels = decode_pixels(image_strings.first)
          end
          if pixels
            # Import the pixels to NArray and give it a proper shape:
            raise "Missing Rows and/or Columns Element. Unable to construct pixel data array." unless num_rows and num_cols
            if num_frames > 1 or options[:volume]
              # Create an empty 3D NArray. fill it with pixels frame by frame, then reassign the pixels variable to it:
              narr = Numo::Int16.zeros(num_frames, num_cols, num_rows)
              num_frames.times do |i|
                narr[i, true, true] = Numo::NArray[*pixels[(i * num_cols * num_rows)..((i + 1) * num_cols * num_rows - 1)]].reshape!(num_cols, num_rows)
              end
              pixels = narr
            else
              pixels = Numo::NArray[*pixels].reshape!(num_cols, num_rows)
            end
            # Remap the image from pixel values to presentation values if the user has requested this:
            pixels = process_presentation_values_narray(pixels, -65535, 65535, options[:level]) if options[:remap] or options[:level]
          else
            logger.warn("Decompressing the Pixel Data failed. Pixel values can not be extracted.")
          end
        else
          logger.warn("The DICOM object contains colored pixel data. Retrieval of colored pixels is not supported by this method yet.")
          pixels = false
        end
      end
      return pixels
    end
Creates an NArray containing the pixel data. If the pixel data is an image
 (single frame), a 2-dimensional NArray is returned [columns, rows]. If the
 pixel data is 3-dimensional (more than one frame), a 3-dimensional NArray
 is returned [frames, columns, rows].

 @note To call this method you need to have loaded the NArray library in advance (require 'narray').

 @param [Hash] options the options to use for extracting the pixel data
 @option options [TrueClass, Array<Integer>] :level if true, window leveling is performed using default values from the DICOM object, or if an array ([center, width]) is specified, these custom values are used instead
 @option options [Boolean] :remap if true, the returned pixel values are remapped to presentation values
 @option options [Boolean] :volume if true, the returned array will always be 3-dimensional, even if the pixel data only has one frame
 @return [NArray, NilClass, FalseClass] an NArray of pixel values, alternatively nil (if no image present) or false (if image decode failed)

 @example Retrieve numerical pixel array
   data = dcm.narray
 @example Retrieve numerical pixel array remapped from the original pixel values to presentation values
   data = dcm.narray(:remap => true)