From 715c1d5695645eb2b7f7b4cca06e830fc783dec6 Mon Sep 17 00:00:00 2001 From: cmadjar Date: Wed, 2 Nov 2022 12:42:22 -0400 Subject: [PATCH 1/2] modifies the dcm2niix command to use the Config converter value instead of hardcoding dcm2niix --- .../dicom_archive_loader_pipeline.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/python/lib/dcm2bids_imaging_pipeline_lib/dicom_archive_loader_pipeline.py b/python/lib/dcm2bids_imaging_pipeline_lib/dicom_archive_loader_pipeline.py index 669e6cc90..b201e0fb8 100644 --- a/python/lib/dcm2bids_imaging_pipeline_lib/dicom_archive_loader_pipeline.py +++ b/python/lib/dcm2bids_imaging_pipeline_lib/dicom_archive_loader_pipeline.py @@ -143,8 +143,10 @@ def _run_dcm2niix_conversion(self): nifti_tmp_dir = os.path.join(self.tmp_dir, "nifti_files") os.makedirs(nifti_tmp_dir) + converter = self.config_db_obj.get_config("converter") + dcm2niix_process = subprocess.Popen( - ["dcm2niix", "-ba", "n", "-z", "y", "-o", nifti_tmp_dir, self.extracted_dicom_dir], + [converter, "-ba", "n", "-z", "y", "-o", nifti_tmp_dir, self.extracted_dicom_dir], stdout=subprocess.PIPE, stderr=subprocess.STDOUT ) From b3abff498754b2977d0a723bb90e40c3800ff365 Mon Sep 17 00:00:00 2001 From: cmadjar Date: Wed, 2 Nov 2022 13:00:14 -0400 Subject: [PATCH 2/2] add a check to make sure the converter is a dcm2niix binary --- .../dicom_archive_loader_pipeline.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/python/lib/dcm2bids_imaging_pipeline_lib/dicom_archive_loader_pipeline.py b/python/lib/dcm2bids_imaging_pipeline_lib/dicom_archive_loader_pipeline.py index b201e0fb8..9305599b9 100644 --- a/python/lib/dcm2bids_imaging_pipeline_lib/dicom_archive_loader_pipeline.py +++ b/python/lib/dcm2bids_imaging_pipeline_lib/dicom_archive_loader_pipeline.py @@ -144,6 +144,9 @@ def _run_dcm2niix_conversion(self): os.makedirs(nifti_tmp_dir) converter = self.config_db_obj.get_config("converter") + if not re.search('.*dcm2niix.*', converter, re.IGNORECASE): + message = f"{converter} does not appear to be a dcm2niix binary." + self.log_error_and_exit(message, lib.exitcode.PROJECT_CUSTOMIZATION_FAILURE, is_error="Y", is_verbose="N") dcm2niix_process = subprocess.Popen( [converter, "-ba", "n", "-z", "y", "-o", nifti_tmp_dir, self.extracted_dicom_dir],