def read_image
      raw_image = []
      @stream.index = @hdr['vox_offset']
      type = NIFTI_DATATYPES[@hdr['datatype']]
      format = @stream.format[type]
      @image_rubyarray = @stream.decode(@stream.rest_length, type)
    end
def read_image
      raw_image = []
      @stream.index = @hdr['vox_offset']
      type = NIFTI_DATATYPES[@hdr['datatype']]
      format = @stream.format[type]
      @image_rubyarray = @stream.decode(@stream.rest_length, type)
    end
Create a NRead object to parse a nifti file or binary string and set header and image info instance variables.

 The nifti header will be checked for validity (header size and magic number) and will raise an IOError if invalid.

 NIFTI header extensions are not yet supported and are not included in the header.

 The header and image are accessible via the hdr and image instance variables.  An optional narray matrix may also be available in image_narray if desired by passing in :narray => true as an option.

 === Parameters

 * <tt>source</tt> -- A string which specifies either the path of a NIFTI file to be loaded, or a binary NIFTI string to be parsed.
 * <tt>options</tt> -- A hash of parameters.

 === Options

 * <tt>:bin</tt> -- Boolean. If set to true, string parameter will be interpreted as a binary NIFTI string, and not a path string, which is the default behaviour.
 * <tt>:image</tt> -- Boolean. If set to true, automatically load the image into @image, otherwise only a header is collected and you can get an image
 * <tt>:narray</tt> -- Boolean.  If set to true, a properly shaped narray matrix will be set in the instance variable @image_narray.  Automatically sets :image => true

 Unpack an image array from vox_offset to the end of a nifti file.

 === Parameters

 There are no parameters - this reads from the binary string in the @string instance variable.

 This sets @image_rubyarray to the image data vector and also returns it.