code: def get_opt_parser():
      # use module docstring for help output
      p = OptionParser(
          usage=f"{sys.argv[0]} [OPTIONS] <PAR files>\n\n" + __doc__,
          version="%prog " + nibabel.__version__,
      )
      p.add_option(
          Option(
              "-v",
              "--verbose",
              action="store_true",
              dest="verbose",
              default=False,
              help="""Make some noise.""",
          )
      )
      p.add_option(
          Option(
              "-o",
              "--output-dir",
              action="store",
              type="string",
              dest="outdir",
              default=None,
              help="Destination directory for NIfTI files. Default: current directory.",
          )
      )
      p.add_option(
          Option(
              "-c",
              "--compressed",
              action="store_true",
              dest="compressed",
              default=False,
              help="Whether to write compressed NIfTI files or not.",
          )
      )
      p.add_option(
          Option(
              "-p",
              "--permit-truncated",
              action="store_true",
              dest="permit_truncated",
              default=False,
              help=one_line(
                  """Permit conversion of truncated recordings. Support for
                     this is experimental, and results *must* be checked
                     afterward for validity."""
              ),
          )
      )
      p.add_option(
          Option(
              "-b",
              "--bvs",
              action="store_true",
              dest="bvs",
              default=False,
              help="Output bvals/bvecs files in addition to NIFTI image.",
          )
      )
      p.add_option(
          Option(
              "-d",
              "--dwell-time",
              action="store_true",
              default=False,
              dest="dwell_time",
              help=one_line(
                  """Calculate the scan dwell time. If supplied, the magnetic
                     field strength should also be supplied using
                     --field-strength (default 3). The field strength must be
                     supplied because it is not encoded in the PAR/REC
                     format."""
              ),
          )
      )
      p.add_option(
          Option(
              "--field-strength",
              action="store",
              type="float",
              dest="field_strength",
              help=one_line(
                  """The magnetic field strength of the recording, only needed
                     for --dwell-time. The field strength must be supplied
                     because it is not encoded in the PAR/REC format."""
              ),
          )
      )
      p.add_option(
          Option(
              "-i",
              "--volume-info",
              action="store_true",
              dest="vol_info",
              default=False,
              help=one_line(
                  """Export .PAR volume labels corresponding to the fourth
                     dimension of the data.  The dimension info will be stored in
                     CSV format with the first row containing dimension labels
                     and the subsequent rows (one per volume), the corresponding
                     indices.  Only labels that vary along the 4th dimension are
                     exported (e.g. for a single volume structural scan there
                     are no dynamic labels and no output file will be created).
                     """
              ),
          )
      )
      p.add_option(
          Option(
              "--origin",
              action="store",
              dest="origin",
              default="scanner",
              help=one_line(
                  """Reference point of the q-form transformation of the NIfTI
                     image. If 'scanner' the (0,0,0) coordinates will refer to
                     the scanner's iso center. If 'fov', this coordinate will be
                     the center of the recorded volume (field of view). Default:
                     'scanner'."""
              ),
          )
      )
      p.add_option(
          Option(
              "--minmax",
              action="store",
              nargs=2,
              dest="minmax",
              help=one_line(
                  """Minimum and maximum settings to be stored in the NIfTI
                     header. If any of them is set to 'parse', the scaled data is
                     scanned for the actual minimum and maximum.  To bypass this
                     potentially slow and memory intensive step (the data has to
                     be scaled and fully loaded into memory), fixed values can be
                     provided as space-separated pair, e.g. '5.4 120.4'. It is
                     possible to set a fixed minimum as scan for the actual
                     maximum (and vice versa). Default: 'parse parse'."""
              ),
          )
      )
      p.set_defaults(minmax=("parse", "parse"))
      p.add_option(
          Option(
              "--store-header",
              action="store_true",
              dest="store_header",
              default=False,
              help=one_line(
                  """If set, all information from the PAR header is stored in
                     an extension of the NIfTI file header.  Default: off"""
              ),
          )
      )
      p.add_option(
          Option(
              "--scaling",
              action="store",
              dest="scaling",
              default="dv",
              help=one_line(
                  """Choose data scaling setting. The PAR header defines two
                     different data scaling settings: 'dv' (values displayed on
                     console) and 'fp' (floating point values). Either one can be
                     chosen, or scaling can be disabled completely ('off').  Note
                     that neither method will actually scale the data, but just
                     store the corresponding settings in the NIfTI header, unless
                     non-uniform scaling is used, in which case the data is
                     stored in the file in scaled form. Default: 'dv'"""
              ),
          )
      )
      p.add_option(
          Option(
              "--keep-trace",
              action="store_true",
              dest="keep_trace",
              default=False,
              help=one_line(
                  """Do not discard the diagnostic Philips DTI
                     trace volume, if it exists in the data."""
              ),
          )
      )
      p.add_option(
          Option(
              "--overwrite",
              action="store_true",
              dest="overwrite",
              default=False,
              help="Overwrite file if it exists. Default: False",
          )
      )
      p.add_option(
          Option(
              "--strict-sort",
              action="store_true",
              dest="strict_sort",
              default=False,
              help=one_line(
                  """Use additional keys in determining the order
                  to sort the slices within the .REC file.  This may be necessary
                  for more complicated scans with multiple echos,
                  cardiac phases, ASL label states, etc."""
              ),
          )
      )
      return p
  
file_path: nibabel/nibabel/cmdline/parrec2nii.py
imports: import csv
  import os
  import sys
  from optparse import Option, OptionParser
  import numpy
  import numpy.linalg
  import nibabel
  import nibabel.nifti1
  import nibabel.parrec
  from nibabel.affines import apply_affine, from_matvec, to_matvec
  from nibabel.filename_parser import splitext_addext
  from nibabel.mriutils import MRIError, calculate_dwell_time
  from nibabel.orientations import apply_orientation, inv_ornt_aff, io_orientation
  from nibabel.parrec import one_line
  from nibabel.volumeutils import fname_ext_ul_case
label_desc: Use image node_id 1 for calling a global function with example usage: get_opt_parser() and returns: p