From 0550be8965dd9d47e295d8c2bad27d8d02c3bf0e Mon Sep 17 00:00:00 2001 From: Isaiah Norton Date: Wed, 5 Apr 2017 14:12:05 -0400 Subject: [PATCH 1/5] BUG: check for converter factory failure --- DWIConvert/DWIConvertLib.cxx | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/DWIConvert/DWIConvertLib.cxx b/DWIConvert/DWIConvertLib.cxx index f03b6a636..84d7f5f69 100644 --- a/DWIConvert/DWIConvertLib.cxx +++ b/DWIConvert/DWIConvertLib.cxx @@ -143,7 +143,7 @@ int DWIConvert::read() std::cerr << "Invalid conversion mode" << std::endl; return EXIT_FAILURE; } - return EXIT_SUCCESS; + return (NULL == m_converter ? EXIT_FAILURE : EXIT_SUCCESS); } @@ -243,6 +243,11 @@ DWIConverter * DWIConvert::CreateDicomConverter( std::cerr << "Exception creating converter " << excp << std::endl; return ITK_NULLPTR; } + if (NULL == converter) + { + std::cerr << "Unable to create converter!" << std::endl; + return ITK_NULLPTR; + } // read Dicom directory try From 3cf1d5eb87242db08495b997ac07143c701c044e Mon Sep 17 00:00:00 2001 From: Isaiah Norton Date: Wed, 5 Apr 2017 14:23:03 -0400 Subject: [PATCH 2/5] COMP: remove unnecessary call to DCMTK loglevel Unnecessary since: https://github.com/InsightSoftwareConsortium/ITK/commit/934940b8a0909a0463c874f6c417f23dc7ef50f7 --- DWIConvert/DWIConvertLib.cxx | 1 - 1 file changed, 1 deletion(-) diff --git a/DWIConvert/DWIConvertLib.cxx b/DWIConvert/DWIConvertLib.cxx index 84d7f5f69..b445675f5 100644 --- a/DWIConvert/DWIConvertLib.cxx +++ b/DWIConvert/DWIConvertLib.cxx @@ -65,7 +65,6 @@ int DWIConvert::read() return EXIT_FAILURE; } - dcmtk::log4cplus::helpers::LogLog::getLogLog()->setQuietMode(true); // register DCMTK codecs, otherwise they will not be available when // `itkDCMTKSeriesFileNames` is used to build a list of filenames, // so reading series with JPEG transfer syntax will fail. From 244c7bf6ff55bd5c24df8e50a6d077d40a05aac2 Mon Sep 17 00:00:00 2001 From: Isaiah Norton Date: Wed, 5 Apr 2017 15:10:09 -0400 Subject: [PATCH 3/5] STYLE: clean up style --- DWIConvert/DWIConvertLib.cxx | 13 ++++++++++--- DWIConvert/DWIConvertLib.h | 5 +++-- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/DWIConvert/DWIConvertLib.cxx b/DWIConvert/DWIConvertLib.cxx index b445675f5..886c994b1 100644 --- a/DWIConvert/DWIConvertLib.cxx +++ b/DWIConvert/DWIConvertLib.cxx @@ -290,9 +290,16 @@ void DWIConvert::setInputFileType(const std::string& inputVolume, const std::str m_inputDicomDirectory = inputDicomDirectory; if (emptyString == m_inputDicomDirectory && emptyString != m_inputVolume){ const std::string inputExt = itksys::SystemTools::GetFilenameExtension(m_inputVolume); - if ( std::string::npos != inputExt.rfind(".nii")) m_inputFileType = "FSL"; - else if (std::string::npos != inputExt.rfind(".nrrd") || std::string::npos != inputExt.rfind(".nhdr")) m_inputFileType = "Nrrd"; - else { + if ( std::string::npos != inputExt.rfind(".nii")) + { + m_inputFileType = "FSL"; + } + else if (std::string::npos != inputExt.rfind(".nrrd") || std::string::npos != inputExt.rfind(".nhdr")) + { + m_inputFileType = "Nrrd"; + } + else + { std::cerr <<"Error: file type of inputVoume is not supported currently"< Date: Wed, 5 Apr 2017 15:11:30 -0400 Subject: [PATCH 4/5] ENH: prefer inputVolume over inputDicomDirectory Slicer CLI seems to always send an entry for input DicomDirectory --- DWIConvert/DWIConvertLib.cxx | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/DWIConvert/DWIConvertLib.cxx b/DWIConvert/DWIConvertLib.cxx index 886c994b1..678857b7d 100644 --- a/DWIConvert/DWIConvertLib.cxx +++ b/DWIConvert/DWIConvertLib.cxx @@ -288,7 +288,11 @@ DWIConverter * DWIConvert::CreateDicomConverter( void DWIConvert::setInputFileType(const std::string& inputVolume, const std::string& inputDicomDirectory){ m_inputVolume = inputVolume; m_inputDicomDirectory = inputDicomDirectory; - if (emptyString == m_inputDicomDirectory && emptyString != m_inputVolume){ + + // prefer the inputVolume field if available + if ( (!m_inputVolume.empty()) || + m_inputDicomDirectory.empty() ) + { const std::string inputExt = itksys::SystemTools::GetFilenameExtension(m_inputVolume); if ( std::string::npos != inputExt.rfind(".nii")) { From 45e8dc11f685bf208ecffa866bf3ef4d1c4a1801 Mon Sep 17 00:00:00 2001 From: Isaiah Norton Date: Wed, 5 Apr 2017 15:14:07 -0400 Subject: [PATCH 5/5] ENH: add optional "outputNiftiFile" parameter to allow Slicer GUI use In NrrdToFSL mode users need to specify the output Nifti path, but it is not possible to do so with the Slicer CLI diffusion-weighted node type. The CLI and generated GUI will always create a MRMLNode selector which links to a temporary NRRD file using via NRRD I/O. So add an optional outputNiftiFile parameter which can be used in the GUI. ref: http://massmail.spl.harvard.edu/public-archives/slicer-users/2017/011994.html --- DWIConvert/DWIConvert.cxx | 3 +++ DWIConvert/DWIConvert.xml | 12 ++++++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/DWIConvert/DWIConvert.cxx b/DWIConvert/DWIConvert.cxx index 471a7b3e3..fd55926cc 100644 --- a/DWIConvert/DWIConvert.cxx +++ b/DWIConvert/DWIConvert.cxx @@ -79,6 +79,9 @@ int main(int argc, char *argv[]) dWIConvert.setUseIdentityMeasurementFrame (useIdentityMeaseurementFrame); dWIConvert.setUseBMatrixGradientDirections (useBMatrixGradientDirections); + if (!outputNiftiFile.empty()) + outputVolume = outputNiftiFile; + dWIConvert.setOutputFileType(outputVolume); dWIConvert.setOutputDirectory(outputDirectory); dWIConvert.setOutputBValues(outputBValues); diff --git a/DWIConvert/DWIConvert.xml b/DWIConvert/DWIConvert.xml index 83e7a64f1..a97be018e 100755 --- a/DWIConvert/DWIConvert.xml +++ b/DWIConvert/DWIConvert.xml @@ -49,11 +49,12 @@ --inputDicomDirectory input + - + @@ -81,7 +82,14 @@ - + + + outputNiftiFile + --outputNiftiFile + + output + + outputBValues --outputBValues