We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Meshfix interface inverting command parameters
### Summary
Hi,
While using the MeshFix interface, I received this error:
```shell
RuntimeError: Command:
meshfix /path/to/file.off -a 2.000000 0.200000 --fineTuneIn  4 --shells 2 -o file_fixed.off -q
Standard output:
Fixing asin tolerance to 3.491368e-02
Standard error:

ERROR- number of substeps must be > 0.
Return code: 255
```

### Actual behavior
As shown previously, the interface generated command leading to this error is:
```shell
meshfix /path/to/file.off -a 2.000000 0.200000 --fineTuneIn  4 --shells 2 -o file_fixed.off -q
```
And the error is pretty clear, the `--fineTuneIn` argument requires a distance **and** a substeps number. Those two parameters are actualy given in the code:
```python
finetune_wm = pe.Node(interface=mf.MeshFix(), name='finetune_wm')
finetune_wm.inputs.quiet_mode = True
finetune_wm.inputs.epsilon_angle = 2
finetune_wm.inputs.number_of_biggest_shells = 2
finetune_wm.inputs.finetuning_substeps = 4       # Set the substeps number
finetune_wm.inputs.finetuning_distance = 0.2     # Set the distance
finetune_wm.inputs.finetuning_inwards = True     # Set --fineTuneIn
```
And these parameters are also in the command but in a wrong order:
```shell
0.200000 --fineTuneIn  4
```

### Expected behavior
The correct order should be:
```shell
--fineTuneIn 0.200000  4
```
As writen in the doc:
> --fineTuneIn \<d\> \<n\> Used to fine-tune the minimal distance between surfaces 
> A minimal distance d is ensured, and reached in n substeps

And then the command should be:
```shell
meshfix /path/to/file.off -a 2.000000 --fineTuneIn 0.200000  4 --shells 2 -o file_fixed.off -q
```


