import os
from nipype.interfaces.base import (BaseInterface, BaseInterfaceInputSpec, traits,
    InputMultiPath, File, Directory, TraitedSpec)
from qipipe.staging.fix_dicom import fix_dicom_headers

class FixDicomInputSpec(BaseInterfaceInputSpec):
    collection = traits.Str(desc='The image collection', mandatory=True)

    subject = traits.Str(desc='The subject name', mandatory=True)

    in_files = InputMultiPath(File(exists=True), desc='The input DICOM files', mandatory=True)
    

class FixDicomOutputSpec(TraitedSpec):
    out_files = traits.List(desc="The modified output files", trait=File, exists=True)


class FixDicom(BaseInterface):
    """The FixDicom interface wraps the :meth:`qipipe.staging.fix_dicom.fix_dicom_headers`
    function."""
    
    input_spec = FixDicomInputSpec
    
    output_spec = FixDicomOutputSpec
    
    def _run_interface(self, runtime):
        self._out_files = fix_dicom_headers(self.inputs.collection, self.inputs.subject, *self.inputs.in_files)
        return runtime

    def _list_outputs(self):
        outputs = self._outputs().get()
        outputs['out_files'] = self._out_files
        return outputs

import os
from nipype.interfaces.base import (BaseInterface, BaseInterfaceInputSpec, traits,
    InputMultiPath, File, Directory, TraitedSpec)
from qipipe.staging.fix_dicom import fix_dicom_headers

class FixDicomInputSpec(BaseInterfaceInputSpec):
    collection = traits.Str(desc='The image collection', mandatory=True)

    subject = traits.Str(desc='The subject name', mandatory=True)

    in_file = File(exists=True, desc='The input DICOM file', mandatory=True)
    

class FixDicomOutputSpec(TraitedSpec):
    out_file = File(desc="The modified output file", exists=True)


class FixDicom(BaseInterface):
    """The FixDicom interface wraps the :meth:`qipipe.staging.fix_dicom.fix_dicom_headers`
    function."""
    
    input_spec = FixDicomInputSpec
    
    output_spec = FixDicomOutputSpec
    
    def _run_interface(self, runtime):
        self._out_file = fix_dicom_headers(self.inputs.collection, self.inputs.subject, self.inputs.in_file)
        return runtime

    def _list_outputs(self):
        outputs = self._outputs().get()
        outputs['out_file'] = self._out_file
        return outputs

Fix only one file at a time.
Fix only one file at a time.

  import os
  from nipype.interfaces.base import (BaseInterface, BaseInterfaceInputSpec, traits,
      InputMultiPath, File, Directory, TraitedSpec)
  from qipipe.staging.fix_dicom import fix_dicom_headers
  
  class FixDicomInputSpec(BaseInterfaceInputSpec):
      collection = traits.Str(desc='The image collection', mandatory=True)
  
      subject = traits.Str(desc='The subject name', mandatory=True)
  
-     in_files = InputMultiPath(File(exists=True), desc='The input DICOM files', mandatory=True)
+     in_file = File(exists=True, desc='The input DICOM file', mandatory=True)
      
  
  class FixDicomOutputSpec(TraitedSpec):
-     out_files = traits.List(desc="The modified output files", trait=File, exists=True)
+     out_file = File(desc="The modified output file", exists=True)
  
  
  class FixDicom(BaseInterface):
      """The FixDicom interface wraps the :meth:`qipipe.staging.fix_dicom.fix_dicom_headers`
      function."""
      
      input_spec = FixDicomInputSpec
      
      output_spec = FixDicomOutputSpec
      
      def _run_interface(self, runtime):
-         self._out_files = fix_dicom_headers(self.inputs.collection, self.inputs.subject, *self.inputs.in_files)
+         self._out_file = fix_dicom_headers(self.inputs.collection, self.inputs.subject, self.inputs.in_file)
          return runtime
  
      def _list_outputs(self):
          outputs = self._outputs().get()
-         outputs['out_files'] = self._out_files
+         outputs['out_file'] = self._out_file
          return outputs
  
Fix only one file at a time.
## Code Before:
import os
from nipype.interfaces.base import (BaseInterface, BaseInterfaceInputSpec, traits,
    InputMultiPath, File, Directory, TraitedSpec)
from qipipe.staging.fix_dicom import fix_dicom_headers

class FixDicomInputSpec(BaseInterfaceInputSpec):
    collection = traits.Str(desc='The image collection', mandatory=True)

    subject = traits.Str(desc='The subject name', mandatory=True)

    in_files = InputMultiPath(File(exists=True), desc='The input DICOM files', mandatory=True)
    

class FixDicomOutputSpec(TraitedSpec):
    out_files = traits.List(desc="The modified output files", trait=File, exists=True)


class FixDicom(BaseInterface):
    """The FixDicom interface wraps the :meth:`qipipe.staging.fix_dicom.fix_dicom_headers`
    function."""
    
    input_spec = FixDicomInputSpec
    
    output_spec = FixDicomOutputSpec
    
    def _run_interface(self, runtime):
        self._out_files = fix_dicom_headers(self.inputs.collection, self.inputs.subject, *self.inputs.in_files)
        return runtime

    def _list_outputs(self):
        outputs = self._outputs().get()
        outputs['out_files'] = self._out_files
        return outputs

## Instruction:
Fix only one file at a time.
## Code After:
import os
from nipype.interfaces.base import (BaseInterface, BaseInterfaceInputSpec, traits,
    InputMultiPath, File, Directory, TraitedSpec)
from qipipe.staging.fix_dicom import fix_dicom_headers

class FixDicomInputSpec(BaseInterfaceInputSpec):
    collection = traits.Str(desc='The image collection', mandatory=True)

    subject = traits.Str(desc='The subject name', mandatory=True)

    in_file = File(exists=True, desc='The input DICOM file', mandatory=True)
    

class FixDicomOutputSpec(TraitedSpec):
    out_file = File(desc="The modified output file", exists=True)


class FixDicom(BaseInterface):
    """The FixDicom interface wraps the :meth:`qipipe.staging.fix_dicom.fix_dicom_headers`
    function."""
    
    input_spec = FixDicomInputSpec
    
    output_spec = FixDicomOutputSpec
    
    def _run_interface(self, runtime):
        self._out_file = fix_dicom_headers(self.inputs.collection, self.inputs.subject, self.inputs.in_file)
        return runtime

    def _list_outputs(self):
        outputs = self._outputs().get()
        outputs['out_file'] = self._out_file
        return outputs
