From ccba52a89ed103ca94c0a6be57581586676c2c3f Mon Sep 17 00:00:00 2001 From: Chris Rorden Date: Tue, 26 Dec 2017 13:25:28 -0500 Subject: [PATCH] Faster conversion when opts.numSeries != 0 --- README.md | 1 + console/main_console.cpp | 3 +-- console/nii_dicom_batch.cpp | 14 +++++--------- 3 files changed, 7 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 6b768bf9..d1f42ece 100644 --- a/README.md +++ b/README.md @@ -71,6 +71,7 @@ If you have any problems with the cmake build script described above or want to - [divest](https://github.com/jonclayden/divest) R interface to dcm2niix. - [sci-tran dcm2niix](https://github.com/scitran-apps/dcm2niix) docker. - [neuro_docker](https://github.com/Neurita/neuro_docker) includes dcm2niix as part of a single, static Dockerfile. + - [https://github.com/lalet/boutiques-dcm2niix boutiques-dcm2niix] is a dockerfile for installing and validating dcm2niix. - [neurodocker](https://github.com/kaczmarj/neurodocker) generates [custom](https://github.com/rordenlab/dcm2niix/issues/138) Dockerfiles given specific versions of neuroimaging software. - [dcm2niix_afni](https://afni.nimh.nih.gov/pub/dist/doc/program_help/dcm2niix_afni.html) is a version of dcm2niix included with the [AFNI](https://afni.nimh.nih.gov/) distribution. - [MRIcroGL](https://github.com/neurolabusc/MRIcroGL) is available for MacOS, Linux and Windows and provides a graphical interface for dcm2niix. You can get compiled copies from the [MRIcroGL NITRC web site](https://www.nitrc.org/projects/mricrogl/). \ No newline at end of file diff --git a/console/main_console.cpp b/console/main_console.cpp index 59e12d88..a784d2dd 100644 --- a/console/main_console.cpp +++ b/console/main_console.cpp @@ -297,7 +297,7 @@ int main(int argc, const char * argv[]) opts.isCreateText = true; #if !defined(_WIN64) && !defined(_WIN32) //shell script for Unix only } else if (argv[i][1] == 'u') { - checkUpToDate(); + return checkUpToDate(); #endif } else if ((argv[i][1] == 'v') && ((i+1) < argc)) { i++; @@ -340,7 +340,6 @@ int main(int argc, const char * argv[]) if (seriesNumber < 0) opts.numSeries = -1; //report series: convert none else if ((opts.numSeries >= 0) && (opts.numSeries < MAX_NUM_SERIES)) { - opts.seriesNumber[opts.numSeries] = seriesNumber; opts.numSeries += 1; } diff --git a/console/nii_dicom_batch.cpp b/console/nii_dicom_batch.cpp index f7516184..e7df4d51 100644 --- a/console/nii_dicom_batch.cpp +++ b/console/nii_dicom_batch.cpp @@ -2477,8 +2477,12 @@ int saveDcm2Nii(int nConvert, struct TDCMsort dcmSort[],struct TDICOMdata dcmLis free(imgM); return EXIT_FAILURE; } - if (opts.numSeries < 0) { //report series but do not convert + // Prevent these DICOM files from being reused. + for(int i = 0; i < nConvert; ++i) + dcmList[dcmSort[i].indx].converted2NII = 1; + if (opts.numSeries < 0) { //report series number but do not convert printMessage("\t%d\t%s\n", dcmList[dcmSort[0].indx].seriesNum, pathoutname); + printMessage(" %s\n",nameList->str[dcmSort[0].indx]); return EXIT_SUCCESS; } checkSliceTiming(&dcmList[indx0], &dcmList[indx1]); @@ -2515,7 +2519,6 @@ int saveDcm2Nii(int nConvert, struct TDCMsort dcmSort[],struct TDICOMdata dcmLis free(imgM); return EXIT_SUCCESS; } - nii_SaveText(pathoutname, dcmList[dcmSort[0].indx], opts, &hdr0, nameList->str[indx]); int numADC = 0; int * volOrderIndex = nii_SaveDTI(pathoutname,nConvert, dcmSort, dcmList, opts, sliceDir, dti4D, &numADC); @@ -2586,20 +2589,13 @@ int saveDcm2Nii(int nConvert, struct TDCMsort dcmSort[],struct TDICOMdata dcmLis } if ((opts.isCrop) && (dcmList[indx0].is3DAcq) && (hdr0.dim[3] > 1) && (hdr0.dim[0] < 4))//for T1 scan: && (dcmList[indx0].TE < 25) returnCode = nii_saveCrop(pathoutname, hdr0, imgM,opts); //n.b. must be run AFTER nii_setOrtho()! - #ifdef HAVE_R // Note that for R, only one image should be created per series // Hence the logical OR here if (returnCode == EXIT_SUCCESS || nii_saveNII(pathoutname,hdr0,imgM,opts) == EXIT_SUCCESS) nii_saveAttributes(dcmList[dcmSort[0].indx], hdr0, opts); #endif - free(imgM); - - // Prevent these DICOM files from being reused. - for(int i = 0; i < nConvert; ++i) - dcmList[dcmSort[i].indx].converted2NII = 1; - return returnCode;//EXIT_SUCCESS; }// saveDcm2Nii()