--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `nipype/interfaces/meshfix.py`
Content:
```
1 # -*- coding: utf-8 -*-
2 # emacs: -*- mode: python; py-indent-offset: 4; indent-tabs-mode: nil -*-
3 # vi: set ft=python sts=4 ts=4 sw=4 et:
4 """ Fixes meshes:
5 """
6 from __future__ import (print_function, division, unicode_literals,
7                         absolute_import)
8 
9 import os.path as op
10 from ..utils.filemanip import split_filename
11 from .base import (CommandLine, CommandLineInputSpec, traits, TraitedSpec,
12                    isdefined, File)
13 
14 
15 class MeshFixInputSpec(CommandLineInputSpec):
16     number_of_biggest_shells = traits.Int(
17         argstr='--shells %d', desc="Only the N biggest shells are kept")
18 
19     epsilon_angle = traits.Range(
20         argstr='-a %f',
21         low=0.0,
22         high=2.0,
23         desc="Epsilon angle in degrees (must be between 0 and 2)")
24 
25     join_overlapping_largest_components = traits.Bool(
26         argstr='-j',
27         xor=['join_closest_components'],
28         desc='Join 2 biggest components if they overlap, remove the rest.')
29 
30     join_closest_components = traits.Bool(
31         argstr='-jc',
32         xor=['join_closest_components'],
33         desc='Join the closest pair of components.')
34 
35     quiet_mode = traits.Bool(
36         argstr='-q', desc="Quiet mode, don't write much to stdout.")
37 
38     dont_clean = traits.Bool(argstr='--no-clean', desc="Don't Clean")
39 
40     save_as_stl = traits.Bool(
41         xor=['save_as_vrml', 'save_as_freesurfer_mesh'],
42         argstr='--stl',
43         desc="Result is saved in stereolithographic format (.stl)")
44     save_as_vrml = traits.Bool(
45         argstr='--wrl',
46         xor=['save_as_stl', 'save_as_freesurfer_mesh'],
47         desc="Result is saved in VRML1.0 format (.wrl)")
48     save_as_freesurfer_mesh = traits.Bool(
49         argstr='--fsmesh',
50         xor=['save_as_vrml', 'save_as_stl'],
51         desc="Result is saved in freesurfer mesh format")
52 
53     remove_handles = traits.Bool(
54         argstr='--remove-handles', desc="Remove handles")
55 
56     uniform_remeshing_steps = traits.Int(
57         argstr='-u %d',
58         requires=['uniform_remeshing_vertices'],
59         desc="Number of steps for uniform remeshing of the whole mesh")
60 
61     uniform_remeshing_vertices = traits.Int(
62         argstr='--vertices %d',
63         requires=['uniform_remeshing_steps'],
64         desc="Constrains the number of vertices."
65         "Must be used with uniform_remeshing_steps")
66 
67     laplacian_smoothing_steps = traits.Int(
68         argstr='--smooth %d',
69         desc="The number of laplacian smoothing steps to apply")
70 
71     x_shift = traits.Int(
72         argstr='--smooth %d',
73         desc=
74         "Shifts the coordinates of the vertices when saving. Output must be in FreeSurfer format"
75     )
76 
77     # Cutting, decoupling, dilation
78     cut_outer = traits.Int(
79         argstr='--cut-outer %d',
80         desc="Remove triangles of 1st that are outside of the 2nd shell.")
81     cut_inner = traits.Int(
82         argstr='--cut-inner %d',
83         desc=
84         "Remove triangles of 1st that are inside of the 2nd shell. Dilate 2nd by N; Fill holes and keep only 1st afterwards."
85     )
86     decouple_inin = traits.Int(
87         argstr='--decouple-inin %d',
88         desc="Treat 1st file as inner, 2nd file as outer component."
89         "Resolve overlaps by moving inners triangles inwards. Constrain the min distance between the components > d."
90     )
91     decouple_outin = traits.Int(
92         argstr='--decouple-outin %d',
93         desc="Treat 1st file as outer, 2nd file as inner component."
94         "Resolve overlaps by moving outers triangles inwards. Constrain the min distance between the components > d."
95     )
96     decouple_outout = traits.Int(
97         argstr='--decouple-outout %d',
98         desc="Treat 1st file as outer, 2nd file as inner component."
99         "Resolve overlaps by moving outers triangles outwards. Constrain the min distance between the components > d."
100     )
101 
102     finetuning_inwards = traits.Bool(
103         argstr='--fineTuneIn ',
104         requires=['finetuning_distance', 'finetuning_substeps'])
105     finetuning_outwards = traits.Bool(
106         argstr='--fineTuneIn ',
107         requires=['finetuning_distance', 'finetuning_substeps'],
108         xor=['finetuning_inwards'],
109         desc=
110         'Similar to finetuning_inwards, but ensures minimal distance in the other direction'
111     )
112     finetuning_distance = traits.Float(
113         argstr='%f',
114         requires=['finetuning_substeps'],
115         desc="Used to fine-tune the minimal distance between surfaces."
116         "A minimal distance d is ensured, and reached in n substeps. When using the surfaces for subsequent volume meshing by gmsh, this step prevent too flat tetrahedra2)"
117     )
118     finetuning_substeps = traits.Int(
119         argstr='%d',
120         requires=['finetuning_distance'],
121         desc="Used to fine-tune the minimal distance between surfaces."
122         "A minimal distance d is ensured, and reached in n substeps. When using the surfaces for subsequent volume meshing by gmsh, this step prevent too flat tetrahedra2)"
123     )
124 
125     dilation = traits.Int(
126         argstr='--dilate %d',
127         desc="Dilate the surface by d. d < 0 means shrinking.")
128     set_intersections_to_one = traits.Bool(
129         argstr='--intersect',
130         desc="If the mesh contains intersections, return value = 1."
131         "If saved in gmsh format, intersections will be highlighted.")
132 
133     in_file1 = File(exists=True, argstr="%s", position=1, mandatory=True)
134     in_file2 = File(exists=True, argstr="%s", position=2)
135     output_type = traits.Enum(
136         'off', ['stl', 'msh', 'wrl', 'vrml', 'fs', 'off'],
137         usedefault=True,
138         desc='The output type to save the file as.')
139     out_filename = File(
140         genfile=True,
141         argstr="-o %s",
142         desc='The output filename for the fixed mesh file')
143 
144 
145 class MeshFixOutputSpec(TraitedSpec):
146     mesh_file = File(exists=True, desc='The output mesh file')
147 
148 
149 class MeshFix(CommandLine):
150     """
151     MeshFix v1.2-alpha - by Marco Attene, Mirko Windhoff, Axel Thielscher.
152 
153     .. seealso::
154 
155         http://jmeshlib.sourceforge.net
156             Sourceforge page
157 
158         http://simnibs.de/installation/meshfixandgetfem
159             Ubuntu installation instructions
160 
161     If MeshFix is used for research purposes, please cite the following paper:
162     M. Attene - A lightweight approach to repairing digitized polygon meshes.
163     The Visual Computer, 2010. (c) Springer.
164 
165     Accepted input formats are OFF, PLY and STL.
166     Other formats (like .msh for gmsh) are supported only partially.
167 
168     Example
169     -------
170 
171     >>> import nipype.interfaces.meshfix as mf
172     >>> fix = mf.MeshFix()
173     >>> fix.inputs.in_file1 = 'lh-pial.stl'
174     >>> fix.inputs.in_file2 = 'rh-pial.stl'
175     >>> fix.run()                                    # doctest: +SKIP
176     >>> fix.cmdline
177     'meshfix lh-pial.stl rh-pial.stl -o lh-pial_fixed.off'
178     """
179     _cmd = 'meshfix'
180     input_spec = MeshFixInputSpec
181     output_spec = MeshFixOutputSpec
182 
183     def _list_outputs(self):
184         outputs = self.output_spec().get()
185         if isdefined(self.inputs.out_filename):
186             path, name, ext = split_filename(self.inputs.out_filename)
187             ext = ext.replace('.', '')
188             out_types = ['stl', 'msh', 'wrl', 'vrml', 'fs', 'off']
189             # Make sure that the output filename uses one of the possible file types
190             if any(ext == out_type.lower() for out_type in out_types):
191                 outputs['mesh_file'] = op.abspath(self.inputs.out_filename)
192             else:
193                 outputs['mesh_file'] = op.abspath(
194                     name + '.' + self.inputs.output_type)
195         else:
196             outputs['mesh_file'] = op.abspath(self._gen_outfilename())
197         return outputs
198 
199     def _gen_filename(self, name):
200         if name == 'out_filename':
201             return self._gen_outfilename()
202         else:
203             return None
204 
205     def _gen_outfilename(self):
206         _, name, _ = split_filename(self.inputs.in_file1)
207         if self.inputs.save_as_freesurfer_mesh or self.inputs.output_type == 'fs':
208             self.inputs.output_type = 'fs'
209             self.inputs.save_as_freesurfer_mesh = True
210         if self.inputs.save_as_stl or self.inputs.output_type == 'stl':
211             self.inputs.output_type = 'stl'
212             self.inputs.save_as_stl = True
213         if self.inputs.save_as_vrml or self.inputs.output_type == 'vrml':
214             self.inputs.output_type = 'vrml'
215             self.inputs.save_as_vrml = True
216         return name + '_fixed.' + self.inputs.output_type
217
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/nipype/interfaces/meshfix.py b/nipype/interfaces/meshfix.py
--- a/nipype/interfaces/meshfix.py
+++ b/nipype/interfaces/meshfix.py
@@ -70,8 +70,7 @@
 
     x_shift = traits.Int(
         argstr='--smooth %d',
-        desc=
-        "Shifts the coordinates of the vertices when saving. Output must be in FreeSurfer format"
+        desc="Shifts the coordinates of the vertices when saving. Output must be in FreeSurfer format"
     )
 
     # Cutting, decoupling, dilation
@@ -80,8 +79,7 @@
         desc="Remove triangles of 1st that are outside of the 2nd shell.")
     cut_inner = traits.Int(
         argstr='--cut-inner %d',
-        desc=
-        "Remove triangles of 1st that are inside of the 2nd shell. Dilate 2nd by N; Fill holes and keep only 1st afterwards."
+        desc="Remove triangles of 1st that are inside of the 2nd shell. Dilate 2nd by N; Fill holes and keep only 1st afterwards."
     )
     decouple_inin = traits.Int(
         argstr='--decouple-inin %d',
@@ -101,23 +99,28 @@
 
     finetuning_inwards = traits.Bool(
         argstr='--fineTuneIn ',
-        requires=['finetuning_distance', 'finetuning_substeps'])
+        requires=['finetuning_distance', 'finetuning_substeps'],
+        position=-3,
+        desc="Used to fine-tune the minimal distance between surfaces."
+    )
     finetuning_outwards = traits.Bool(
-        argstr='--fineTuneIn ',
+        argstr='--fineTuneOut ',
         requires=['finetuning_distance', 'finetuning_substeps'],
+        position=-3,
         xor=['finetuning_inwards'],
-        desc=
-        'Similar to finetuning_inwards, but ensures minimal distance in the other direction'
+        desc='Similar to finetuning_inwards, but ensures minimal distance in the other direction'
     )
     finetuning_distance = traits.Float(
         argstr='%f',
         requires=['finetuning_substeps'],
+        position=-2,
         desc="Used to fine-tune the minimal distance between surfaces."
         "A minimal distance d is ensured, and reached in n substeps. When using the surfaces for subsequent volume meshing by gmsh, this step prevent too flat tetrahedra2)"
     )
     finetuning_substeps = traits.Int(
         argstr='%d',
         requires=['finetuning_distance'],
+        position=-1,
         desc="Used to fine-tune the minimal distance between surfaces."
         "A minimal distance d is ensured, and reached in n substeps. When using the surfaces for subsequent volume meshing by gmsh, this step prevent too flat tetrahedra2)"
     )

{"golden_diff": "diff --git a/nipype/interfaces/meshfix.py b/nipype/interfaces/meshfix.py\n--- a/nipype/interfaces/meshfix.py\n+++ b/nipype/interfaces/meshfix.py\n@@ -70,8 +70,7 @@\n \n     x_shift = traits.Int(\n         argstr='--smooth %d',\n-        desc=\n-        \"Shifts the coordinates of the vertices when saving. Output must be in FreeSurfer format\"\n+        desc=\"Shifts the coordinates of the vertices when saving. Output must be in FreeSurfer format\"\n     )\n \n     # Cutting, decoupling, dilation\n@@ -80,8 +79,7 @@\n         desc=\"Remove triangles of 1st that are outside of the 2nd shell.\")\n     cut_inner = traits.Int(\n         argstr='--cut-inner %d',\n-        desc=\n-        \"Remove triangles of 1st that are inside of the 2nd shell. Dilate 2nd by N; Fill holes and keep only 1st afterwards.\"\n+        desc=\"Remove triangles of 1st that are inside of the 2nd shell. Dilate 2nd by N; Fill holes and keep only 1st afterwards.\"\n     )\n     decouple_inin = traits.Int(\n         argstr='--decouple-inin %d',\n@@ -101,23 +99,28 @@\n \n     finetuning_inwards = traits.Bool(\n         argstr='--fineTuneIn ',\n-        requires=['finetuning_distance', 'finetuning_substeps'])\n+        requires=['finetuning_distance', 'finetuning_substeps'],\n+        position=-3,\n+        desc=\"Used to fine-tune the minimal distance between surfaces.\"\n+    )\n     finetuning_outwards = traits.Bool(\n-        argstr='--fineTuneIn ',\n+        argstr='--fineTuneOut ',\n         requires=['finetuning_distance', 'finetuning_substeps'],\n+        position=-3,\n         xor=['finetuning_inwards'],\n-        desc=\n-        'Similar to finetuning_inwards, but ensures minimal distance in the other direction'\n+        desc='Similar to finetuning_inwards, but ensures minimal distance in the other direction'\n     )\n     finetuning_distance = traits.Float(\n         argstr='%f',\n         requires=['finetuning_substeps'],\n+        position=-2,\n         desc=\"Used to fine-tune the minimal distance between surfaces.\"\n         \"A minimal distance d is ensured, and reached in n substeps. When using the surfaces for subsequent volume meshing by gmsh, this step prevent too flat tetrahedra2)\"\n     )\n     finetuning_substeps = traits.Int(\n         argstr='%d',\n         requires=['finetuning_distance'],\n+        position=-1,\n         desc=\"Used to fine-tune the minimal distance between surfaces.\"\n         \"A minimal distance d is ensured, and reached in n substeps. When using the surfaces for subsequent volume meshing by gmsh, this step prevent too flat tetrahedra2)\"\n     )\n", "issue": "Meshfix interface inverting command parameters\n### Summary\r\nHi,\r\nWhile using the MeshFix interface, I received this error:\r\n```shell\r\nRuntimeError: Command:\r\nmeshfix /path/to/file.off -a 2.000000 0.200000 --fineTuneIn  4 --shells 2 -o file_fixed.off -q\r\nStandard output:\r\nFixing asin tolerance to 3.491368e-02\r\nStandard error:\r\n\r\nERROR- number of substeps must be > 0.\r\nReturn code: 255\r\n```\r\n\r\n### Actual behavior\r\nAs shown previously, the interface generated command leading to this error is:\r\n```shell\r\nmeshfix /path/to/file.off -a 2.000000 0.200000 --fineTuneIn  4 --shells 2 -o file_fixed.off -q\r\n```\r\nAnd the error is pretty clear, the `--fineTuneIn` argument requires a distance **and** a substeps number. Those two parameters are actualy given in the code:\r\n```python\r\nfinetune_wm = pe.Node(interface=mf.MeshFix(), name='finetune_wm')\r\nfinetune_wm.inputs.quiet_mode = True\r\nfinetune_wm.inputs.epsilon_angle = 2\r\nfinetune_wm.inputs.number_of_biggest_shells = 2\r\nfinetune_wm.inputs.finetuning_substeps = 4       # Set the substeps number\r\nfinetune_wm.inputs.finetuning_distance = 0.2     # Set the distance\r\nfinetune_wm.inputs.finetuning_inwards = True     # Set --fineTuneIn\r\n```\r\nAnd these parameters are also in the command but in a wrong order:\r\n```shell\r\n0.200000 --fineTuneIn  4\r\n```\r\n\r\n### Expected behavior\r\nThe correct order should be:\r\n```shell\r\n--fineTuneIn 0.200000  4\r\n```\r\nAs writen in the doc:\r\n> --fineTuneIn \\<d\\> \\<n\\> Used to fine-tune the minimal distance between surfaces \r\n> A minimal distance d is ensured, and reached in n substeps\r\n\r\nAnd then the command should be:\r\n```shell\r\nmeshfix /path/to/file.off -a 2.000000 --fineTuneIn 0.200000  4 --shells 2 -o file_fixed.off -q\r\n```\r\n\n", "before_files": [{"content": "# -*- coding: utf-8 -*-\n# emacs: -*- mode: python; py-indent-offset: 4; indent-tabs-mode: nil -*-\n# vi: set ft=python sts=4 ts=4 sw=4 et:\n\"\"\" Fixes meshes:\n\"\"\"\nfrom __future__ import (print_function, division, unicode_literals,\n                        absolute_import)\n\nimport os.path as op\nfrom ..utils.filemanip import split_filename\nfrom .base import (CommandLine, CommandLineInputSpec, traits, TraitedSpec,\n                   isdefined, File)\n\n\nclass MeshFixInputSpec(CommandLineInputSpec):\n    number_of_biggest_shells = traits.Int(\n        argstr='--shells %d', desc=\"Only the N biggest shells are kept\")\n\n    epsilon_angle = traits.Range(\n        argstr='-a %f',\n        low=0.0,\n        high=2.0,\n        desc=\"Epsilon angle in degrees (must be between 0 and 2)\")\n\n    join_overlapping_largest_components = traits.Bool(\n        argstr='-j',\n        xor=['join_closest_components'],\n        desc='Join 2 biggest components if they overlap, remove the rest.')\n\n    join_closest_components = traits.Bool(\n        argstr='-jc',\n        xor=['join_closest_components'],\n        desc='Join the closest pair of components.')\n\n    quiet_mode = traits.Bool(\n        argstr='-q', desc=\"Quiet mode, don't write much to stdout.\")\n\n    dont_clean = traits.Bool(argstr='--no-clean', desc=\"Don't Clean\")\n\n    save_as_stl = traits.Bool(\n        xor=['save_as_vrml', 'save_as_freesurfer_mesh'],\n        argstr='--stl',\n        desc=\"Result is saved in stereolithographic format (.stl)\")\n    save_as_vrml = traits.Bool(\n        argstr='--wrl',\n        xor=['save_as_stl', 'save_as_freesurfer_mesh'],\n        desc=\"Result is saved in VRML1.0 format (.wrl)\")\n    save_as_freesurfer_mesh = traits.Bool(\n        argstr='--fsmesh',\n        xor=['save_as_vrml', 'save_as_stl'],\n        desc=\"Result is saved in freesurfer mesh format\")\n\n    remove_handles = traits.Bool(\n        argstr='--remove-handles', desc=\"Remove handles\")\n\n    uniform_remeshing_steps = traits.Int(\n        argstr='-u %d',\n        requires=['uniform_remeshing_vertices'],\n        desc=\"Number of steps for uniform remeshing of the whole mesh\")\n\n    uniform_remeshing_vertices = traits.Int(\n        argstr='--vertices %d',\n        requires=['uniform_remeshing_steps'],\n        desc=\"Constrains the number of vertices.\"\n        \"Must be used with uniform_remeshing_steps\")\n\n    laplacian_smoothing_steps = traits.Int(\n        argstr='--smooth %d',\n        desc=\"The number of laplacian smoothing steps to apply\")\n\n    x_shift = traits.Int(\n        argstr='--smooth %d',\n        desc=\n        \"Shifts the coordinates of the vertices when saving. Output must be in FreeSurfer format\"\n    )\n\n    # Cutting, decoupling, dilation\n    cut_outer = traits.Int(\n        argstr='--cut-outer %d',\n        desc=\"Remove triangles of 1st that are outside of the 2nd shell.\")\n    cut_inner = traits.Int(\n        argstr='--cut-inner %d',\n        desc=\n        \"Remove triangles of 1st that are inside of the 2nd shell. Dilate 2nd by N; Fill holes and keep only 1st afterwards.\"\n    )\n    decouple_inin = traits.Int(\n        argstr='--decouple-inin %d',\n        desc=\"Treat 1st file as inner, 2nd file as outer component.\"\n        \"Resolve overlaps by moving inners triangles inwards. Constrain the min distance between the components > d.\"\n    )\n    decouple_outin = traits.Int(\n        argstr='--decouple-outin %d',\n        desc=\"Treat 1st file as outer, 2nd file as inner component.\"\n        \"Resolve overlaps by moving outers triangles inwards. Constrain the min distance between the components > d.\"\n    )\n    decouple_outout = traits.Int(\n        argstr='--decouple-outout %d',\n        desc=\"Treat 1st file as outer, 2nd file as inner component.\"\n        \"Resolve overlaps by moving outers triangles outwards. Constrain the min distance between the components > d.\"\n    )\n\n    finetuning_inwards = traits.Bool(\n        argstr='--fineTuneIn ',\n        requires=['finetuning_distance', 'finetuning_substeps'])\n    finetuning_outwards = traits.Bool(\n        argstr='--fineTuneIn ',\n        requires=['finetuning_distance', 'finetuning_substeps'],\n        xor=['finetuning_inwards'],\n        desc=\n        'Similar to finetuning_inwards, but ensures minimal distance in the other direction'\n    )\n    finetuning_distance = traits.Float(\n        argstr='%f',\n        requires=['finetuning_substeps'],\n        desc=\"Used to fine-tune the minimal distance between surfaces.\"\n        \"A minimal distance d is ensured, and reached in n substeps. When using the surfaces for subsequent volume meshing by gmsh, this step prevent too flat tetrahedra2)\"\n    )\n    finetuning_substeps = traits.Int(\n        argstr='%d',\n        requires=['finetuning_distance'],\n        desc=\"Used to fine-tune the minimal distance between surfaces.\"\n        \"A minimal distance d is ensured, and reached in n substeps. When using the surfaces for subsequent volume meshing by gmsh, this step prevent too flat tetrahedra2)\"\n    )\n\n    dilation = traits.Int(\n        argstr='--dilate %d',\n        desc=\"Dilate the surface by d. d < 0 means shrinking.\")\n    set_intersections_to_one = traits.Bool(\n        argstr='--intersect',\n        desc=\"If the mesh contains intersections, return value = 1.\"\n        \"If saved in gmsh format, intersections will be highlighted.\")\n\n    in_file1 = File(exists=True, argstr=\"%s\", position=1, mandatory=True)\n    in_file2 = File(exists=True, argstr=\"%s\", position=2)\n    output_type = traits.Enum(\n        'off', ['stl', 'msh', 'wrl', 'vrml', 'fs', 'off'],\n        usedefault=True,\n        desc='The output type to save the file as.')\n    out_filename = File(\n        genfile=True,\n        argstr=\"-o %s\",\n        desc='The output filename for the fixed mesh file')\n\n\nclass MeshFixOutputSpec(TraitedSpec):\n    mesh_file = File(exists=True, desc='The output mesh file')\n\n\nclass MeshFix(CommandLine):\n    \"\"\"\n    MeshFix v1.2-alpha - by Marco Attene, Mirko Windhoff, Axel Thielscher.\n\n    .. seealso::\n\n        http://jmeshlib.sourceforge.net\n            Sourceforge page\n\n        http://simnibs.de/installation/meshfixandgetfem\n            Ubuntu installation instructions\n\n    If MeshFix is used for research purposes, please cite the following paper:\n    M. Attene - A lightweight approach to repairing digitized polygon meshes.\n    The Visual Computer, 2010. (c) Springer.\n\n    Accepted input formats are OFF, PLY and STL.\n    Other formats (like .msh for gmsh) are supported only partially.\n\n    Example\n    -------\n\n    >>> import nipype.interfaces.meshfix as mf\n    >>> fix = mf.MeshFix()\n    >>> fix.inputs.in_file1 = 'lh-pial.stl'\n    >>> fix.inputs.in_file2 = 'rh-pial.stl'\n    >>> fix.run()                                    # doctest: +SKIP\n    >>> fix.cmdline\n    'meshfix lh-pial.stl rh-pial.stl -o lh-pial_fixed.off'\n    \"\"\"\n    _cmd = 'meshfix'\n    input_spec = MeshFixInputSpec\n    output_spec = MeshFixOutputSpec\n\n    def _list_outputs(self):\n        outputs = self.output_spec().get()\n        if isdefined(self.inputs.out_filename):\n            path, name, ext = split_filename(self.inputs.out_filename)\n            ext = ext.replace('.', '')\n            out_types = ['stl', 'msh', 'wrl', 'vrml', 'fs', 'off']\n            # Make sure that the output filename uses one of the possible file types\n            if any(ext == out_type.lower() for out_type in out_types):\n                outputs['mesh_file'] = op.abspath(self.inputs.out_filename)\n            else:\n                outputs['mesh_file'] = op.abspath(\n                    name + '.' + self.inputs.output_type)\n        else:\n            outputs['mesh_file'] = op.abspath(self._gen_outfilename())\n        return outputs\n\n    def _gen_filename(self, name):\n        if name == 'out_filename':\n            return self._gen_outfilename()\n        else:\n            return None\n\n    def _gen_outfilename(self):\n        _, name, _ = split_filename(self.inputs.in_file1)\n        if self.inputs.save_as_freesurfer_mesh or self.inputs.output_type == 'fs':\n            self.inputs.output_type = 'fs'\n            self.inputs.save_as_freesurfer_mesh = True\n        if self.inputs.save_as_stl or self.inputs.output_type == 'stl':\n            self.inputs.output_type = 'stl'\n            self.inputs.save_as_stl = True\n        if self.inputs.save_as_vrml or self.inputs.output_type == 'vrml':\n            self.inputs.output_type = 'vrml'\n            self.inputs.save_as_vrml = True\n        return name + '_fixed.' + self.inputs.output_type\n", "path": "nipype/interfaces/meshfix.py"}], "after_files": [{"content": "# -*- coding: utf-8 -*-\n# emacs: -*- mode: python; py-indent-offset: 4; indent-tabs-mode: nil -*-\n# vi: set ft=python sts=4 ts=4 sw=4 et:\n\"\"\" Fixes meshes:\n\"\"\"\nfrom __future__ import (print_function, division, unicode_literals,\n                        absolute_import)\n\nimport os.path as op\nfrom ..utils.filemanip import split_filename\nfrom .base import (CommandLine, CommandLineInputSpec, traits, TraitedSpec,\n                   isdefined, File)\n\n\nclass MeshFixInputSpec(CommandLineInputSpec):\n    number_of_biggest_shells = traits.Int(\n        argstr='--shells %d', desc=\"Only the N biggest shells are kept\")\n\n    epsilon_angle = traits.Range(\n        argstr='-a %f',\n        low=0.0,\n        high=2.0,\n        desc=\"Epsilon angle in degrees (must be between 0 and 2)\")\n\n    join_overlapping_largest_components = traits.Bool(\n        argstr='-j',\n        xor=['join_closest_components'],\n        desc='Join 2 biggest components if they overlap, remove the rest.')\n\n    join_closest_components = traits.Bool(\n        argstr='-jc',\n        xor=['join_closest_components'],\n        desc='Join the closest pair of components.')\n\n    quiet_mode = traits.Bool(\n        argstr='-q', desc=\"Quiet mode, don't write much to stdout.\")\n\n    dont_clean = traits.Bool(argstr='--no-clean', desc=\"Don't Clean\")\n\n    save_as_stl = traits.Bool(\n        xor=['save_as_vrml', 'save_as_freesurfer_mesh'],\n        argstr='--stl',\n        desc=\"Result is saved in stereolithographic format (.stl)\")\n    save_as_vrml = traits.Bool(\n        argstr='--wrl',\n        xor=['save_as_stl', 'save_as_freesurfer_mesh'],\n        desc=\"Result is saved in VRML1.0 format (.wrl)\")\n    save_as_freesurfer_mesh = traits.Bool(\n        argstr='--fsmesh',\n        xor=['save_as_vrml', 'save_as_stl'],\n        desc=\"Result is saved in freesurfer mesh format\")\n\n    remove_handles = traits.Bool(\n        argstr='--remove-handles', desc=\"Remove handles\")\n\n    uniform_remeshing_steps = traits.Int(\n        argstr='-u %d',\n        requires=['uniform_remeshing_vertices'],\n        desc=\"Number of steps for uniform remeshing of the whole mesh\")\n\n    uniform_remeshing_vertices = traits.Int(\n        argstr='--vertices %d',\n        requires=['uniform_remeshing_steps'],\n        desc=\"Constrains the number of vertices.\"\n        \"Must be used with uniform_remeshing_steps\")\n\n    laplacian_smoothing_steps = traits.Int(\n        argstr='--smooth %d',\n        desc=\"The number of laplacian smoothing steps to apply\")\n\n    x_shift = traits.Int(\n        argstr='--smooth %d',\n        desc=\"Shifts the coordinates of the vertices when saving. Output must be in FreeSurfer format\"\n    )\n\n    # Cutting, decoupling, dilation\n    cut_outer = traits.Int(\n        argstr='--cut-outer %d',\n        desc=\"Remove triangles of 1st that are outside of the 2nd shell.\")\n    cut_inner = traits.Int(\n        argstr='--cut-inner %d',\n        desc=\"Remove triangles of 1st that are inside of the 2nd shell. Dilate 2nd by N; Fill holes and keep only 1st afterwards.\"\n    )\n    decouple_inin = traits.Int(\n        argstr='--decouple-inin %d',\n        desc=\"Treat 1st file as inner, 2nd file as outer component.\"\n        \"Resolve overlaps by moving inners triangles inwards. Constrain the min distance between the components > d.\"\n    )\n    decouple_outin = traits.Int(\n        argstr='--decouple-outin %d',\n        desc=\"Treat 1st file as outer, 2nd file as inner component.\"\n        \"Resolve overlaps by moving outers triangles inwards. Constrain the min distance between the components > d.\"\n    )\n    decouple_outout = traits.Int(\n        argstr='--decouple-outout %d',\n        desc=\"Treat 1st file as outer, 2nd file as inner component.\"\n        \"Resolve overlaps by moving outers triangles outwards. Constrain the min distance between the components > d.\"\n    )\n\n    finetuning_inwards = traits.Bool(\n        argstr='--fineTuneIn ',\n        requires=['finetuning_distance', 'finetuning_substeps'],\n        position=-3,\n        desc=\"Used to fine-tune the minimal distance between surfaces.\"\n    )\n    finetuning_outwards = traits.Bool(\n        argstr='--fineTuneOut ',\n        requires=['finetuning_distance', 'finetuning_substeps'],\n        position=-3,\n        xor=['finetuning_inwards'],\n        desc='Similar to finetuning_inwards, but ensures minimal distance in the other direction'\n    )\n    finetuning_distance = traits.Float(\n        argstr='%f',\n        requires=['finetuning_substeps'],\n        position=-2,\n        desc=\"Used to fine-tune the minimal distance between surfaces.\"\n        \"A minimal distance d is ensured, and reached in n substeps. When using the surfaces for subsequent volume meshing by gmsh, this step prevent too flat tetrahedra2)\"\n    )\n    finetuning_substeps = traits.Int(\n        argstr='%d',\n        requires=['finetuning_distance'],\n        position=-1,\n        desc=\"Used to fine-tune the minimal distance between surfaces.\"\n        \"A minimal distance d is ensured, and reached in n substeps. When using the surfaces for subsequent volume meshing by gmsh, this step prevent too flat tetrahedra2)\"\n    )\n\n    dilation = traits.Int(\n        argstr='--dilate %d',\n        desc=\"Dilate the surface by d. d < 0 means shrinking.\")\n    set_intersections_to_one = traits.Bool(\n        argstr='--intersect',\n        desc=\"If the mesh contains intersections, return value = 1.\"\n        \"If saved in gmsh format, intersections will be highlighted.\")\n\n    in_file1 = File(exists=True, argstr=\"%s\", position=1, mandatory=True)\n    in_file2 = File(exists=True, argstr=\"%s\", position=2)\n    output_type = traits.Enum(\n        'off', ['stl', 'msh', 'wrl', 'vrml', 'fs', 'off'],\n        usedefault=True,\n        desc='The output type to save the file as.')\n    out_filename = File(\n        genfile=True,\n        argstr=\"-o %s\",\n        desc='The output filename for the fixed mesh file')\n\n\nclass MeshFixOutputSpec(TraitedSpec):\n    mesh_file = File(exists=True, desc='The output mesh file')\n\n\nclass MeshFix(CommandLine):\n    \"\"\"\n    MeshFix v1.2-alpha - by Marco Attene, Mirko Windhoff, Axel Thielscher.\n\n    .. seealso::\n\n        http://jmeshlib.sourceforge.net\n            Sourceforge page\n\n        http://simnibs.de/installation/meshfixandgetfem\n            Ubuntu installation instructions\n\n    If MeshFix is used for research purposes, please cite the following paper:\n    M. Attene - A lightweight approach to repairing digitized polygon meshes.\n    The Visual Computer, 2010. (c) Springer.\n\n    Accepted input formats are OFF, PLY and STL.\n    Other formats (like .msh for gmsh) are supported only partially.\n\n    Example\n    -------\n\n    >>> import nipype.interfaces.meshfix as mf\n    >>> fix = mf.MeshFix()\n    >>> fix.inputs.in_file1 = 'lh-pial.stl'\n    >>> fix.inputs.in_file2 = 'rh-pial.stl'\n    >>> fix.run()                                    # doctest: +SKIP\n    >>> fix.cmdline\n    'meshfix lh-pial.stl rh-pial.stl -o lh-pial_fixed.off'\n    \"\"\"\n    _cmd = 'meshfix'\n    input_spec = MeshFixInputSpec\n    output_spec = MeshFixOutputSpec\n\n    def _list_outputs(self):\n        outputs = self.output_spec().get()\n        if isdefined(self.inputs.out_filename):\n            path, name, ext = split_filename(self.inputs.out_filename)\n            ext = ext.replace('.', '')\n            out_types = ['stl', 'msh', 'wrl', 'vrml', 'fs', 'off']\n            # Make sure that the output filename uses one of the possible file types\n            if any(ext == out_type.lower() for out_type in out_types):\n                outputs['mesh_file'] = op.abspath(self.inputs.out_filename)\n            else:\n                outputs['mesh_file'] = op.abspath(\n                    name + '.' + self.inputs.output_type)\n        else:\n            outputs['mesh_file'] = op.abspath(self._gen_outfilename())\n        return outputs\n\n    def _gen_filename(self, name):\n        if name == 'out_filename':\n            return self._gen_outfilename()\n        else:\n            return None\n\n    def _gen_outfilename(self):\n        _, name, _ = split_filename(self.inputs.in_file1)\n        if self.inputs.save_as_freesurfer_mesh or self.inputs.output_type == 'fs':\n            self.inputs.output_type = 'fs'\n            self.inputs.save_as_freesurfer_mesh = True\n        if self.inputs.save_as_stl or self.inputs.output_type == 'stl':\n            self.inputs.output_type = 'stl'\n            self.inputs.save_as_stl = True\n        if self.inputs.save_as_vrml or self.inputs.output_type == 'vrml':\n            self.inputs.output_type = 'vrml'\n            self.inputs.save_as_vrml = True\n        return name + '_fixed.' + self.inputs.output_type\n", "path": "nipype/interfaces/meshfix.py"}]}