diff --git a/console/main_console.cpp b/console/main_console.cpp index 74f326e8..b64b987d 100644 --- a/console/main_console.cpp +++ b/console/main_console.cpp @@ -104,6 +104,7 @@ void showHelp(const char *argv[], struct TDCMopts opts) { printf(" -n : only convert this series CRC number - can be used up to %i times (default convert all)\n", MAX_NUM_SERIES); printf(" -o : output directory (omit to save to input folder)\n"); printf(" -p : Philips precise float (not display) scaling (y/n, default y)\n"); + printf(" -q : only search directory for DICOMs (y/l/n, default y) [y=show number of DICOMs found, l=additionally list DICOMs found, n=no]\n"); printf(" -r : rename instead of convert DICOMs (y/n, default n)\n"); printf(" -s : single file mode, do not convert other images in folder (y/n, default n)\n"); //text notes replaced with BIDS: this function is deprecated @@ -178,7 +179,7 @@ void showHelp(const char *argv[], struct TDCMopts opts) { } //showHelp() int invalidParam(int i, const char *argv[]) { - if (strchr("yYnNoOhHiIjJBb01234",argv[i][0])) + if (strchr("yYnNoOhHiIjlLJBb01234",argv[i][0])) return 0; //if (argv[i][0] != '-') return 0; @@ -471,6 +472,14 @@ int main(int argc, const char *argv[]) { return 0; if ((argv[i][0] == 'y') || (argv[i][0] == 'Y')) opts.isRenameNotConvert = true; + } else if ((argv[i][1] == 'q') && ((i + 1) < argc)) { + i++; + if (invalidParam(i, argv)) + return 0; + if ((argv[i][0] == 'y') || (argv[i][0] == 'Y')) + opts.onlySearchDirForDICOM = 1; + else if ((argv[i][0] == 'l') || (argv[i][0] == 'L')) + opts.onlySearchDirForDICOM = 2; } else if ((argv[i][1] == 's') && ((i + 1) < argc)) { i++; if (invalidParam(i, argv)) @@ -624,11 +633,14 @@ int main(int argc, const char *argv[]) { if (ret != EXIT_SUCCESS) return ret; } + + if (opts.onlySearchDirForDICOM == 0) { #if !defined(_WIN64) && !defined(_WIN32) - printf("Conversion required %f seconds (%f for core code).\n", get_wall_time() - startWall, ((float)(clock() - start)) / CLOCKS_PER_SEC); + printf("Conversion required %f seconds (%f for core code).\n", get_wall_time() - startWall, ((float)(clock() - start)) / CLOCKS_PER_SEC); #else - printf("Conversion required %f seconds.\n", ((float)(clock() - start)) / CLOCKS_PER_SEC); + printf("Conversion required %f seconds.\n", ((float)(clock() - start)) / CLOCKS_PER_SEC); #endif + } //if (isSaveIni) //we now save defaults earlier, in case of early termination. // saveIniFile(opts); return EXIT_SUCCESS; diff --git a/console/nii_dicom_batch.cpp b/console/nii_dicom_batch.cpp index a623c510..ee9b0d5b 100644 --- a/console/nii_dicom_batch.cpp +++ b/console/nii_dicom_batch.cpp @@ -8238,6 +8238,12 @@ int nii_loadDirCore(char *indir, struct TDCMopts *opts) { } size_t nDcm = nameList.numItems; printMessage("Found %lu DICOM file(s)\n", nameList.numItems); //includes images and other non-image DICOMs + if (opts->onlySearchDirForDICOM == 2) { + printMessage("List of DICOM file(s):\n"); + for (int i = 0; i < nameList.numItems; i++) + printMessage("%s\n", nameList.str[i]); + printMessage("End of list (%lu in total)\n", nameList.numItems); + } #ifdef myTimer if (opts->isProgress > 1) printMessage("Stage 1 (Count number of DICOMs) required %f seconds.\n", ((float)(clock() - start)) / CLOCKS_PER_SEC); @@ -8294,7 +8300,7 @@ int nii_loadDirCore(char *indir, struct TDCMopts *opts) { printMessage("Stage 2 (Read DICOM headers, Convert 4D) required %f seconds.\n", ((float)(clock() - start)) / CLOCKS_PER_SEC); start = clock(); #endif - if (opts->isRenameNotConvert) { + if ((opts->isRenameNotConvert) || (opts->onlySearchDirForDICOM != 0)) { free(dcmList); free(dti4D); return EXIT_SUCCESS; @@ -8852,6 +8858,7 @@ void setDefaultOpts(struct TDCMopts *opts, const char *argv[]) { //either "setDe opts->isPipedGz = false; //e.g. pipe data directly to pigz instead of saving uncompressed to disk opts->isSave3D = false; opts->dirSearchDepth = 5; + opts->onlySearchDirForDICOM = 0; opts->isProgress = 0; opts->nameConflictBehavior = kNAME_CONFLICT_ADD_SUFFIX; #ifdef myDisableZLib diff --git a/console/nii_dicom_batch.h b/console/nii_dicom_batch.h index 0f9c88c8..22398999 100644 --- a/console/nii_dicom_batch.h +++ b/console/nii_dicom_batch.h @@ -57,7 +57,7 @@ void nii_clrMrifsStruct(); struct TDCMopts { bool isIgnoreTriggerTimes, isTestx0021x105E, isAddNamePostFixes, isSaveNativeEndian, isOneDirAtATime, isRenameNotConvert, isSave3D, isGz, isPipedGz, isFlipY, isCreateBIDS, isSortDTIbyBVal, isAnonymizeBIDS, isOnlyBIDS, isCreateText, isForceOnsetTimes,isIgnoreDerivedAnd2D, isPhilipsFloatNotDisplayScaling, isTiltCorrect, isRGBplanar, isOnlySingleFile, isForceStackDCE, isIgnoreSeriesInstanceUID, isRotate3DAcq, isCrop; - int saveFormat, isMaximize16BitRange, isForceStackSameSeries, nameConflictBehavior, isVerbose, isProgress, compressFlag, dirSearchDepth, gzLevel, diffCyclingModeGE; //support for compressed data 0=none, + int saveFormat, isMaximize16BitRange, isForceStackSameSeries, nameConflictBehavior, isVerbose, isProgress, compressFlag, dirSearchDepth, onlySearchDirForDICOM, gzLevel, diffCyclingModeGE; //support for compressed data 0=none, char filename[512], outdir[512], indir[512], pigzname[512], optsname[512], indirParent[512], imageComments[24]; double seriesNumber[MAX_NUM_SERIES]; //requires double must store -1 (report but do not convert) as well as seriesUidCrc (uint32) long numSeries;