From 54390b20ac73afb397d5a9ca45e4e75dedbb80aa Mon Sep 17 00:00:00 2001 From: akeshavan Date: Thu, 7 Apr 2016 14:23:18 -0700 Subject: [PATCH 1/5] fix: no double filenames in the list, and filenames must exist to be in the list --- nipype/interfaces/dcm2nii.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/nipype/interfaces/dcm2nii.py b/nipype/interfaces/dcm2nii.py index b78d925517..2848f745f4 100644 --- a/nipype/interfaces/dcm2nii.py +++ b/nipype/interfaces/dcm2nii.py @@ -139,11 +139,13 @@ def _parse_stdout(self, stdout): else: output_dir = self._gen_filename('output_dir') val = os.path.join(output_dir, val) - out_file = val + if os.path.exists(val): + out_file = val if out_file: - files.append(out_file) - last_added_file = out_file + if not out_file in files: + files.append(out_file) + last_added_file = out_file continue if line.startswith("Reorienting as "): From e5674fe22ddd66457cc61f341abe08db027d2d9d Mon Sep 17 00:00:00 2001 From: akeshavan Date: Thu, 7 Apr 2016 14:49:27 -0700 Subject: [PATCH 2/5] fix: make check-before-commit --- nipype/workflows/smri/freesurfer/recon.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/nipype/workflows/smri/freesurfer/recon.py b/nipype/workflows/smri/freesurfer/recon.py index c9206812f3..b574314f35 100644 --- a/nipype/workflows/smri/freesurfer/recon.py +++ b/nipype/workflows/smri/freesurfer/recon.py @@ -82,7 +82,7 @@ def link_masks(subjects_dir, subject_id): def create_reconall_workflow(name="ReconAll", plugin_args=None, recoding_file=None): """Creates the ReconAll workflow in nipype. - + Example ------- >>> from nipype.workflows.smri.freesurfer import create_skullstripped_recon_flow @@ -200,7 +200,7 @@ def checkarg(arg, default): 'lookup_table', 'wm_lookup_table', 'awk_file'] - + config_node = pe.Node(niu.Function(params, params, setconfig), @@ -509,7 +509,7 @@ def completemethod(datasinked_files, subject_id): reconall.connect([(datasink, completion, [('out_file', 'datasinked_files')]), (inputspec, completion, [('subject_id', 'subject_id')]), (completion, postds_outputspec, [('subject_id', 'subject_id')])]) - + #### Workflow additions go here if recoding_file: From 6620234ed86bff8b876526f784152987e1a036ce Mon Sep 17 00:00:00 2001 From: akeshavan Date: Thu, 7 Apr 2016 18:27:16 -0700 Subject: [PATCH 3/5] fix: dcm2nii does not always crop and reorient when it says it does --- nipype/interfaces/dcm2nii.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/nipype/interfaces/dcm2nii.py b/nipype/interfaces/dcm2nii.py index 2848f745f4..8a0c53ecac 100644 --- a/nipype/interfaces/dcm2nii.py +++ b/nipype/interfaces/dcm2nii.py @@ -155,9 +155,11 @@ def _parse_stdout(self, stdout): elif line.startswith("Cropping NIfTI/Analyze image "): base, filename = os.path.split(line[len("Cropping NIfTI/Analyze image "):]) filename = "c" + filename - reoriented_and_cropped_files.append(os.path.join(base, filename)) - skip = True - continue + if os.path.exists(os.path.join(base, filename)): + reoriented_and_cropped_files.append(os.path.join(base, filename)) + skip = True + continue + skip = False return files, reoriented_files, reoriented_and_cropped_files, bvecs, bvals From 2090493ab77d589dd12764fd8be5099cbd403fab Mon Sep 17 00:00:00 2001 From: akeshavan Date: Thu, 7 Apr 2016 18:32:41 -0700 Subject: [PATCH 4/5] fix: if you expect a reoriented and cropped file but it does not exist, interface errors normally --- nipype/interfaces/dcm2nii.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/nipype/interfaces/dcm2nii.py b/nipype/interfaces/dcm2nii.py index 8a0c53ecac..6aa4eb7beb 100644 --- a/nipype/interfaces/dcm2nii.py +++ b/nipype/interfaces/dcm2nii.py @@ -155,11 +155,12 @@ def _parse_stdout(self, stdout): elif line.startswith("Cropping NIfTI/Analyze image "): base, filename = os.path.split(line[len("Cropping NIfTI/Analyze image "):]) filename = "c" + filename - if os.path.exists(os.path.join(base, filename)): + if os.path.exists(os.path.join(base, filename)) or self.inputs.reorient_and_crop: + # if reorient&crop is true but the file doesn't exist, this errors when setting outputs reoriented_and_cropped_files.append(os.path.join(base, filename)) skip = True continue - + skip = False return files, reoriented_files, reoriented_and_cropped_files, bvecs, bvals From dee2e58fbcf0951b5b09355a61c81e4c15e5447a Mon Sep 17 00:00:00 2001 From: akeshavan Date: Mon, 11 Apr 2016 16:50:12 -0700 Subject: [PATCH 5/5] doc: make check-before-commit --- nipype/interfaces/dcm2nii.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nipype/interfaces/dcm2nii.py b/nipype/interfaces/dcm2nii.py index 6aa4eb7beb..5c5eb4e134 100644 --- a/nipype/interfaces/dcm2nii.py +++ b/nipype/interfaces/dcm2nii.py @@ -160,7 +160,7 @@ def _parse_stdout(self, stdout): reoriented_and_cropped_files.append(os.path.join(base, filename)) skip = True continue - + skip = False return files, reoriented_files, reoriented_and_cropped_files, bvecs, bvals