From 0931fda459f5feb4dad74a31f5d622c8a4cc20d4 Mon Sep 17 00:00:00 2001 From: manuegrx <47973414+manuegrx@users.noreply.github.com> Date: Tue, 10 Oct 2023 09:57:34 +0200 Subject: [PATCH 01/26] [fix] MRTrix3 change inputs position for MRTransform --- nipype/interfaces/mrtrix3/utils.py | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/nipype/interfaces/mrtrix3/utils.py b/nipype/interfaces/mrtrix3/utils.py index 2ec7eba909..6909f380be 100644 --- a/nipype/interfaces/mrtrix3/utils.py +++ b/nipype/interfaces/mrtrix3/utils.py @@ -822,13 +822,11 @@ class MRTransformInputSpec(MRTrix3BaseInputSpec): ) invert = traits.Bool( argstr="-inverse", - position=1, desc="Invert the specified transform before using it", ) linear_transform = File( exists=True, argstr="-linear %s", - position=1, desc=( "Specify a linear transform to apply, in the form of a 3x4 or 4x4 ascii file. " "Note the standard reverse convention is used, " @@ -838,38 +836,32 @@ class MRTransformInputSpec(MRTrix3BaseInputSpec): ) replace_transform = traits.Bool( argstr="-replace", - position=1, desc="replace the current transform by that specified, rather than applying it to the current transform", ) transformation_file = File( exists=True, argstr="-transform %s", - position=1, desc="The transform to apply, in the form of a 4x4 ascii file.", ) template_image = File( exists=True, argstr="-template %s", - position=1, desc="Reslice the input image to match the specified template image.", ) reference_image = File( exists=True, argstr="-reference %s", - position=1, desc="in case the transform supplied maps from the input image onto a reference image, use this option to specify the reference. Note that this implicitly sets the -replace option.", ) flip_x = traits.Bool( argstr="-flipx", - position=1, desc="assume the transform is supplied assuming a coordinate system with the x-axis reversed relative to the MRtrix convention (i.e. x increases from right to left). This is required to handle transform matrices produced by FSL's FLIRT command. This is only used in conjunction with the -reference option.", ) quiet = traits.Bool( argstr="-quiet", - position=1, desc="Do not display information messages or progress status.", ) - debug = traits.Bool(argstr="-debug", position=1, desc="Display debugging messages.") + debug = traits.Bool(argstr="-debug", desc="Display debugging messages.") class MRTransformOutputSpec(TraitedSpec): From 0d0d3ff1283d45cdf9d84e6de10a400078021537 Mon Sep 17 00:00:00 2001 From: manuegrx <47973414+manuegrx@users.noreply.github.com> Date: Tue, 10 Oct 2023 10:21:20 +0200 Subject: [PATCH 02/26] add test create by check-before-commit --- nipype/interfaces/mrtrix3/tests/test_auto_MRTransform.py | 9 --------- 1 file changed, 9 deletions(-) diff --git a/nipype/interfaces/mrtrix3/tests/test_auto_MRTransform.py b/nipype/interfaces/mrtrix3/tests/test_auto_MRTransform.py index b50ee2c67f..e0337da2a9 100644 --- a/nipype/interfaces/mrtrix3/tests/test_auto_MRTransform.py +++ b/nipype/interfaces/mrtrix3/tests/test_auto_MRTransform.py @@ -12,7 +12,6 @@ def test_MRTransform_inputs(): ), debug=dict( argstr="-debug", - position=1, ), environ=dict( nohash=True, @@ -20,7 +19,6 @@ def test_MRTransform_inputs(): ), flip_x=dict( argstr="-flipx", - position=1, ), grad_file=dict( argstr="-grad %s", @@ -45,12 +43,10 @@ def test_MRTransform_inputs(): ), invert=dict( argstr="-inverse", - position=1, ), linear_transform=dict( argstr="-linear %s", extensions=None, - position=1, ), nthreads=dict( argstr="-nthreads %d", @@ -71,26 +67,21 @@ def test_MRTransform_inputs(): ), quiet=dict( argstr="-quiet", - position=1, ), reference_image=dict( argstr="-reference %s", extensions=None, - position=1, ), replace_transform=dict( argstr="-replace", - position=1, ), template_image=dict( argstr="-template %s", extensions=None, - position=1, ), transformation_file=dict( argstr="-transform %s", extensions=None, - position=1, ), ) inputs = MRTransform.input_spec() From b066807402ee07d908ce4f1b24ca69fef6b91809 Mon Sep 17 00:00:00 2001 From: Hans Johnson Date: Wed, 26 Oct 2022 17:58:51 -0500 Subject: [PATCH 03/26] BUG: Reading serialized event requires conversion of dates This patch attempts to convert string date representations back to datetime.date objects so that compuations can be done on them. --- nipype/utils/draw_gantt_chart.py | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/nipype/utils/draw_gantt_chart.py b/nipype/utils/draw_gantt_chart.py index debce75970..6190e12fdf 100644 --- a/nipype/utils/draw_gantt_chart.py +++ b/nipype/utils/draw_gantt_chart.py @@ -103,8 +103,26 @@ def log_to_dict(logfile): nodes_list = [json.loads(l) for l in lines] + def _convert_string_to_datetime(datestring): + try: + datetime_object: datetime.datetime = datetime.datetime.strptime( + datestring, "%Y-%m-%dT%H:%M:%S.%f" + ) + return datetime_object + except Exception as _: + pass + return datestring + + date_object_node_list: list = list() + for n in nodes_list: + if "start" in n.keys(): + n["start"] = _convert_string_to_datetime(n["start"]) + if "finish" in n.keys(): + n["finish"] = _convert_string_to_datetime(n["finish"]) + date_object_node_list.append(n) + # Return list of nodes - return nodes_list + return date_object_node_list def calculate_resource_timeseries(events, resource): @@ -514,7 +532,11 @@ def generate_gantt_chart( # Create the header of the report with useful information start_node = nodes_list[0] last_node = nodes_list[-1] - duration = (last_node["finish"] - start_node["start"]).total_seconds() + duration: float = 0.0 + if isinstance(start_node["start"], datetime.date) and isinstance( + last_node["finish"], datetime.date + ): + duration = (last_node["finish"] - start_node["start"]).total_seconds() # Get events based dictionary of node run stats events = create_event_dict(start_node["start"], nodes_list) From 50be1a4acd53ee56bbeef93d038b497a62db334a Mon Sep 17 00:00:00 2001 From: Taylor Salo Date: Tue, 5 Dec 2023 10:37:57 -0500 Subject: [PATCH 04/26] Add GenericLabel to ANTS ApplyTransforms. --- nipype/interfaces/ants/resampling.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/nipype/interfaces/ants/resampling.py b/nipype/interfaces/ants/resampling.py index 82a9e7a214..1b3e172756 100644 --- a/nipype/interfaces/ants/resampling.py +++ b/nipype/interfaces/ants/resampling.py @@ -349,6 +349,7 @@ class ApplyTransformsInputSpec(ANTSCommandInputSpec): "MultiLabel", "Gaussian", "BSpline", + "GenericLabel", argstr="%s", usedefault=True, ) @@ -497,6 +498,7 @@ def _format_arg(self, opt, spec, val): "BSpline", "MultiLabel", "Gaussian", + "GenericLabel", ] and isdefined(self.inputs.interpolation_parameters): return "--interpolation {}[ {} ]".format( self.inputs.interpolation, From 0114009b7b946844515997bffef2ab5fad965b35 Mon Sep 17 00:00:00 2001 From: Taylor Salo Date: Tue, 5 Dec 2023 15:51:49 -0500 Subject: [PATCH 05/26] Address @effigies' review. --- nipype/interfaces/ants/resampling.py | 1 + 1 file changed, 1 insertion(+) diff --git a/nipype/interfaces/ants/resampling.py b/nipype/interfaces/ants/resampling.py index 1b3e172756..3a6ba2c724 100644 --- a/nipype/interfaces/ants/resampling.py +++ b/nipype/interfaces/ants/resampling.py @@ -358,6 +358,7 @@ class ApplyTransformsInputSpec(ANTSCommandInputSpec): traits.Tuple( traits.Float(), traits.Float() # Gaussian/MultiLabel (sigma, alpha) ), + traits.Tuple(traits.Str()), # GenericLabel ) transforms = InputMultiObject( traits.Either(File(exists=True), "identity"), From 71e8795d6f81d21baac754e10bb42b50d044c465 Mon Sep 17 00:00:00 2001 From: Horea Christian Date: Mon, 22 Jan 2024 10:52:12 -0500 Subject: [PATCH 06/26] Adjusted variable names for clarity and codespell false positives --- nipype/pipeline/engine/utils.py | 40 ++++++++++++++++----------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/nipype/pipeline/engine/utils.py b/nipype/pipeline/engine/utils.py index 36122561e4..d947735cb0 100644 --- a/nipype/pipeline/engine/utils.py +++ b/nipype/pipeline/engine/utils.py @@ -510,15 +510,15 @@ def _write_detailed_dot(graph, dotfilename): edges = [] for n in nx.topological_sort(graph): nodename = n.itername - inports = [] + in_ports = [] for u, v, d in graph.in_edges(nbunch=n, data=True): for cd in d["connect"]: if isinstance(cd[0], (str, bytes)): outport = cd[0] else: outport = cd[0][0] - inport = cd[1] - ipstrip = "in%s" % _replacefunk(inport) + in_port = cd[1] + ipstrip = "in%s" % _replacefunk(in_port) opstrip = "out%s" % _replacefunk(outport) edges.append( "%s:%s:e -> %s:%s:w;" @@ -529,11 +529,11 @@ def _write_detailed_dot(graph, dotfilename): ipstrip, ) ) - if inport not in inports: - inports.append(inport) + if in_port not in in_ports: + in_ports.append(in_port) inputstr = ( ["{IN"] - + [f"| {ip}" for ip in sorted(inports)] + + [f"| {ip}" for ip in sorted(in_ports)] + ["}"] ) outports = [] @@ -886,34 +886,34 @@ def _node_ports(graph, node): for _, v, d in graph.out_edges(node, data=True): for src, dest in d["connect"]: if isinstance(src, tuple): - srcport = src[0] + src_port = src[0] else: - srcport = src - if srcport not in portoutputs: - portoutputs[srcport] = [] - portoutputs[srcport].append((v, dest, src)) + src_port = src + if src_port not in portoutputs: + portoutputs[src_port] = [] + portoutputs[src_port].append((v, dest, src)) return (portinputs, portoutputs) def _propagate_root_output(graph, node, field, connections): """Propagates the given graph root node output port field connections to the out-edge destination nodes.""" - for destnode, inport, src in connections: + for destnode, in_port, src in connections: value = getattr(node.inputs, field) if isinstance(src, tuple): value = evaluate_connect_function(src[1], src[2], value) - destnode.set_input(inport, value) + destnode.set_input(in_port, value) def _propagate_internal_output(graph, node, field, connections, portinputs): """Propagates the given graph internal node output port field connections to the out-edge source node and in-edge destination nodes.""" - for destnode, inport, src in connections: + for destnode, in_port, src in connections: if field in portinputs: - srcnode, srcport = portinputs[field] - if isinstance(srcport, tuple) and isinstance(src, tuple): - src_func = srcport[1].split("\\n")[0] + srcnode, src_port = portinputs[field] + if isinstance(src_port, tuple) and isinstance(src, tuple): + src_func = src_port[1].split("\\n")[0] dst_func = src[1].split("\\n")[0] raise ValueError( "Does not support two inline functions " @@ -924,9 +924,9 @@ def _propagate_internal_output(graph, node, field, connections, portinputs): connect = graph.get_edge_data(srcnode, destnode, default={"connect": []}) if isinstance(src, tuple): - connect["connect"].append(((srcport, src[1], src[2]), inport)) + connect["connect"].append(((src_port, src[1], src[2]), in_port)) else: - connect = {"connect": [(srcport, inport)]} + connect = {"connect": [(src_port, in_port)]} old_connect = graph.get_edge_data( srcnode, destnode, default={"connect": []} ) @@ -936,7 +936,7 @@ def _propagate_internal_output(graph, node, field, connections, portinputs): value = getattr(node.inputs, field) if isinstance(src, tuple): value = evaluate_connect_function(src[1], src[2], value) - destnode.set_input(inport, value) + destnode.set_input(in_port, value) def generate_expanded_graph(graph_in): From 1ab6baedd14b3b7e451c155d4c8774192d3a710a Mon Sep 17 00:00:00 2001 From: Steffen Bollmann Date: Mon, 12 Feb 2024 09:50:55 +1000 Subject: [PATCH 07/26] Fix wrong name, should be al_ea --- nipype/interfaces/afni/preprocess.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nipype/interfaces/afni/preprocess.py b/nipype/interfaces/afni/preprocess.py index a60a9f4617..d4836cbd0c 100644 --- a/nipype/interfaces/afni/preprocess.py +++ b/nipype/interfaces/afni/preprocess.py @@ -180,7 +180,7 @@ class AlignEpiAnatPy(AFNIPythonCommand): >>> al_ea.cmdline # doctest: +ELLIPSIS 'python2 ...align_epi_anat.py -anat structural.nii -epi_base 0 -epi_strip 3dAutomask -epi \ functional.nii -save_skullstrip -suffix _al -tshift off -volreg off' - >>> res = allineate.run() # doctest: +SKIP + >>> res = al_ea.run() # doctest: +SKIP See Also -------- From 3afcd62bd9bfa3ee0b85c4db1c4eb0eacea577a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Toomas=20Erik=20Anij=C3=A4rv?= Date: Tue, 20 Feb 2024 09:43:14 +0100 Subject: [PATCH 08/26] Update utils.py - Added 'hsvs' option for 5ttgen function --- nipype/interfaces/mrtrix3/utils.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/nipype/interfaces/mrtrix3/utils.py b/nipype/interfaces/mrtrix3/utils.py index 2ec7eba909..93196cc4e5 100644 --- a/nipype/interfaces/mrtrix3/utils.py +++ b/nipype/interfaces/mrtrix3/utils.py @@ -224,13 +224,14 @@ class Generate5ttInputSpec(MRTrix3BaseInputSpec): "fsl", "gif", "freesurfer", + "hsvs", argstr="%s", position=-3, mandatory=True, desc="tissue segmentation algorithm", ) in_file = File( - exists=True, argstr="%s", mandatory=True, position=-2, desc="input image" + exists=False, argstr="%s", mandatory=True, position=-2, desc="input image" ) out_file = File(argstr="%s", mandatory=True, position=-1, desc="output image") From 367776d6f27c06d4a80df1ba9b309529fb8fcdb8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Toomas=20Erik=20Anij=C3=A4rv?= Date: Tue, 20 Feb 2024 09:47:05 +0100 Subject: [PATCH 09/26] Update .zenodo.json --- .zenodo.json | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.zenodo.json b/.zenodo.json index 4b8ae1f2a6..6e884e7594 100644 --- a/.zenodo.json +++ b/.zenodo.json @@ -911,6 +911,11 @@ "name": "Wu, Jianxiao", "orcid": "0000-0002-4866-272X", }, + { + "affiliation": "Lund University", + "name": "Anijärv, Toomas Erik", + "orcid": "0000-0002-3650-4230", + }, ], "keywords": [ "neuroimaging", From c08e17b992c1fa069963f7b7910a7d66aea746ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Toomas=20Erik=20Anij=C3=A4rv?= Date: Tue, 20 Feb 2024 13:51:11 +0100 Subject: [PATCH 10/26] Update utils.py - Changed '-inverse' parameter location from 1 to 2 (otherwise cannot use together with -linear) --- nipype/interfaces/mrtrix3/utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nipype/interfaces/mrtrix3/utils.py b/nipype/interfaces/mrtrix3/utils.py index 93196cc4e5..d0b474a76b 100644 --- a/nipype/interfaces/mrtrix3/utils.py +++ b/nipype/interfaces/mrtrix3/utils.py @@ -823,7 +823,7 @@ class MRTransformInputSpec(MRTrix3BaseInputSpec): ) invert = traits.Bool( argstr="-inverse", - position=1, + position=2, desc="Invert the specified transform before using it", ) linear_transform = File( From 445cd6d567157dec2b62906dd561384c7b8704a2 Mon Sep 17 00:00:00 2001 From: Chris Markiewicz Date: Tue, 27 Feb 2024 14:26:06 -0500 Subject: [PATCH 11/26] Fix typos --- .codespellrc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.codespellrc b/.codespellrc index 4bc57b6662..1192e63c5b 100644 --- a/.codespellrc +++ b/.codespellrc @@ -9,4 +9,5 @@ skip = .git,*.pdf,*.svg,external # Reson - short journal name # ALS, FWE - neuroimaging specific abbrevs # Comision - foreign word used -ignore-words-list = te,inport,objekt,jist,nd,hel,inout,fith,whos,fot,ue,shs,smal,nam,filetest,suh,noo,reson,als,fwe,crasher,comision,afile +# expad - AFNI flag +ignore-words-list = te,inport,objekt,jist,nd,hel,inout,fith,whos,fot,ue,shs,smal,nam,filetest,suh,noo,reson,als,fwe,crasher,comision,afile,expad From 457cf3c866667c54d8dc2c3c477d073388d0a47f Mon Sep 17 00:00:00 2001 From: Chris Markiewicz Date: Tue, 27 Feb 2024 14:27:50 -0500 Subject: [PATCH 12/26] Update pre-commit hooks --- .pre-commit-config.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 4c68f0d3f0..c1bda308da 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -2,17 +2,17 @@ # See https://pre-commit.com/hooks.html for more hooks repos: - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.4.0 + rev: v4.5.0 hooks: - id: trailing-whitespace - id: end-of-file-fixer - id: check-yaml - id: check-added-large-files - repo: https://github.com/psf/black - rev: 23.3.0 + rev: 24.2.0 hooks: - id: black - repo: https://github.com/codespell-project/codespell - rev: v2.2.5 + rev: v2.2.6 hooks: - id: codespell From f1cbc1c941f8d02659f8ef245aac0862efb80ccf Mon Sep 17 00:00:00 2001 From: Chris Markiewicz Date: Tue, 27 Feb 2024 14:28:18 -0500 Subject: [PATCH 13/26] STY: black 2024.2 [ignore-rev] --- nipype/algorithms/modelgen.py | 6 +++--- nipype/algorithms/rapidart.py | 6 +++--- nipype/caching/memory.py | 1 + nipype/interfaces/ants/legacy.py | 1 - nipype/interfaces/ants/registration.py | 1 + nipype/interfaces/ants/resampling.py | 1 + nipype/interfaces/ants/segmentation.py | 1 + nipype/interfaces/ants/utils.py | 1 + nipype/interfaces/base/core.py | 8 +++++--- nipype/interfaces/c3.py | 1 + nipype/interfaces/cmtk/__init__.py | 1 + nipype/interfaces/dcm2nii.py | 1 + nipype/interfaces/diffusion_toolkit/__init__.py | 1 + nipype/interfaces/dipy/__init__.py | 1 + nipype/interfaces/dipy/reconstruction.py | 1 + nipype/interfaces/dtitk/__init__.py | 1 + nipype/interfaces/fsl/epi.py | 6 +++--- nipype/interfaces/fsl/tests/test_preprocess.py | 2 +- nipype/interfaces/mipav/__init__.py | 1 + nipype/interfaces/mne/__init__.py | 1 + nipype/interfaces/nipy/__init__.py | 1 + nipype/interfaces/semtools/__init__.py | 1 + nipype/interfaces/slicer/__init__.py | 1 + nipype/interfaces/slicer/generate_classes.py | 1 + nipype/pipeline/plugins/dagman.py | 1 + nipype/pipeline/plugins/oar.py | 1 + nipype/pipeline/plugins/pbs.py | 1 + nipype/pipeline/plugins/pbsgraph.py | 1 + nipype/pipeline/plugins/sge.py | 1 + nipype/pipeline/plugins/sgegraph.py | 1 + nipype/pipeline/plugins/slurm.py | 1 + nipype/pipeline/plugins/slurmgraph.py | 1 + nipype/scripts/instance.py | 1 + nipype/scripts/utils.py | 1 - nipype/sphinxext/apidoc/__init__.py | 1 + nipype/sphinxext/documenter.py | 1 + nipype/sphinxext/gh.py | 1 + nipype/utils/functions.py | 1 + nipype/utils/imagemanip.py | 1 + 39 files changed, 47 insertions(+), 15 deletions(-) diff --git a/nipype/algorithms/modelgen.py b/nipype/algorithms/modelgen.py index e2656a0478..8487ac0264 100644 --- a/nipype/algorithms/modelgen.py +++ b/nipype/algorithms/modelgen.py @@ -417,9 +417,9 @@ def _generate_standard_design( sessinfo[i]["cond"][cid]["pmod"][j]["poly"] = info.pmod[ cid ].poly[j] - sessinfo[i]["cond"][cid]["pmod"][j][ - "param" - ] = info.pmod[cid].param[j] + sessinfo[i]["cond"][cid]["pmod"][j]["param"] = ( + info.pmod[cid].param[j] + ) sessinfo[i]["regress"] = [] if hasattr(info, "regressors") and info.regressors is not None: diff --git a/nipype/algorithms/rapidart.py b/nipype/algorithms/rapidart.py index 6063c5325f..99abf55b84 100644 --- a/nipype/algorithms/rapidart.py +++ b/nipype/algorithms/rapidart.py @@ -584,9 +584,9 @@ def _detect_outliers_core(self, imgfile, motionfile, runidx, cwd=None): if displacement is not None: dmap = np.zeros((x, y, z, timepoints), dtype=np.float64) for i in range(timepoints): - dmap[ - voxel_coords[0], voxel_coords[1], voxel_coords[2], i - ] = displacement[i, :] + dmap[voxel_coords[0], voxel_coords[1], voxel_coords[2], i] = ( + displacement[i, :] + ) dimg = Nifti1Image(dmap, affine) dimg.to_filename(displacementfile) else: diff --git a/nipype/caching/memory.py b/nipype/caching/memory.py index c941b48b41..a1d45ffff2 100644 --- a/nipype/caching/memory.py +++ b/nipype/caching/memory.py @@ -2,6 +2,7 @@ Using nipype with persistence and lazy recomputation but without explicit name-steps pipeline: getting back scope in command-line based programming. """ + import os import hashlib import pickle diff --git a/nipype/interfaces/ants/legacy.py b/nipype/interfaces/ants/legacy.py index 447e8afa83..373ca4982a 100644 --- a/nipype/interfaces/ants/legacy.py +++ b/nipype/interfaces/ants/legacy.py @@ -4,7 +4,6 @@ are preserved for backwards compatibility. """ - import os from glob import glob diff --git a/nipype/interfaces/ants/registration.py b/nipype/interfaces/ants/registration.py index 6312d8aa30..13fe55739c 100644 --- a/nipype/interfaces/ants/registration.py +++ b/nipype/interfaces/ants/registration.py @@ -1,6 +1,7 @@ """The ants module provides basic functions for interfacing with ants functions. """ + import os from ...utils.filemanip import ensure_list diff --git a/nipype/interfaces/ants/resampling.py b/nipype/interfaces/ants/resampling.py index 3a6ba2c724..c91b90238c 100644 --- a/nipype/interfaces/ants/resampling.py +++ b/nipype/interfaces/ants/resampling.py @@ -1,5 +1,6 @@ """ANTS Apply Transforms interface """ + import os from .base import ANTSCommand, ANTSCommandInputSpec diff --git a/nipype/interfaces/ants/segmentation.py b/nipype/interfaces/ants/segmentation.py index 11119cbde7..76c0ef152d 100644 --- a/nipype/interfaces/ants/segmentation.py +++ b/nipype/interfaces/ants/segmentation.py @@ -1,4 +1,5 @@ """Wrappers for segmentation utilities within ANTs.""" + import os from glob import glob from ...external.due import BibTeX diff --git a/nipype/interfaces/ants/utils.py b/nipype/interfaces/ants/utils.py index a2f57935f4..dd81aedd30 100644 --- a/nipype/interfaces/ants/utils.py +++ b/nipype/interfaces/ants/utils.py @@ -1,4 +1,5 @@ """ANTs' utilities.""" + import os from warnings import warn from ..base import traits, isdefined, TraitedSpec, File, Str, InputMultiObject diff --git a/nipype/interfaces/base/core.py b/nipype/interfaces/base/core.py index 797b90e741..6f60a13063 100644 --- a/nipype/interfaces/base/core.py +++ b/nipype/interfaces/base/core.py @@ -380,9 +380,11 @@ def run(self, cwd=None, ignore_exception=None, **inputs): """ rtc = RuntimeContext( resource_monitor=config.resource_monitor and self.resource_monitor, - ignore_exception=ignore_exception - if ignore_exception is not None - else self.ignore_exception, + ignore_exception=( + ignore_exception + if ignore_exception is not None + else self.ignore_exception + ), ) with indirectory(cwd or os.getcwd()): diff --git a/nipype/interfaces/c3.py b/nipype/interfaces/c3.py index 534d652b86..3871120d2c 100644 --- a/nipype/interfaces/c3.py +++ b/nipype/interfaces/c3.py @@ -1,4 +1,5 @@ """Convert3D is a command-line tool for converting 3D images between common file formats.""" + import os from glob import glob diff --git a/nipype/interfaces/cmtk/__init__.py b/nipype/interfaces/cmtk/__init__.py index 426130e1a5..d71ac76e2c 100644 --- a/nipype/interfaces/cmtk/__init__.py +++ b/nipype/interfaces/cmtk/__init__.py @@ -1,4 +1,5 @@ """CMP implements a full processing pipeline for creating connectomes with dMRI data.""" + from .cmtk import ROIGen, CreateMatrix, CreateNodes from .nx import NetworkXMetrics, AverageNetworks from .parcellation import Parcellate diff --git a/nipype/interfaces/dcm2nii.py b/nipype/interfaces/dcm2nii.py index e37887a99c..05ba2c2951 100644 --- a/nipype/interfaces/dcm2nii.py +++ b/nipype/interfaces/dcm2nii.py @@ -1,4 +1,5 @@ """dcm2nii converts images from the proprietary scanner DICOM format to NIfTI.""" + import os import re from copy import deepcopy diff --git a/nipype/interfaces/diffusion_toolkit/__init__.py b/nipype/interfaces/diffusion_toolkit/__init__.py index ef8dce7e4e..89b3d059ef 100644 --- a/nipype/interfaces/diffusion_toolkit/__init__.py +++ b/nipype/interfaces/diffusion_toolkit/__init__.py @@ -1,4 +1,5 @@ """Diffusion Toolkit performs data reconstruction and fiber tracking on diffusion MR images.""" + from .base import Info from .postproc import SplineFilter, TrackMerge from .dti import DTIRecon, DTITracker diff --git a/nipype/interfaces/dipy/__init__.py b/nipype/interfaces/dipy/__init__.py index d12c13844f..aa74ee46f8 100644 --- a/nipype/interfaces/dipy/__init__.py +++ b/nipype/interfaces/dipy/__init__.py @@ -1,4 +1,5 @@ """DIPY is a computational neuroimaging tool for diffusion MRI.""" + from .tracks import StreamlineTractography, TrackDensityMap from .tensors import TensorMode, DTI from .preprocess import Resample, Denoise diff --git a/nipype/interfaces/dipy/reconstruction.py b/nipype/interfaces/dipy/reconstruction.py index 7d39ab89d5..f242a76e29 100644 --- a/nipype/interfaces/dipy/reconstruction.py +++ b/nipype/interfaces/dipy/reconstruction.py @@ -2,6 +2,7 @@ Interfaces to the reconstruction algorithms in dipy """ + import os.path as op import numpy as np diff --git a/nipype/interfaces/dtitk/__init__.py b/nipype/interfaces/dtitk/__init__.py index d1420c3afb..4210c1dd5d 100644 --- a/nipype/interfaces/dtitk/__init__.py +++ b/nipype/interfaces/dtitk/__init__.py @@ -5,6 +5,7 @@ `_ command line tools. """ + from .registration import ( Rigid, Affine, diff --git a/nipype/interfaces/fsl/epi.py b/nipype/interfaces/fsl/epi.py index 5b4f577e0a..09daacb17f 100644 --- a/nipype/interfaces/fsl/epi.py +++ b/nipype/interfaces/fsl/epi.py @@ -1059,9 +1059,9 @@ def _list_outputs(self): if os.path.exists(out_shell_alignment_parameters): outputs["out_shell_alignment_parameters"] = out_shell_alignment_parameters if os.path.exists(out_shell_pe_translation_parameters): - outputs[ - "out_shell_pe_translation_parameters" - ] = out_shell_pe_translation_parameters + outputs["out_shell_pe_translation_parameters"] = ( + out_shell_pe_translation_parameters + ) if os.path.exists(out_outlier_map): outputs["out_outlier_map"] = out_outlier_map if os.path.exists(out_outlier_n_stdev_map): diff --git a/nipype/interfaces/fsl/tests/test_preprocess.py b/nipype/interfaces/fsl/tests/test_preprocess.py index 72f663394f..e32e5c574f 100644 --- a/nipype/interfaces/fsl/tests/test_preprocess.py +++ b/nipype/interfaces/fsl/tests/test_preprocess.py @@ -70,7 +70,7 @@ def func(): "center": ("-c 54 75 80", [54, 75, 80]), "threshold": ("-t", True), "mesh": ("-e", True), - "surfaces": ("-A", True) + "surfaces": ("-A", True), # 'verbose': ('-v', True), # 'flags': ('--i-made-this-up', '--i-made-this-up'), } diff --git a/nipype/interfaces/mipav/__init__.py b/nipype/interfaces/mipav/__init__.py index 51dd200dce..9cde4c0bcd 100644 --- a/nipype/interfaces/mipav/__init__.py +++ b/nipype/interfaces/mipav/__init__.py @@ -1,4 +1,5 @@ """MIPAV enables quantitative analysis and visualization of multimodal medical images.""" + from .developer import ( JistLaminarVolumetricLayering, JistBrainMgdmSegmentation, diff --git a/nipype/interfaces/mne/__init__.py b/nipype/interfaces/mne/__init__.py index 4a4750e8a4..7eba176251 100644 --- a/nipype/interfaces/mne/__init__.py +++ b/nipype/interfaces/mne/__init__.py @@ -1,2 +1,3 @@ """MNE is a software for exploring, visualizing, and analyzing human neurophysiological data.""" + from .base import WatershedBEM diff --git a/nipype/interfaces/nipy/__init__.py b/nipype/interfaces/nipy/__init__.py index c7fee0b8d8..ad8b66d887 100644 --- a/nipype/interfaces/nipy/__init__.py +++ b/nipype/interfaces/nipy/__init__.py @@ -1,4 +1,5 @@ """NIPY is a python project for analysis of structural and functional neuroimaging data.""" + from .model import FitGLM, EstimateContrast from .preprocess import ComputeMask, SpaceTimeRealigner from .utils import Similarity diff --git a/nipype/interfaces/semtools/__init__.py b/nipype/interfaces/semtools/__init__.py index ef43a28900..317273cfd8 100644 --- a/nipype/interfaces/semtools/__init__.py +++ b/nipype/interfaces/semtools/__init__.py @@ -1,4 +1,5 @@ """SEM Tools are useful tools for Structural Equation Modeling.""" + from .diffusion import * from .featurecreator import GenerateCsfClippedFromClassifiedImage from .segmentation import * diff --git a/nipype/interfaces/slicer/__init__.py b/nipype/interfaces/slicer/__init__.py index d874ab88c4..ca191b99df 100644 --- a/nipype/interfaces/slicer/__init__.py +++ b/nipype/interfaces/slicer/__init__.py @@ -4,6 +4,7 @@ For an EXPERIMENTAL implementation of an interface for the ``3dSlicer`` full framework, please check `"dynamic" Slicer `__. """ + from .diffusion import * from .segmentation import * from .filtering import * diff --git a/nipype/interfaces/slicer/generate_classes.py b/nipype/interfaces/slicer/generate_classes.py index 83f76c45b2..7c0c53bac6 100644 --- a/nipype/interfaces/slicer/generate_classes.py +++ b/nipype/interfaces/slicer/generate_classes.py @@ -2,6 +2,7 @@ modules are selected from the hardcoded list below and generated code is placed in the cli_modules.py file (and imported in __init__.py). For this to work correctly you must have your CLI executables in $PATH""" + import xml.dom.minidom import subprocess import os diff --git a/nipype/pipeline/plugins/dagman.py b/nipype/pipeline/plugins/dagman.py index 42a73f0d8d..ad8e4ec733 100644 --- a/nipype/pipeline/plugins/dagman.py +++ b/nipype/pipeline/plugins/dagman.py @@ -1,5 +1,6 @@ """Parallel workflow execution via Condor DAGMan """ + import os import sys import uuid diff --git a/nipype/pipeline/plugins/oar.py b/nipype/pipeline/plugins/oar.py index 0102d5b923..409d1746a5 100644 --- a/nipype/pipeline/plugins/oar.py +++ b/nipype/pipeline/plugins/oar.py @@ -1,5 +1,6 @@ """Parallel workflow execution via OAR http://oar.imag.fr """ + import os import stat from time import sleep diff --git a/nipype/pipeline/plugins/pbs.py b/nipype/pipeline/plugins/pbs.py index 3106cc1122..e6e699efd0 100644 --- a/nipype/pipeline/plugins/pbs.py +++ b/nipype/pipeline/plugins/pbs.py @@ -1,5 +1,6 @@ """Parallel workflow execution via PBS/Torque """ + import os from time import sleep diff --git a/nipype/pipeline/plugins/pbsgraph.py b/nipype/pipeline/plugins/pbsgraph.py index 17c6db2964..4b245dedb7 100644 --- a/nipype/pipeline/plugins/pbsgraph.py +++ b/nipype/pipeline/plugins/pbsgraph.py @@ -1,5 +1,6 @@ """Parallel workflow execution via PBS/Torque """ + import os import sys diff --git a/nipype/pipeline/plugins/sge.py b/nipype/pipeline/plugins/sge.py index ac89f2dfea..8ddbb31791 100644 --- a/nipype/pipeline/plugins/sge.py +++ b/nipype/pipeline/plugins/sge.py @@ -1,5 +1,6 @@ """Parallel workflow execution via SGE """ + import os import pwd import re diff --git a/nipype/pipeline/plugins/sgegraph.py b/nipype/pipeline/plugins/sgegraph.py index 182619bd98..ad5fb78c44 100644 --- a/nipype/pipeline/plugins/sgegraph.py +++ b/nipype/pipeline/plugins/sgegraph.py @@ -1,5 +1,6 @@ """Parallel workflow execution via SGE """ + import os import sys diff --git a/nipype/pipeline/plugins/slurm.py b/nipype/pipeline/plugins/slurm.py index 79fe28ee3d..cd37339695 100644 --- a/nipype/pipeline/plugins/slurm.py +++ b/nipype/pipeline/plugins/slurm.py @@ -5,6 +5,7 @@ Parallel workflow execution with SLURM """ + import os import re from time import sleep diff --git a/nipype/pipeline/plugins/slurmgraph.py b/nipype/pipeline/plugins/slurmgraph.py index 901dc02a99..7d9ff0cc41 100644 --- a/nipype/pipeline/plugins/slurmgraph.py +++ b/nipype/pipeline/plugins/slurmgraph.py @@ -1,5 +1,6 @@ """Parallel workflow execution via SLURM """ + import os import sys diff --git a/nipype/scripts/instance.py b/nipype/scripts/instance.py index 7bd2d7bf1b..f8712cf367 100644 --- a/nipype/scripts/instance.py +++ b/nipype/scripts/instance.py @@ -1,6 +1,7 @@ """ Import lib and class meta programming utilities. """ + import inspect import importlib diff --git a/nipype/scripts/utils.py b/nipype/scripts/utils.py index 00b0f8970e..77e7231bea 100644 --- a/nipype/scripts/utils.py +++ b/nipype/scripts/utils.py @@ -2,7 +2,6 @@ Utilities for the CLI functions. """ - import re import click import json diff --git a/nipype/sphinxext/apidoc/__init__.py b/nipype/sphinxext/apidoc/__init__.py index 7392973536..151011bdfc 100644 --- a/nipype/sphinxext/apidoc/__init__.py +++ b/nipype/sphinxext/apidoc/__init__.py @@ -38,6 +38,7 @@ class Config(NapoleonConfig): (requires duecredit to be installed). """ + _config_values = { "nipype_skip_classes": ( ["Tester", "InputSpec", "OutputSpec", "Numpy", "NipypeTester"], diff --git a/nipype/sphinxext/documenter.py b/nipype/sphinxext/documenter.py index 500c486927..eee0f626b9 100644 --- a/nipype/sphinxext/documenter.py +++ b/nipype/sphinxext/documenter.py @@ -1,4 +1,5 @@ """sphinx autodoc ext.""" + from sphinx.locale import _ from sphinx.ext import autodoc from nipype.interfaces.base import BaseInterface diff --git a/nipype/sphinxext/gh.py b/nipype/sphinxext/gh.py index 9339ddb48b..07a6513fb4 100644 --- a/nipype/sphinxext/gh.py +++ b/nipype/sphinxext/gh.py @@ -1,4 +1,5 @@ """Build a file URL.""" + import os import inspect import subprocess diff --git a/nipype/utils/functions.py b/nipype/utils/functions.py index 1ef35b22b1..262f48665e 100644 --- a/nipype/utils/functions.py +++ b/nipype/utils/functions.py @@ -2,6 +2,7 @@ Handles custom functions used in Function interface. Future imports are avoided to keep namespace as clear as possible. """ + import inspect from textwrap import dedent diff --git a/nipype/utils/imagemanip.py b/nipype/utils/imagemanip.py index 4fe022973b..15680dc6e4 100644 --- a/nipype/utils/imagemanip.py +++ b/nipype/utils/imagemanip.py @@ -1,4 +1,5 @@ """Image manipulation utilities (mostly, NiBabel manipulations).""" + import nibabel as nb From d5cf21a075b26a5c9205fab66b7c5395973099fa Mon Sep 17 00:00:00 2001 From: Chris Markiewicz Date: Tue, 27 Feb 2024 14:30:13 -0500 Subject: [PATCH 14/26] chore: Update .git-blame-ignore-revs --- .git-blame-ignore-revs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/.git-blame-ignore-revs b/.git-blame-ignore-revs index 8c1e119249..253c1c6919 100644 --- a/.git-blame-ignore-revs +++ b/.git-blame-ignore-revs @@ -1,3 +1,13 @@ +# Tue Feb 27 14:28:18 2024 -0500 - effigies@gmail.com - STY: black 2024.2 [ignore-rev] +f1cbc1c941f8d02659f8ef245aac0862efb80ccf +# Mon Sep 11 13:36:40 2023 +0200 - 37933899+servoz@users.noreply.github.com - run black for nipype/interfaces/spm/preprocess.py +b9cac5e993143febb01ade42e56b41009427a4b6 +# Wed Jul 5 16:31:45 2023 -0400 - effigies@gmail.com - STY: Run black and fix typo +34a4ac6eeff8d4924b40875c45df5d84a97da90b +# Wed Jul 5 11:30:42 2023 -0400 - effigies@gmail.com - STY: black +3b89ca85faf2428ecf7844de9c0db4aa7c329c93 +# Wed Jul 5 09:49:31 2023 -0400 - effigies@gmail.com - STY: black +4a6a7d9d25d5d1e1f0eb55828dede58f8b9c9f80 # Wed Apr 5 14:01:05 2023 -0400 - effigies@gmail.com - STY: black [ignore-rev] a9ce9b78a402ebacf7726ad6454bb75b1447f52f # Wed Sep 14 14:12:07 2022 -0400 - mathiasg@stanford.edu - STY: Black From 056b48f23c896bed0fce1c571f33bb01922a1713 Mon Sep 17 00:00:00 2001 From: Chris Markiewicz Date: Tue, 27 Feb 2024 14:35:34 -0500 Subject: [PATCH 15/26] chore: Update dependabot config to update all actions in one go --- .github/dependabot.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 3ab43cc7e7..61d6e0c09e 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -5,3 +5,7 @@ updates: directory: "/" schedule: interval: "weekly" + groups: + actions-infrastructure: + patterns: + - "actions/*" From 33a855f5eb8d521df26509d29abbb713c18da312 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 27 Feb 2024 19:36:54 +0000 Subject: [PATCH 16/26] Bump the actions-infrastructure group with 3 updates Bumps the actions-infrastructure group with 3 updates: [actions/setup-python](https://github.com/actions/setup-python), [actions/upload-artifact](https://github.com/actions/upload-artifact) and [actions/download-artifact](https://github.com/actions/download-artifact). Updates `actions/setup-python` from 4 to 5 - [Release notes](https://github.com/actions/setup-python/releases) - [Commits](https://github.com/actions/setup-python/compare/v4...v5) Updates `actions/upload-artifact` from 3 to 4 - [Release notes](https://github.com/actions/upload-artifact/releases) - [Commits](https://github.com/actions/upload-artifact/compare/v3...v4) Updates `actions/download-artifact` from 3 to 4 - [Release notes](https://github.com/actions/download-artifact/releases) - [Commits](https://github.com/actions/download-artifact/compare/v3...v4) --- updated-dependencies: - dependency-name: actions/setup-python dependency-type: direct:production update-type: version-update:semver-major dependency-group: actions-infrastructure - dependency-name: actions/upload-artifact dependency-type: direct:production update-type: version-update:semver-major dependency-group: actions-infrastructure - dependency-name: actions/download-artifact dependency-type: direct:production update-type: version-update:semver-major dependency-group: actions-infrastructure ... Signed-off-by: dependabot[bot] --- .github/workflows/contrib.yml | 4 ++-- .github/workflows/tests.yml | 14 +++++++------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/.github/workflows/contrib.yml b/.github/workflows/contrib.yml index 2b35e7c831..67427e0e66 100644 --- a/.github/workflows/contrib.yml +++ b/.github/workflows/contrib.yml @@ -50,7 +50,7 @@ jobs: submodules: recursive fetch-depth: 0 - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v4 + uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} - name: Display Python version @@ -76,7 +76,7 @@ jobs: file: coverage.xml if: ${{ always() }} - name: Upload pytest test results - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: pytest-results-${{ matrix.os }}-${{ matrix.python-version }} path: test-results.xml diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index c769cc9c71..ffd04e1878 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -40,14 +40,14 @@ jobs: - uses: actions/checkout@v4 with: fetch-depth: 0 - - uses: actions/setup-python@v4 + - uses: actions/setup-python@v5 with: python-version: 3 - run: pip install --upgrade build twine - name: Build sdist and wheel run: python -m build - run: twine check dist/* - - uses: actions/upload-artifact@v3 + - uses: actions/upload-artifact@v4 with: name: dist path: dist/ @@ -59,11 +59,11 @@ jobs: matrix: package: ['wheel', 'sdist'] steps: - - uses: actions/download-artifact@v3 + - uses: actions/download-artifact@v4 with: name: dist path: dist/ - - uses: actions/setup-python@v4 + - uses: actions/setup-python@v5 with: python-version: 3 - name: Display Python version @@ -124,7 +124,7 @@ jobs: steps: - uses: actions/checkout@v4 - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v4 + uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} - name: Display Python version @@ -150,7 +150,7 @@ jobs: file: coverage.xml if: ${{ always() }} - name: Upload pytest test results - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: pytest-results-${{ matrix.os }}-${{ matrix.python-version }} path: test-results.xml @@ -162,7 +162,7 @@ jobs: needs: [stable, test-package] if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') steps: - - uses: actions/download-artifact@v3 + - uses: actions/download-artifact@v4 with: name: dist path: dist/ From caef07b7ab5a8f31398efa85265509bae158fccc Mon Sep 17 00:00:00 2001 From: Chris Markiewicz Date: Tue, 27 Feb 2024 16:37:17 -0500 Subject: [PATCH 17/26] Update .github/workflows/tests.yml --- .github/workflows/tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index ffd04e1878..899f2fc37b 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -152,7 +152,7 @@ jobs: - name: Upload pytest test results uses: actions/upload-artifact@v4 with: - name: pytest-results-${{ matrix.os }}-${{ matrix.python-version }} + name: pytest-results-${{ matrix.os }}-${{ matrix.python-version }}-${{ matrix.deb-depends }} path: test-results.xml if: ${{ always() && matrix.check == 'test' }} From 81d690c4386c1e964eefef9fa22a9ef1d28dbda7 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 5 Feb 2024 04:30:48 +0000 Subject: [PATCH 18/26] Bump codecov/codecov-action from 3 to 4 Bumps [codecov/codecov-action](https://github.com/codecov/codecov-action) from 3 to 4. - [Release notes](https://github.com/codecov/codecov-action/releases) - [Changelog](https://github.com/codecov/codecov-action/blob/main/CHANGELOG.md) - [Commits](https://github.com/codecov/codecov-action/compare/v3...v4) --- updated-dependencies: - dependency-name: codecov/codecov-action dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- .github/workflows/contrib.yml | 2 +- .github/workflows/tests.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/contrib.yml b/.github/workflows/contrib.yml index 2b35e7c831..f5d2f05001 100644 --- a/.github/workflows/contrib.yml +++ b/.github/workflows/contrib.yml @@ -71,7 +71,7 @@ jobs: - name: Run tests run: tools/ci/check.sh if: ${{ matrix.check != 'skiptests' }} - - uses: codecov/codecov-action@v3 + - uses: codecov/codecov-action@v4 with: file: coverage.xml if: ${{ always() }} diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index c769cc9c71..fe0c56c64e 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -145,7 +145,7 @@ jobs: - name: Run tests run: tools/ci/check.sh if: ${{ matrix.check != 'skiptests' }} - - uses: codecov/codecov-action@v3 + - uses: codecov/codecov-action@v4 with: file: coverage.xml if: ${{ always() }} From 2f793c27e3016919a433e14c0638d5b0992e814c Mon Sep 17 00:00:00 2001 From: Chris Markiewicz Date: Tue, 27 Feb 2024 16:40:28 -0500 Subject: [PATCH 19/26] Apply suggestions from code review --- .github/workflows/contrib.yml | 1 + .github/workflows/tests.yml | 1 + 2 files changed, 2 insertions(+) diff --git a/.github/workflows/contrib.yml b/.github/workflows/contrib.yml index f5d2f05001..97d9fd2ef2 100644 --- a/.github/workflows/contrib.yml +++ b/.github/workflows/contrib.yml @@ -74,6 +74,7 @@ jobs: - uses: codecov/codecov-action@v4 with: file: coverage.xml + token: ${{ secrets.CODECOV_TOKEN }} if: ${{ always() }} - name: Upload pytest test results uses: actions/upload-artifact@v3 diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index fe0c56c64e..93793281e5 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -148,6 +148,7 @@ jobs: - uses: codecov/codecov-action@v4 with: file: coverage.xml + token: ${{ secrets.CODECOV_TOKEN }} if: ${{ always() }} - name: Upload pytest test results uses: actions/upload-artifact@v3 From eda649755b4090ebaa959a771829fec1f9db3ba0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Toomas=20Erik=20Anij=C3=A4rv?= Date: Wed, 28 Feb 2024 09:03:21 +0100 Subject: [PATCH 20/26] Fix generate5tt input --- nipype/interfaces/mrtrix3/utils.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/nipype/interfaces/mrtrix3/utils.py b/nipype/interfaces/mrtrix3/utils.py index d0b474a76b..cb6b31ae91 100644 --- a/nipype/interfaces/mrtrix3/utils.py +++ b/nipype/interfaces/mrtrix3/utils.py @@ -11,6 +11,7 @@ traits, TraitedSpec, File, + Directory, InputMultiPath, isdefined, ) @@ -230,8 +231,10 @@ class Generate5ttInputSpec(MRTrix3BaseInputSpec): mandatory=True, desc="tissue segmentation algorithm", ) - in_file = File( - exists=False, argstr="%s", mandatory=True, position=-2, desc="input image" + in_file = traits.Either( + File(exists=True), + Directory(exists=True), + argstr="%s", mandatory=True, position=-2, desc="input image / directory" ) out_file = File(argstr="%s", mandatory=True, position=-1, desc="output image") From 7fc44fd9eb7eb80ef01c3253bb2cd72932389d48 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Toomas=20Erik=20Anij=C3=A4rv?= Date: Wed, 28 Feb 2024 09:07:45 +0100 Subject: [PATCH 21/26] Remove the -inverse parameter position change --- nipype/interfaces/mrtrix3/utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nipype/interfaces/mrtrix3/utils.py b/nipype/interfaces/mrtrix3/utils.py index cb6b31ae91..cecbc6c855 100644 --- a/nipype/interfaces/mrtrix3/utils.py +++ b/nipype/interfaces/mrtrix3/utils.py @@ -826,7 +826,7 @@ class MRTransformInputSpec(MRTrix3BaseInputSpec): ) invert = traits.Bool( argstr="-inverse", - position=2, + position=1, desc="Invert the specified transform before using it", ) linear_transform = File( From 259210675c7db33927f2f70dbb0f215d8008f091 Mon Sep 17 00:00:00 2001 From: Martin Norgaard Date: Sun, 3 Mar 2024 20:09:36 +0100 Subject: [PATCH 22/26] ENH: add STC PVC to PETPVC interface --- nipype/interfaces/petpvc.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/nipype/interfaces/petpvc.py b/nipype/interfaces/petpvc.py index dbd1d805ed..ac388f6b51 100644 --- a/nipype/interfaces/petpvc.py +++ b/nipype/interfaces/petpvc.py @@ -37,6 +37,7 @@ "RBV+VC", "RL", "VC", + "STC", ] @@ -75,6 +76,7 @@ class PETPVCInputSpec(CommandLineInputSpec): * Muller Gartner -- ``MG`` * Muller Gartner with Van-Cittert -- ``MG+VC`` * Muller Gartner with Richardson-Lucy -- ``MG+RL`` + * Single-target correction -- ``STC`` """, ) From dcc249903b7957cffca61f6ff82761d615f273ce Mon Sep 17 00:00:00 2001 From: Zach Lindsey Date: Wed, 13 Mar 2024 11:16:04 -0500 Subject: [PATCH 23/26] use csvreader for parsing csv files --- nipype/interfaces/utility/csv.py | 15 ++++---- nipype/interfaces/utility/tests/test_csv.py | 41 +++++++++++++++++++++ 2 files changed, 48 insertions(+), 8 deletions(-) diff --git a/nipype/interfaces/utility/csv.py b/nipype/interfaces/utility/csv.py index 3bfc46203d..da09e425fb 100644 --- a/nipype/interfaces/utility/csv.py +++ b/nipype/interfaces/utility/csv.py @@ -2,6 +2,7 @@ # vi: set ft=python sts=4 ts=4 sw=4 et: """CSV Handling utilities """ +import csv from ..base import traits, TraitedSpec, DynamicTraitedSpec, File, BaseInterface from ..io import add_traits @@ -13,6 +14,7 @@ class CSVReaderInputSpec(DynamicTraitedSpec, TraitedSpec): header = traits.Bool( False, usedefault=True, desc="True if the first line is a column header" ) + delimiter = traits.String(",", usedefault=True, desc="Delimiter to use.") class CSVReader(BaseInterface): @@ -52,14 +54,11 @@ def _append_entry(self, outputs, entry): outputs[key].append(value) return outputs - def _parse_line(self, line): - line = line.replace("\n", "") - entry = [x.strip() for x in line.split(",")] - return entry - def _get_outfields(self): with open(self.inputs.in_file) as fid: - entry = self._parse_line(fid.readline()) + reader = csv.reader(fid, delimiter=self.inputs.delimiter) + + entry = next(reader) if self.inputs.header: self._outfields = tuple(entry) else: @@ -82,10 +81,10 @@ def _list_outputs(self): for key in self._outfields: outputs[key] = [] # initialize outfields with open(self.inputs.in_file) as fid: - for line in fid.readlines(): + reader = csv.reader(fid, delimiter=self.inputs.delimiter) + for entry in reader: if self.inputs.header and isHeader: # skip header line isHeader = False continue - entry = self._parse_line(line) outputs = self._append_entry(outputs, entry) return outputs diff --git a/nipype/interfaces/utility/tests/test_csv.py b/nipype/interfaces/utility/tests/test_csv.py index 923af9d837..3d4dcabe95 100644 --- a/nipype/interfaces/utility/tests/test_csv.py +++ b/nipype/interfaces/utility/tests/test_csv.py @@ -26,3 +26,44 @@ def test_csvReader(tmpdir): assert out.outputs.column_0 == ["foo", "bar", "baz"] assert out.outputs.column_1 == ["hello", "world", "goodbye"] assert out.outputs.column_2 == ["300.1", "5", "0.3"] + + +def test_csvReader_quoted(tmpdir): + header = "files,labels,erosion\n" + lines = ["foo,\"hello, world\",300.1\n"] + + name = tmpdir.join("testfile.csv").strpath + with open(name, "w") as fid: + reader = utility.CSVReader() + fid.writelines(lines) + fid.flush() + reader.inputs.in_file = name + out = reader.run() + + assert out.outputs.column_0 == ["foo"] + assert out.outputs.column_1 == ["hello, world"] + assert out.outputs.column_2 == ["300.1"] + + +def test_csvReader_tabs(tmpdir): + header = "files\tlabels\terosion\n" + lines = ["foo\thello\t300.1\n", "bar\tworld\t5\n", "baz\tgoodbye\t0.3\n"] + for x in range(2): + name = tmpdir.join("testfile.csv").strpath + with open(name, "w") as fid: + reader = utility.CSVReader(delimiter="\t") + if x % 2 == 0: + fid.write(header) + reader.inputs.header = True + fid.writelines(lines) + fid.flush() + reader.inputs.in_file = name + out = reader.run() + if x % 2 == 0: + assert out.outputs.files == ["foo", "bar", "baz"] + assert out.outputs.labels == ["hello", "world", "goodbye"] + assert out.outputs.erosion == ["300.1", "5", "0.3"] + else: + assert out.outputs.column_0 == ["foo", "bar", "baz"] + assert out.outputs.column_1 == ["hello", "world", "goodbye"] + assert out.outputs.column_2 == ["300.1", "5", "0.3"] From 5e84919fe1efd30524bf6c4a3b79d14d9be4a8de Mon Sep 17 00:00:00 2001 From: Zach Lindsey Date: Wed, 13 Mar 2024 13:52:35 -0500 Subject: [PATCH 24/26] add csvreader autotest --- nipype/interfaces/utility/tests/test_auto_CSVReader.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/nipype/interfaces/utility/tests/test_auto_CSVReader.py b/nipype/interfaces/utility/tests/test_auto_CSVReader.py index be24c59eb4..a96a4d11bf 100644 --- a/nipype/interfaces/utility/tests/test_auto_CSVReader.py +++ b/nipype/interfaces/utility/tests/test_auto_CSVReader.py @@ -4,6 +4,9 @@ def test_CSVReader_inputs(): input_map = dict( + delimiter=dict( + usedefault=True, + ), header=dict( usedefault=True, ), From f746c3408fe7e658bbc9cb0084c27540dc6d3a64 Mon Sep 17 00:00:00 2001 From: Chris Markiewicz Date: Sun, 17 Mar 2024 10:40:31 -0400 Subject: [PATCH 25/26] Update nipype/interfaces/utility/tests/test_csv.py --- nipype/interfaces/utility/tests/test_csv.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nipype/interfaces/utility/tests/test_csv.py b/nipype/interfaces/utility/tests/test_csv.py index 3d4dcabe95..8a8f06e509 100644 --- a/nipype/interfaces/utility/tests/test_csv.py +++ b/nipype/interfaces/utility/tests/test_csv.py @@ -30,7 +30,7 @@ def test_csvReader(tmpdir): def test_csvReader_quoted(tmpdir): header = "files,labels,erosion\n" - lines = ["foo,\"hello, world\",300.1\n"] + lines = ['foo,"hello, world",300.1\n'] name = tmpdir.join("testfile.csv").strpath with open(name, "w") as fid: From f1a8909d233ed2a707b6ee8937504eea9ee7f154 Mon Sep 17 00:00:00 2001 From: Chris Markiewicz Date: Sun, 17 Mar 2024 10:44:57 -0400 Subject: [PATCH 26/26] STY: black --- nipype/interfaces/mrtrix3/utils.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/nipype/interfaces/mrtrix3/utils.py b/nipype/interfaces/mrtrix3/utils.py index 3a35e7e534..ed6846cea7 100644 --- a/nipype/interfaces/mrtrix3/utils.py +++ b/nipype/interfaces/mrtrix3/utils.py @@ -234,7 +234,10 @@ class Generate5ttInputSpec(MRTrix3BaseInputSpec): in_file = traits.Either( File(exists=True), Directory(exists=True), - argstr="%s", mandatory=True, position=-2, desc="input image / directory" + argstr="%s", + mandatory=True, + position=-2, + desc="input image / directory", ) out_file = File(argstr="%s", mandatory=True, position=-1, desc="output image")