From c19143e383146e6e6ab69f2be21d1da8574e1438 Mon Sep 17 00:00:00 2001 From: mauriliogenovese Date: Mon, 9 Oct 2023 18:04:06 +0200 Subject: [PATCH 1/6] Update dcm2nii.py --- nipype/interfaces/dcm2nii.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/nipype/interfaces/dcm2nii.py b/nipype/interfaces/dcm2nii.py index e37887a99c..f8f01ae2d7 100644 --- a/nipype/interfaces/dcm2nii.py +++ b/nipype/interfaces/dcm2nii.py @@ -469,7 +469,7 @@ def _parse_files(self, filenames): for filename in filenames: # search for relevant files, and sort accordingly - for fl in search_files(filename, outtypes): + for fl in search_files(filename, outtypes, self.inputs.crop): if ( fl.endswith(".nii") or fl.endswith(".gz") @@ -502,7 +502,13 @@ def _list_outputs(self): # https://stackoverflow.com/a/4829130 -def search_files(prefix, outtypes): - return it.chain.from_iterable( +def search_files(prefix, outtypes, search_crop): + found = it.chain.from_iterable( iglob(glob.escape(prefix + outtype)) for outtype in outtypes ) + if search_crop: + found = it.chain( + it.chain.from_iterable(iglob(glob.escape(prefix) + "_Crop_*" + outtype) for outtype in outtypes), + found + ) + return found From e447b92bcb3b9ed9e35394d6edef1d91b7c424e6 Mon Sep 17 00:00:00 2001 From: Chris Markiewicz Date: Sun, 17 Mar 2024 10:58:12 -0400 Subject: [PATCH 2/6] STY: black [ignore-rev] --- nipype/interfaces/dcm2nii.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/nipype/interfaces/dcm2nii.py b/nipype/interfaces/dcm2nii.py index 6d197edd11..f7bd9e3906 100644 --- a/nipype/interfaces/dcm2nii.py +++ b/nipype/interfaces/dcm2nii.py @@ -509,7 +509,9 @@ def search_files(prefix, outtypes, search_crop): ) if search_crop: found = it.chain( - it.chain.from_iterable(iglob(glob.escape(prefix) + "_Crop_*" + outtype) for outtype in outtypes), - found + it.chain.from_iterable( + iglob(glob.escape(prefix) + "_Crop_*" + outtype) for outtype in outtypes + ), + found, ) return found From 73019f23c84d16b388b5f344e3cc5acb58d64a87 Mon Sep 17 00:00:00 2001 From: mauriliogenovese Date: Thu, 21 Mar 2024 17:11:05 +0100 Subject: [PATCH 3/6] Update test_dcm2nii.py --- nipype/interfaces/tests/test_dcm2nii.py | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/nipype/interfaces/tests/test_dcm2nii.py b/nipype/interfaces/tests/test_dcm2nii.py index 4e54f73960..04b02c5ed8 100644 --- a/nipype/interfaces/tests/test_dcm2nii.py +++ b/nipype/interfaces/tests/test_dcm2nii.py @@ -5,17 +5,26 @@ @pytest.mark.parametrize( - "fname, extension", + "fname, extension, search_crop", [ - ("output_1", ".txt"), - ("output_w_[]_meta_1", ".json"), - ("output_w_**^$?_meta_2", ".txt"), + ("output_1", ".txt", False), + ("output_w_[]_meta_1", ".json", False), + ("output_w_**^$?_meta_2", ".txt", False), + ("output_cropped", ".txt", True), ], ) -def test_search_files(tmp_path, fname, extension): +def test_search_files(tmp_path, fname, extension, search_crop): tmp_fname = fname + extension test_file = tmp_path / tmp_fname test_file.touch() - actual_files_list = dcm2nii.search_files(str(tmp_path / fname), [extension]) + if search_crop: + tmp_cropped_fname = fname + "_Crop_1" + extension + test_cropped_file = tmp_path / tmp_cropped_fname + test_cropped_file.touch() + + actual_files_list = dcm2nii.search_files(str(tmp_path / fname), [extension], search_crop) for f in actual_files_list: - assert str(test_file) == f + if search_crop: + assert (f in (str(test_cropped_file), str(test_file))) + else: + assert str(test_file) == f From 529f6f43654f1cb612578772e38f923bdafd7436 Mon Sep 17 00:00:00 2001 From: mauriliogenovese Date: Thu, 21 Mar 2024 17:22:14 +0100 Subject: [PATCH 4/6] Update .zenodo.json --- .zenodo.json | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/.zenodo.json b/.zenodo.json index bc34c33939..a6b5b1375d 100644 --- a/.zenodo.json +++ b/.zenodo.json @@ -919,7 +919,12 @@ "affiliation": "MIT, HMS", "name": "Ghosh, Satrajit", "orcid": "0000-0002-5312-6729" - } + }, + { + "affiliation": "Azienda Ospedaliero-Universitaria di Modena", + "name": "Genovese, Maurilio", + "orcid": "0000-0002-8154-8224" + }, ], "keywords": [ "neuroimaging", From c52fece0cf154c1a93a55b202d088f08924a023e Mon Sep 17 00:00:00 2001 From: Chris Markiewicz Date: Thu, 21 Mar 2024 13:34:09 -0400 Subject: [PATCH 5/6] STY: black [ignore-rev] --- nipype/interfaces/tests/test_dcm2nii.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/nipype/interfaces/tests/test_dcm2nii.py b/nipype/interfaces/tests/test_dcm2nii.py index 04b02c5ed8..5154534c5a 100644 --- a/nipype/interfaces/tests/test_dcm2nii.py +++ b/nipype/interfaces/tests/test_dcm2nii.py @@ -22,9 +22,11 @@ def test_search_files(tmp_path, fname, extension, search_crop): test_cropped_file = tmp_path / tmp_cropped_fname test_cropped_file.touch() - actual_files_list = dcm2nii.search_files(str(tmp_path / fname), [extension], search_crop) + actual_files_list = dcm2nii.search_files( + str(tmp_path / fname), [extension], search_crop + ) for f in actual_files_list: if search_crop: - assert (f in (str(test_cropped_file), str(test_file))) + assert f in (str(test_cropped_file), str(test_file)) else: assert str(test_file) == f From cf926c0da6d7f0cb0d83a7056b8442c2ae3434d9 Mon Sep 17 00:00:00 2001 From: Chris Markiewicz Date: Thu, 21 Mar 2024 13:35:21 -0400 Subject: [PATCH 6/6] MNT: Reorder Zenodo, fix JSON error --- .zenodo.json | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.zenodo.json b/.zenodo.json index a6b5b1375d..d01d2409e3 100644 --- a/.zenodo.json +++ b/.zenodo.json @@ -910,6 +910,11 @@ "name": "Anijärv, Toomas Erik", "orcid": "0000-0002-3650-4230" }, + { + "affiliation": "Azienda Ospedaliero-Universitaria di Modena", + "name": "Genovese, Maurilio", + "orcid": "0000-0002-8154-8224" + }, { "affiliation": "Department of Psychology, Stanford University", "name": "Gorgolewski, Krzysztof J.", @@ -919,12 +924,7 @@ "affiliation": "MIT, HMS", "name": "Ghosh, Satrajit", "orcid": "0000-0002-5312-6729" - }, - { - "affiliation": "Azienda Ospedaliero-Universitaria di Modena", - "name": "Genovese, Maurilio", - "orcid": "0000-0002-8154-8224" - }, + } ], "keywords": [ "neuroimaging",