internlm/SWE-Fixer-Train-110K huggingface dataset:
Repository: nipy/nipype

Issue:
AFNI's 3dmask_tool does not accept multiple mask files
### Summary

As far as I can see AFNI's `3dmask_tool` allows multiple masks as input, while it is not possible to input a list as `in_file` argument?

See [here](https://afni.nimh.nih.gov/pub/dist/doc/program_help/3dmask_tool.html) for details on the tool.

Error:
```python
Traceback (most recent call last):
  File "/home/hstojic/.pyenv/nipy/local/lib/python2.7/site-packages/nipype/pipeline/plugins/linear.py", line 44, in run
    node.run(updatehash=updatehash)
  File "/home/hstojic/.pyenv/nipy/local/lib/python2.7/site-packages/nipype/pipeline/engine/nodes.py", line 408, in run
    cached, updated = self.is_cached()
  File "/home/hstojic/.pyenv/nipy/local/lib/python2.7/site-packages/nipype/pipeline/engine/nodes.py", line 294, in is_cached
    hashed_inputs, hashvalue = self._get_hashval()
  File "/home/hstojic/.pyenv/nipy/local/lib/python2.7/site-packages/nipype/pipeline/engine/nodes.py", line 488, in _get_hashval
    self._get_inputs()
  File "/home/hstojic/.pyenv/nipy/local/lib/python2.7/site-packages/nipype/pipeline/engine/nodes.py", line 531, in _get_inputs
    self.set_input(key, deepcopy(output_value))
  File "/home/hstojic/.pyenv/nipy/local/lib/python2.7/site-packages/nipype/pipeline/engine/nodes.py", line 276, in set_input
    setattr(self.inputs, parameter, deepcopy(val))
  File "/home/hstojic/.pyenv/nipy/local/lib/python2.7/site-packages/nipype/interfaces/base/traits_extension.py", line 103, in validate
    validated_value = super(File, self).validate(object, name, value)
  File "/home/hstojic/.pyenv/nipy/local/lib/python2.7/site-packages/traits/trait_types.py", line 411, in validate
    self.error( object, name, value )
  File "/home/hstojic/.pyenv/nipy/local/lib/python2.7/site-packages/traits/trait_handlers.py", line 172, in error
    value )
TraitError: The 'in_file' trait of a MaskToolInputSpec instance must be an existing file name, but a value of ['mask_1',...,'mask_n'] <type 'list'> was specified.
```

### Execution environment

- My python environment outside container



Discussion:
You can probably fix this with an `InputMultiObject`, e.g.,

```Python
from ..base import InputMultiObject  # nipype.interfaces.base, to be clear

...

    in_file = InputMultiObject(File(exists=True), ...)
```
Yes, that's what I thought of trying, but wanted to check first in case I missed something.

Thanks!

Resolving patch:
diff --git a/nipype/interfaces/afni/utils.py b/nipype/interfaces/afni/utils.py
--- a/nipype/interfaces/afni/utils.py
+++ b/nipype/interfaces/afni/utils.py
@@ -1636,12 +1636,12 @@ def _format_arg(self, name, spec, value):
 
 
 class MaskToolInputSpec(AFNICommandInputSpec):
-    in_file = File(
+    in_file = InputMultiPath(
+        File(exists=True),
         desc='input file or files to 3dmask_tool',
         argstr='-input %s',
         position=-1,
         mandatory=True,
-        exists=True,
         copyfile=False)
     out_file = File(
         name_template='%s_mask',


Test patch:
Repository: nipy/nipype

Issue:
Latest nibabel release breaks test
### Summary
https://github.com/nipy/nipype/blob/fcbe28e58ecabedbcc2dcaf09bf9a7329ae43fcf/nipype/interfaces/tests/test_image.py#L17

blows up with nibabel 2.4.0
### Actual behavior
`AssertionError`
### Expected behavior
Pass
### How to replicate the behavior
View any recent CI build (e.g. https://travis-ci.org/nipy/nipype/jobs/514714882)

Relevant PR -  nipy/nibabel#741



Discussion:

Resolving patch:
diff --git a/nipype/interfaces/image.py b/nipype/interfaces/image.py
--- a/nipype/interfaces/image.py
+++ b/nipype/interfaces/image.py
@@ -5,6 +5,7 @@
 from ..utils.filemanip import fname_presuffix
 from .base import (SimpleInterface, TraitedSpec, BaseInterfaceInputSpec,
                    traits, File)
+from .. import LooseVersion
 
 
 class RescaleInputSpec(BaseInterfaceInputSpec):
@@ -186,8 +187,8 @@ def _run_interface(self, runtime):
         transform = ornt_transform(orig_ornt, targ_ornt)
         affine_xfm = inv_ornt_aff(transform, orig_img.shape)
 
-        # Check can be eliminated when minimum nibabel version >= 2.2
-        if hasattr(orig_img, 'as_reoriented'):
+        # Check can be eliminated when minimum nibabel version >= 2.4
+        if LooseVersion(nb.__version__) >= LooseVersion('2.4.0'):
             reoriented = orig_img.as_reoriented(transform)
         else:
             reoriented = _as_reoriented_backport(orig_img, transform)
@@ -212,7 +213,7 @@ def _run_interface(self, runtime):
 
 
 def _as_reoriented_backport(img, ornt):
-    """Backport of img.as_reoriented as of nibabel 2.2.0"""
+    """Backport of img.as_reoriented as of nibabel 2.4.0"""
     import numpy as np
     import nibabel as nb
     from nibabel.orientations import inv_ornt_aff
@@ -225,13 +226,8 @@ def _as_reoriented_backport(img, ornt):
 
     if isinstance(reoriented, nb.Nifti1Pair):
         # Also apply the transform to the dim_info fields
-        new_dim = list(reoriented.header.get_dim_info())
-        for idx, value in enumerate(new_dim):
-            # For each value, leave as None if it was that way,
-            # otherwise check where we have mapped it to
-            if value is None:
-                continue
-            new_dim[idx] = np.where(ornt[:, 0] == idx)[0]
+        new_dim = [None if orig_dim is None else int(ornt[orig_dim, 0])
+                   for orig_dim in img.header.get_dim_info()]
 
         reoriented.header.set_dim_info(*new_dim)
 


Test patch:
diff --git a/nipype/interfaces/tests/test_image.py b/nipype/interfaces/tests/test_image.py
--- a/nipype/interfaces/tests/test_image.py
+++ b/nipype/interfaces/tests/test_image.py
@@ -9,10 +9,10 @@
 from ..image import _as_reoriented_backport, _orientations
 from ... import LooseVersion
 
-nibabel22 = LooseVersion(nb.__version__) >= LooseVersion('2.2.0')
+nibabel24 = LooseVersion(nb.__version__) >= LooseVersion('2.4.0')
 
 
-@pytest.mark.skipif(not nibabel22,
+@pytest.mark.skipif(not nibabel24,
                     reason="Old nibabel - can't directly compare")
 def test_reorientation_backport():
     pixdims = ((1, 1, 1), (2, 2, 3))
Repository: nipy/nipype

Issue:
mne.WatershedBEM creates incorrect command line
### Summary
The mne.WatershedBEM interface `_cmd` do not correspond to the behavior of the stable release of  mne [see documentation](https://martinos.org/mne/stable/generated/commands.html#create-bem-surfaces-using-the-watershed-algorithm-included-with-freesurfer)
 [This line](https://github.com/nipy/nipype/blob/f79581edc042ed38064f48e85b6dcc38bc30a084/nipype/interfaces/mne/base.py#L97) `_cmd = 'mne_watershed_bem'` should be `_cmd = 'mne watershed_bem'`
mne.WatershedBEM creates incorrect command line
### Summary
The mne.WatershedBEM interface `_cmd` do not correspond to the behavior of the stable release of  mne [see documentation](https://martinos.org/mne/stable/generated/commands.html#create-bem-surfaces-using-the-watershed-algorithm-included-with-freesurfer)
 [This line](https://github.com/nipy/nipype/blob/f79581edc042ed38064f48e85b6dcc38bc30a084/nipype/interfaces/mne/base.py#L97) `_cmd = 'mne_watershed_bem'` should be `_cmd = 'mne watershed_bem'`


Discussion:

Resolving patch:
diff --git a/nipype/interfaces/mne/base.py b/nipype/interfaces/mne/base.py
--- a/nipype/interfaces/mne/base.py
+++ b/nipype/interfaces/mne/base.py
@@ -89,12 +89,12 @@ class WatershedBEM(FSCommand):
     >>> bem.inputs.subject_id = 'subj1'
     >>> bem.inputs.subjects_dir = '.'
     >>> bem.cmdline
-    'mne_watershed_bem --overwrite --subject subj1 --volume T1'
+    'mne watershed_bem --overwrite --subject subj1 --volume T1'
     >>> bem.run() 				# doctest: +SKIP
 
    """
 
-    _cmd = 'mne_watershed_bem'
+    _cmd = 'mne watershed_bem'
     input_spec = WatershedBEMInputSpec
     output_spec = WatershedBEMOutputSpec
     _additional_metadata = ['loc', 'altkey']


Test patch:
Repository: nipy/nipype

Issue:
Replace gcd with math.gcd (Python 3.5+)




Discussion:

Resolving patch:
diff --git a/nipype/algorithms/modelgen.py b/nipype/algorithms/modelgen.py
--- a/nipype/algorithms/modelgen.py
+++ b/nipype/algorithms/modelgen.py
@@ -30,25 +30,6 @@
 iflogger = logging.getLogger("nipype.interface")
 
 
-def gcd(a, b):
-    """
-    Return the greatest common divisor of two integers (uses Euclid's algorithm).
-
-    Examples
-    --------
-    >>> gcd(4, 5)
-    1
-    >>> gcd(4, 8)
-    4
-    >>> gcd(22, 55)
-    11
-
-    """
-    while b > 0:
-        a, b = b, a % b
-    return a
-
-
 def spm_hrf(RT, P=None, fMRI_T=16):
     """
     python implementation of spm_hrf
@@ -799,9 +780,9 @@ def _gen_regress(self, i_onsets, i_durations, i_amplitudes, nscans):
             matplotlib.use(config.get("execution", "matplotlib_backend"))
             import matplotlib.pyplot as plt
 
-        TR = np.round(self.inputs.time_repetition * 1000)  # in ms
+        TR = int(np.round(self.inputs.time_repetition * 1000))  # in ms
         if self.inputs.time_acquisition:
-            TA = np.round(self.inputs.time_acquisition * 1000)  # in ms
+            TA = int(np.round(self.inputs.time_acquisition * 1000))  # in ms
         else:
             TA = TR  # in ms
         nvol = self.inputs.volumes_in_cluster
@@ -813,10 +794,10 @@ def _gen_regress(self, i_onsets, i_durations, i_amplitudes, nscans):
         if len(durations) == 1:
             durations = durations * np.ones((len(i_onsets)))
         onsets = np.round(np.array(i_onsets) * 1000)
-        dttemp = gcd(TA, gcd(SILENCE, TR))
+        dttemp = math.gcd(TA, math.gcd(SILENCE, TR))
         if dt < dttemp:
             if dttemp % dt != 0:
-                dt = float(gcd(dttemp, dt))
+                dt = float(math.gcd(dttemp, int(dt)))
 
         if dt < 1:
             raise Exception("Time multiple less than 1 ms")


Test patch:
Repository: nipy/nipype

Issue:
fsl randomise f_only flag contains typo, can't work
### Summary
when calling randomise with f_only=True, nipypes interfaces appends --f_only instead of --fonly. This is incorrect and prevents the call from working.

The offending line is [here](https://github.com/nipy/nipype/blob/master/nipype/interfaces/fsl/model.py#L2250), where the last bit should be `argstr="--fonly"`
### Actual behavior
appending --fonly to the randomise call.

### Expected behavior

--f_only is appended, breaking the call.

### Script/Workflow details

```
    fsl_randomise = mem.cache(fsl.Randomise)
    randomise_results = fsl_randomise(
        in_file=`fourdimage.nii`,
        mask=`mask.nii`,
        num_perm=10000,
        f_only=True,
        **kwargs
        )
```

### Platform details:

```
{'commit_hash': 'c5ce0e2c9',
 'commit_source': 'installation',
 'networkx_version': '2.5',
 'nibabel_version': '3.2.1',
 'nipype_version': '1.4.2',
 'numpy_version': '1.20.1',
 'pkg_path': '/usr/local/miniconda/lib/python3.7/site-packages/nipype',
 'scipy_version': '1.6.1',
 'sys_executable': '/usr/local/miniconda/bin/python',
 'sys_platform': 'linux',
 'sys_version': '3.7.4 (default, Aug 13 2019, 20:35:49) \n[GCC 7.3.0]',
 'traits_version': '6.2.0'}
```


Discussion:
What version of FSL? Are we sure that or didn't change from one to the other?

Would you be up for submitting a PR?
FSL Version 6.0. I just scrolled through the FSL history [here](https://fsl.fmrib.ox.ac.uk/fsl/fslwiki/WhatsNew#anchor1) and didn't see any references to changing the command-line interface, but I may not be digging deep enough. 

I can submit a PR later in the week if no objections arise in the meantime!

Resolving patch:
diff --git a/nipype/interfaces/fsl/model.py b/nipype/interfaces/fsl/model.py
--- a/nipype/interfaces/fsl/model.py
+++ b/nipype/interfaces/fsl/model.py
@@ -2245,7 +2245,7 @@ class RandomiseInputSpec(FSLCommandInputSpec):
         desc=("carry out Threshold-Free Cluster Enhancement with 2D " "optimisation"),
         argstr="--T2",
     )
-    f_only = traits.Bool(desc="calculate f-statistics only", argstr="--f_only")
+    f_only = traits.Bool(desc="calculate f-statistics only", argstr="--fonly")
     raw_stats_imgs = traits.Bool(
         desc="output raw ( unpermuted ) statistic images", argstr="-R"
     )


Test patch:
diff --git a/nipype/interfaces/fsl/tests/test_auto_Randomise.py b/nipype/interfaces/fsl/tests/test_auto_Randomise.py
--- a/nipype/interfaces/fsl/tests/test_auto_Randomise.py
+++ b/nipype/interfaces/fsl/tests/test_auto_Randomise.py
@@ -37,7 +37,7 @@ def test_Randomise_inputs():
             argstr="-S %.2f",
         ),
         f_only=dict(
-            argstr="--f_only",
+            argstr="--fonly",
         ),
         fcon=dict(
             argstr="-f %s",
Repository: nipy/nipype

Issue:
MathsCommand().inputs.out_file has to exist
When setting `MathsCommand().inputs.out_file` argument, a Trait error is thrown because of the `exists=True`:

https://github.com/nipy/nipype/blob/6a7837c0994367a5f34bb576bb0a97ec70669b8f/nipype/interfaces/fsl/maths.py#L44

I think this doesn't make any sense, because `out_file` is to be created by `MathsCommand()`.
In my case, I just want to get rid of SPM nan's in an .nii file, but I also don't want fsl_maths to append a suffix to the filename - this is why I also provide `out_file` to `MathsCommand().inputs`.
A short example:
```
nan2zero = pe.MapNode(interface=MathsCommand(), name='nan2zero', iterfield=['in_file', 'out_file'])
nan2zero.inputs.nan2zeros = True

```


Discussion:
I agree. Would you like to make a PR to remove that?

Resolving patch:
diff --git a/nipype/interfaces/fsl/maths.py b/nipype/interfaces/fsl/maths.py
--- a/nipype/interfaces/fsl/maths.py
+++ b/nipype/interfaces/fsl/maths.py
@@ -41,7 +41,7 @@ class MathsInput(FSLCommandInputSpec):
 
 class MathsOutput(TraitedSpec):
 
-    out_file = File(exists=True, desc="image written after calculations")
+    out_file = File(desc="image written after calculations")
 
 
 class MathsCommand(FSLCommand):


Test patch:
Repository: nipy/nipype

Issue:
[ENH] Add `GenericLabel` to antsRegistration interface as MultiLabel is outdated. 
From `antsRegistration` manual page:

```
 -n, --interpolation Linear
                         NearestNeighbor
                         MultiLabel[<sigma=imageSpacing>,<alpha=4.0>]
                         Gaussian[<sigma=imageSpacing>,<alpha=1.0>]
                         BSpline[<order=3>]
                         CosineWindowedSinc
                         WelchWindowedSinc
                         HammingWindowedSinc
                         LanczosWindowedSinc
                         GenericLabel[<interpolator=Linear>]
```

The `GenericLabel` option is currently missing from the input spec:
https://github.com/nipy/nipype/blob/5ac2f18ac116832d81a13f0c83e0a6aeda1457cf/nipype/interfaces/ants/registration.py#L411-L423

Additionally, `MultiLabel` is no longer recommended and `GenericLabel` is the preferred option.

Will make a PR. 




Discussion:

Resolving patch:
diff --git a/nipype/interfaces/ants/registration.py b/nipype/interfaces/ants/registration.py
--- a/nipype/interfaces/ants/registration.py
+++ b/nipype/interfaces/ants/registration.py
@@ -418,6 +418,7 @@ class RegistrationInputSpec(ANTSCommandInputSpec):
         "BSpline",
         "MultiLabel",
         "Gaussian",
+        "GenericLabel",
         argstr="%s",
         usedefault=True,
     )
@@ -426,6 +427,7 @@ class RegistrationInputSpec(ANTSCommandInputSpec):
         traits.Tuple(
             traits.Float(), traits.Float()  # Gaussian/MultiLabel (sigma, alpha)
         ),
+        traits.Tuple(traits.Str()),  # GenericLabel (interpolator)
     )
 
     write_composite_transform = traits.Bool(
@@ -1297,6 +1299,7 @@ def _format_arg(self, opt, spec, val):
                     "BSpline",
                     "MultiLabel",
                     "Gaussian",
+                    "GenericLabel",
                 ]
                 and isdefined(self.inputs.interpolation_parameters)
             ):


Test patch:
Repository: nipy/nipype

Issue:
[ENH] DWIBiascorrect missing outputs' generation
### Summary
It's a quick fix, but the interface to mrtrix3's dwibiascorrect is missing the method to generate the output dictionary.


Discussion:

Resolving patch:
diff --git a/nipype/interfaces/mrtrix3/preprocess.py b/nipype/interfaces/mrtrix3/preprocess.py
--- a/nipype/interfaces/mrtrix3/preprocess.py
+++ b/nipype/interfaces/mrtrix3/preprocess.py
@@ -242,6 +242,13 @@ def _format_arg(self, name, trait_spec, value):
                 return f"-{trait_spec.argstr}"
         return super()._format_arg(name, trait_spec, value)
 
+    def _list_outputs(self):
+        outputs = self.output_spec().get()
+        outputs["out_file"] = op.abspath(self.inputs.out_file)
+        if self.inputs.bias:
+            outputs["bias"] = op.abspath(self.inputs.bias)
+        return outputs
+
 
 class DWIPreprocInputSpec(MRTrix3BaseInputSpec):
     in_file = File(


Test patch:
Repository: nipy/nipype

Issue:
Prevent excessive etelemetry pings
When etelemetry is down, nipype can spend excessive time re-trying instead of recording a failure mode.

On the one hand, this is a problem with the client. On the other, we should probably code defensively against bugs in the etelemetry client.


Discussion:
https://github.com/nipy/nipype/blob/71c7a7d5315714bad8c423a587ba15760dc00b77/nipype/interfaces/base/core.py#L188-L189

I think the easiest thing to do would be to add a check if `None` is returned, and if so set `BaseInterface._etelemetry_version_data` to `n/a` or something equivalent

Resolving patch:
diff --git a/nipype/__init__.py b/nipype/__init__.py
--- a/nipype/__init__.py
+++ b/nipype/__init__.py
@@ -98,4 +98,4 @@ def check_latest_version(raise_exception=False):
         from .interfaces.base import BaseInterface
 
         if BaseInterface._etelemetry_version_data is None:
-            BaseInterface._etelemetry_version_data = check_latest_version()
+            BaseInterface._etelemetry_version_data = check_latest_version() or "n/a"
diff --git a/nipype/interfaces/base/core.py b/nipype/interfaces/base/core.py
--- a/nipype/interfaces/base/core.py
+++ b/nipype/interfaces/base/core.py
@@ -186,7 +186,7 @@ def __init__(
             from ... import check_latest_version
 
             if BaseInterface._etelemetry_version_data is None:
-                BaseInterface._etelemetry_version_data = check_latest_version()
+                BaseInterface._etelemetry_version_data = check_latest_version() or "n/a"
 
         if not self.input_spec:
             raise Exception("No input_spec in class: %s" % self.__class__.__name__)


Test patch:
Repository: nipy/nipype

Issue:
Unnecessary print used in the FEAT class 
There is an unnecessary print statement used in the ```_list_outputs``` method in the ```FEAT``` class.
This is especially annoying when running a lot of FEAT analysises since it litters the terminal and messes with other user-defined prints and or with progress bars such as ```tqdm```.

https://github.com/nipy/nipype/blob/72aac961cc53eeaa134d50811ff9ae59c8ea9acb/nipype/interfaces/fsl/model.py#L487

As a temporary workaround, you can suppress the print statement like below. 

```python
import contextlib
with contextlib.redirect_stdout(None):
        feat = fsl.FEAT()
        feat.inputs.fsf_file = fsf_file
        feat.terminal_output = "none"
        feat_output = feat.run()
```


Discussion:
Looks like a debug statement added in https://github.com/nipy/nipype/pull/635. Please feel free to open a PR to remove it.

Resolving patch:
diff --git a/nipype/interfaces/fsl/model.py b/nipype/interfaces/fsl/model.py
--- a/nipype/interfaces/fsl/model.py
+++ b/nipype/interfaces/fsl/model.py
@@ -484,7 +484,6 @@ def _list_outputs(self):
                 outputs["feat_dir"] = glob(os.path.join(os.getcwd(), "*ica"))[0]
             else:
                 outputs["feat_dir"] = glob(os.path.join(os.getcwd(), "*feat"))[0]
-        print("Outputs from FEATmodel:", outputs)
         return outputs
 
 


Test patch:
Repository: nipy/nipype

Issue:
optmization_schema error in GTMPVC - petsurfer interface
### Summary
Input and output relation for optimization_schema (input) does not match 'opt' in output in the GTMPVC class in the petsurfer interface. 

### Actual behavior

Traceback:
	    if self.inputs.opt:
	AttributeError: 'GTMPVCInputSpec' object has no attribute 'opt'

### Expected behavior

### How to replicate the behavior

### Script/Workflow details

Please put URL to code or code here (if not too long).

### Platform details:

<!-- Please run the following code from your shell and place the output between the triple ticks, below.
python -c "import nipype; from pprint import pprint; pprint(nipype.get_info())"
-->

```
{'commit_hash': '<not found>',
 'commit_source': '(none found)',
 'networkx_version': '3.1',
 'nibabel_version': '5.1.0',
 'nipype_version': '1.8.6',
 'numpy_version': '1.24.2',
 'pkg_path': '/Users/martinnorgaard/anaconda3/envs/petprep_extract_tacs/lib/python3.9/site-packages/nipype',
 'scipy_version': '1.10.1',
 'sys_executable': '/Users/martinnorgaard/anaconda3/envs/petprep_extract_tacs/bin/python',
 'sys_platform': 'darwin',
 'sys_version': '3.9.16 | packaged by conda-forge | (main, Feb  1 2023, '
                '21:38:11) \n'
                '[Clang 14.0.6 ]',
 'traits_version': '6.3.2'}
```

### Execution environment

Choose one
- Container [Tag: ???]
- My python environment inside container [Base Tag: ???]
- My python environment outside container



Discussion:

Resolving patch:
diff --git a/nipype/interfaces/freesurfer/petsurfer.py b/nipype/interfaces/freesurfer/petsurfer.py
--- a/nipype/interfaces/freesurfer/petsurfer.py
+++ b/nipype/interfaces/freesurfer/petsurfer.py
@@ -557,7 +557,7 @@ def _list_outputs(self):
             outputs["rbv"] = os.path.join(pvcdir, "rbv.nii.gz")
             outputs["reg_rbvpet2anat"] = os.path.join(pvcdir, "aux", "rbv2anat.lta")
             outputs["reg_anat2rbvpet"] = os.path.join(pvcdir, "aux", "anat2rbv.lta")
-        if self.inputs.opt:
+        if self.inputs.optimization_schema:
             outputs["opt_params"] = os.path.join(pvcdir, "aux", "opt.params.dat")
 
         return outputs


Test patch:
Repository: nipy/nipype

Issue:
`locale.getdefaultlocale()` is deprecated
nipype uses the [`locale.getdefaultlocale()`](https://docs.python.org/3/library/locale.html#locale.getdefaultlocale) function [here](https://github.com/nipy/nipype/blob/eb779e6113074c2071830001eacdefca26518ce3/nipype/utils/subprocess.py#L34) and [here](https://github.com/nipy/nipype/blob/b3b3bf3c2aefa57e7f7d77868136d9cea090eb11/nipype/utils/filemanip.py#L696).  However, this function was deprecated in Python 3.11 and will be removed in Python 3.13.  It should be replaced with either [`locale.getpreferredencoding()`](https://docs.python.org/3/library/locale.html#locale.getpreferredencoding) or [`locale.getencoding()`](https://docs.python.org/3/library/locale.html#locale.getencoding).


Discussion:
I guesss `getpreferredencoding` is the better option for now, as we `getencoding()` is 3.11+. Unless there's an argument for using `getencoding` and having a fallback?

Resolving patch:
diff --git a/nipype/utils/filemanip.py b/nipype/utils/filemanip.py
--- a/nipype/utils/filemanip.py
+++ b/nipype/utils/filemanip.py
@@ -670,7 +670,7 @@ def read_stream(stream, logger=None, encoding=None):
 
 
     """
-    default_encoding = encoding or locale.getdefaultlocale()[1] or "UTF-8"
+    default_encoding = encoding or locale.getpreferredencoding(do_setlocale=False)
     logger = logger or fmlogger
     try:
         out = stream.decode(default_encoding)
diff --git a/nipype/utils/subprocess.py b/nipype/utils/subprocess.py
--- a/nipype/utils/subprocess.py
+++ b/nipype/utils/subprocess.py
@@ -30,7 +30,7 @@ def __init__(self, name, impl):
         self._buf = ""
         self._rows = []
         self._lastidx = 0
-        self.default_encoding = locale.getdefaultlocale()[1] or "UTF-8"
+        self.default_encoding = locale.getpreferredencoding(do_setlocale=False)
 
     def fileno(self):
         "Pass-through for file descriptor."


Test patch: