class_docstr: Uses MRIcron's dcm2nii to convert dicom files
  
  Examples
  ========
  
  >>> from nipype.interfaces.dcm2nii import Dcm2nii
  >>> converter = Dcm2nii()
  >>> converter.inputs.source_names = ['functional_1.dcm', 'functional_2.dcm']
  >>> converter.inputs.gzip_output = True
  >>> converter.inputs.output_dir = '.'
  >>> converter.cmdline  # doctest: +ELLIPSIS
  'dcm2nii -a y -c y -b config.ini -v y -d y -e y -g y -i n -n y -o . -p y -x n -f n functional_1.dcm'
class_docstr_tok: ["Uses","MRIcron","'s","dcm2nii","to","convert","dicom","files","Examples","========",">",">",">","from","nipype.interfaces.dcm2nii","import","Dcm2nii",">",">",">","converter","=","Dcm2nii","(",")",">",">",">","converter.inputs.source_names","=","[","'functional_1.dcm","'",",","'functional_2.dcm","'","]",">",">",">","converter.inputs.gzip_output","=","True",">",">",">","converter.inputs.output_dir","=","'",".","'",">",">",">","converter.cmdline","#","doctest",":","+ELLIPSIS","'dcm2nii","-a","y","-c","y","-b","config.ini","-v","y","-d","y","-e","y","-g","y","-i","n","-n","y","-o",".","-p","y","-x","n","-f","n","functional_1.dcm","'"]
code: def _parse_stdout(self, stdout):
      files = []
      reoriented_files = []
      reoriented_and_cropped_files = []
      bvecs = []
      bvals = []
      skip = False
      last_added_file = None
      for line in stdout.split("\n"):
          if not skip:
              out_file = None
              if line.startswith("Saving "):
                  out_file = line[len("Saving ") :]
              elif line.startswith("GZip..."):
                  # for gzipped output files are not absolute
                  fname = line[len("GZip...") :]
                  if (
                      len(files)
                      and os.path.basename(files[-1]) == fname[:-3]
                  ):
                      # we are seeing a previously reported conversion
                      # as being saved in gzipped form -- remove the
                      # obsolete, uncompressed file
                      files.pop()
                  if isdefined(self.inputs.output_dir):
                      output_dir = self.inputs.output_dir
                  else:
                      output_dir = self._gen_filename("output_dir")
                  out_file = os.path.abspath(
                      os.path.join(output_dir, fname)
                  )
              elif line.startswith("Number of diffusion directions "):
                  if last_added_file:
                      base, filename, ext = split_filename(
                          last_added_file
                      )
                      bvecs.append(
                          os.path.join(base, filename + ".bvec")
                      )
                      bvals.append(
                          os.path.join(base, filename + ".bval")
                      )
              elif line.startswith("Removed DWI from DTI scan"):
                  # such line can only follow the 'diffusion' case handled
                  # just above
                  for l in (bvecs, bvals):
                      l[-1] = os.path.join(
                          os.path.dirname(l[-1]),
                          f"x{os.path.basename(l[-1])}",
                      )
              elif re.search(".*->(.*)", line):
                  val = re.search(".*->(.*)", line)
                  val = val.groups()[0]
                  if isdefined(self.inputs.output_dir):
                      output_dir = self.inputs.output_dir
                  else:
                      output_dir = self._gen_filename("output_dir")
                  val = os.path.join(output_dir, val)
                  if os.path.exists(val):
                      out_file = val
  
              if out_file:
                  if out_file not in files:
                      files.append(out_file)
                      last_added_file = out_file
                  continue
  
              if line.startswith("Reorienting as "):
                  reoriented_files.append(
                      line[len("Reorienting as ") :]
                  )
                  skip = True
                  continue
              elif line.startswith("Cropping NIfTI/Analyze image "):
                  base, filename = os.path.split(
                      line[len("Cropping NIfTI/Analyze image ") :]
                  )
                  filename = "c" + filename
                  if (
                      os.path.exists(os.path.join(base, filename))
                      or self.inputs.reorient_and_crop
                  ):
                      # if reorient&crop is true but the file doesn't exist, this errors when setting outputs
                      reoriented_and_cropped_files.append(
                          os.path.join(base, filename)
                      )
                      skip = True
                      continue
  
          skip = False
      return (
          files,
          reoriented_files,
          reoriented_and_cropped_files,
          bvecs,
          bvals,
      )
  
imports: import os
  import re
  from copy import deepcopy
  import itertools
  import glob
  from glob import iglob
  from ..utils.filemanip import split_filename
  from .base import CommandLine, CommandLineInputSpec, InputMultiPath, traits, TraitedSpec, OutputMultiPath, isdefined, File, Directory, PackageInfo
label_desc: Use image node_id 3 for calling the Dcm2nii obj's underlying member method code with example usage: obj._parse_stdout(stdout) and returns: files,  reoriented_files,  reoriented_and_cropped_files,  bvecs,  bvals