Skip to content

Commit ff7b107

Browse files
committed
Add --directory-only to dicomfind, dicompull
This option allows these tools to explicitly limit the search to whatever metadata is present in the DICOMDIR (or sqlite) file. Ideally, the default behavior (only go to files for metadata not present in the DICOMDIR) would be adequate, but vtkDICOMDirectory seems to have a bug that causes it to scan the files unnecessarily, and I haven't yet tracked down that bug.
1 parent 2e9e827 commit ff7b107

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

Programs/dicomfind.cxx

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ void dicomfind_usage(FILE *file, const char *cp)
7878
" -exec ... %s Execute the given command for every file matched.\n"
7979
" -execdir ... + Go to directory and execute command on every series.\n"
8080
" -execdir ... %s Go to directory and execute command on every file.\n"
81+
" --directory-only Do not scan files themselves if DICOMDIR is present.\n"
8182
" --ignore-dicomdir Ignore the DICOMDIR file even if it is present.\n"
8283
" --charset <cs> Charset to use if SpecificCharacterSet is missing.\n"
8384
" --help Print a brief help message.\n"
@@ -569,6 +570,7 @@ int MAINMACRO(int argc, char *argv[])
569570
QueryTagList qtlist;
570571
vtkDICOMItem query;
571572
bool followSymlinks = true;
573+
bool onlyDicomdir = false;
572574
bool ignoreDicomdir = false;
573575
bool requirePixelData = false;
574576
bool findSeries = false;
@@ -714,6 +716,10 @@ int MAINMACRO(int argc, char *argv[])
714716
}
715717
argi = argj;
716718
}
719+
else if (strcmp(arg, "--directory-only") == 0)
720+
{
721+
onlyDicomdir = true;
722+
}
717723
else if (strcmp(arg, "--ignore-dicomdir") == 0)
718724
{
719725
ignoreDicomdir = true;
@@ -767,6 +773,10 @@ int MAINMACRO(int argc, char *argv[])
767773
finder->SetScanDepth(scandepth);
768774
finder->SetFindQuery(query);
769775
finder->SetIgnoreDicomdir(ignoreDicomdir);
776+
if (onlyDicomdir)
777+
{
778+
finder->SetQueryFilesToNever();
779+
}
770780
finder->SetFollowSymlinks(followSymlinks);
771781
finder->SetRequirePixelData(requirePixelData);
772782
finder->SetFindLevel(

Programs/dicompull.cxx

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ void dicompull_usage(FILE *file, const char *cp)
6767
" -name pattern Set file names to match (with \"*\" or \"?\").\n"
6868
" -image Restrict the search to files with PixelData.\n"
6969
" -series Find all files in series if even one file matches.\n"
70+
" --directory-only Do not scan files for search if DICOMDIR is present.\n"
7071
" --ignore-dicomdir Ignore the DICOMDIR file even if it is present.\n"
7172
" --charset <cs> Charset to use if SpecificCharacterSet is missing.\n"
7273
" --silent Do not report any progress information.\n"
@@ -307,6 +308,7 @@ int MAINMACRO(int argc, char *argv[])
307308
vtkDICOMItem query;
308309
bool requirePixelData = false;
309310
bool findSeries = false;
311+
bool onlyDicomdir = false;
310312
bool ignoreDicomdir = false;
311313
vtkDICOMCharacterSet charset;
312314
bool silent = false;
@@ -433,6 +435,10 @@ int MAINMACRO(int argc, char *argv[])
433435
{
434436
findSeries = true;
435437
}
438+
else if (strcmp(arg, "--directory-only") == 0)
439+
{
440+
onlyDicomdir = true;
441+
}
436442
else if (strcmp(arg, "--ignore-dicomdir") == 0)
437443
{
438444
ignoreDicomdir = true;
@@ -551,6 +557,10 @@ int MAINMACRO(int argc, char *argv[])
551557
finder->SetScanDepth(scandepth);
552558
finder->SetFindQuery(query);
553559
finder->SetIgnoreDicomdir(ignoreDicomdir);
560+
if (onlyDicomdir)
561+
{
562+
finder->SetQueryFilesToNever();
563+
}
554564
finder->SetFollowSymlinks(followSymlinks);
555565
finder->SetRequirePixelData(requirePixelData);
556566
finder->SetFindLevel(

0 commit comments

Comments
 (0)