-
Notifications
You must be signed in to change notification settings - Fork 97
/
Copy pathdicomfind.cxx
800 lines (728 loc) · 21.9 KB
/
dicomfind.cxx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
/*=========================================================================
Program: DICOM for VTK
Copyright (c) 2012-2024 David Gobbi
All rights reserved.
See Copyright.txt or http://dgobbi.github.io/bsd3.txt for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notice for more information.
=========================================================================*/
#include "vtkDICOMConfig.h"
#include "vtkDICOMDirectory.h"
#include "vtkDICOMMetaData.h"
#include "vtkDICOMItem.h"
#include "vtkDICOMDataElement.h"
#include "vtkDICOMMetaData.h"
// from dicomcli
#include "vtkConsoleOutputWindow.h"
#include "mainmacro.h"
#include "readquery.h"
#include "vtkStringArray.h"
#include "vtkSmartPointer.h"
#ifndef _WIN32
// includes for execvp
#include <unistd.h>
#include <sys/wait.h>
#include <errno.h>
#else
// includes for spawn
#include <windows.h>
#include <process.h>
#include <errno.h>
// include for getcwd
#include <direct.h>
#endif
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <limits>
// print the version
void dicomfind_version(FILE *file, const char *cp)
{
fprintf(file, "%s %s\n", cp, DICOM_VERSION);
fprintf(file, "\n"
"Copyright (c) 2012-2024, David Gobbi.\n\n"
"This software is distributed under an open-source license. See the\n"
"Copyright.txt file that comes with the vtk-dicom source distribution.\n");
}
// print the usage
void dicomfind_usage(FILE *file, const char *cp)
{
fprintf(file, "usage:\n"
" %s [options] <directory> ...\n\n", cp);
fprintf(file, "options:\n"
" -L Follow symbolic links (default).\n"
" -P Do not follow symbolic links.\n"
" -k tag=value Provide an attribute to be queried and matched.\n"
" -q <query.txt> Provide a file to describe the find query.\n"
" -u <uids.txt> Provide a file that contains a list of UIDs.\n"
" -maxdepth n Set the maximum directory depth.\n"
" -name pattern Set a pattern to match (with \"*\" or \"?\").\n"
" -image Restrict the search to files with PixelData.\n"
" -series Find all files in series if even one file matches.\n"
" -print Print the filenames of all matched files (default).\n"
" -print0 Print the filenames with terminating null, for xargs.\n"
" -exec ... + Execute the given command for every series matched.\n"
" -exec ... %s Execute the given command for every file matched.\n"
" -execdir ... + Go to directory and execute command on every series.\n"
" -execdir ... %s Go to directory and execute command on every file.\n"
" --directory-only Do not scan files themselves if DICOMDIR is present.\n"
" --ignore-dicomdir Ignore the DICOMDIR file even if it is present.\n"
" --charset <cs> Charset to use if SpecificCharacterSet is missing.\n"
" --help Print a brief help message.\n"
" --version Print the software version.\n",
#ifndef _WIN32
"\\;", "\\;"
#else
"; ", "; "
#endif
);
}
// print the help
void dicomfind_help(FILE *file, const char *cp)
{
dicomfind_usage(file, cp);
fprintf(file, "\n"
"This command is like the UNIX \"find\" command, but for DICOM files.\n"
"\n"
"When searching for files with a specific attribute (with \"-k\"), the\n"
"tag can be in its hexadecimal form GGGG,EEEE or with its keyword form\n"
"Modality=MR. Alternatively, the tags can be listed in a query file\n"
"with the \"-q\" option (one tag per line). Attributes nested within\n"
"sequences can be specified by giving a tag path \"-k Tag1/Tag2/Tag3\".\n"
"Either a forward slash or a backslash can be used to separate the\n"
"components of the path. Private tags hould be preceded by the private\n"
"dictionary name in square brackets.\n"
"\n"
"The \"-exec\" and \"-execdir\" arguments cause dicomfind to run the\n"
"specified program on the found files. For example, to dump each file\n"
"one would use \"-exec dicomdump {} \\;\" where each instance of {} will\n"
"be replaced by a found file, and \";\" indicates the end of the args\n"
"to dicomdump. Alternately, if \"+\" is used to end the args, then the\n"
"program will be run on each DICOM series and {} will be replaced by all\n"
"files in the series. The \"-execdir\" argument is similar, except that\n"
"it runs the program from within the directory of the file (or files),\n"
"and {} is replaced by just the filenames instead of with the full paths.\n\n");
}
// remove path portion of filename
const char *dicomfind_basename(const char *filename)
{
const char *cp = filename + strlen(filename);
while (cp != filename && cp[-1] != '\\' && cp[-1] != '/') { --cp; }
return cp;
}
// get directory portion of filename
std::string dicomfind_dirname(const char *filename)
{
const char *cp = filename + strlen(filename);
while (cp != filename)
{
--cp;
if (cp[0] == '\\' || cp[0] == '/') { break; }
}
return std::string(filename, cp - filename);
}
typedef vtkDICOMVR VR;
// Execute a subprocess
#ifndef _WIN32
bool execute_command(const char *command, char *argv[])
{
// flush the output
fflush(stdout);
fflush(stderr);
// fork a new process
pid_t command_pid = fork();
if (command_pid == -1)
{
fprintf(stderr, "Unable to create subprocess: %s\n", argv[0]);
}
// if fork() returned a pid, then this is the original process
if (command_pid != 0)
{
int command_status;
while (waitpid(command_pid, &command_status, 0) == static_cast<pid_t>(-1))
{
if (errno != EINTR)
{
fprintf(stderr, "Unknown error with subprocess: %s\n", argv[0]);
return false;
}
}
if (WIFEXITED(command_status))
{
if (WEXITSTATUS(command_status) != 0)
{
fprintf(stderr, "Subprocess returned negative result: %s\n", argv[0]);
}
return true;
}
else
{
fprintf(stderr, "Abnormal subprocess termination: %s\n", argv[0]);
}
}
else if (execvp(command, argv) == -1)
{
if (errno == ENOENT)
{
fprintf(stderr, "Executable not found: %s\n", argv[0]);
}
else if (errno == ENOEXEC)
{
fprintf(stderr, "File is not executable: %s\n", argv[0]);
}
else if (errno == EACCES)
{
fprintf(stderr, "Access (permission) error: %s\n", argv[0]);
}
else if (errno == E2BIG)
{
fprintf(stderr, "Command line to long for command: %s\n", argv[0]);
}
else if (errno == ENOMEM)
{
fprintf(stderr, "Out of memory while running command: %s\n", argv[0]);
}
else if (errno == EMFILE)
{
fprintf(stderr, "No more available file handles: %s\n", argv[0]);
}
else
{
fprintf(stderr, "Unknown error while running command: %s\n", argv[0]);
}
return false;
}
return true;
}
#else
bool execute_command(const char *, char *argv[])
{
bool rval = true;
// flush the output
fflush(stdout);
fflush(stderr);
int m = 0;
while (argv[m] != 0)
{
m++;
}
wchar_t **wargv = new wchar_t *[m + 1];
for (int i = 0; i < m; i++)
{
int n = MultiByteToWideChar(CP_UTF8, 0, argv[i], -1, nullptr, 0);
wargv[i] = new wchar_t[n];
MultiByteToWideChar(CP_UTF8, 0, argv[i], -1, wargv[i], n);
}
wargv[m] = 0;
if (_wspawnvp(_P_WAIT, wargv[0], wargv) != 0)
{
if (errno == ENOENT)
{
fprintf(stderr, "Executable not found: %s\n", argv[0]);
}
else if (errno == ENOEXEC)
{
fprintf(stderr, "File is not executable: %s\n", argv[0]);
}
else if (errno == E2BIG)
{
fprintf(stderr, "Command line to long for command: %s\n", argv[0]);
}
else if (errno == ENOMEM)
{
fprintf(stderr, "Out of memory while running command: %s\n", argv[0]);
}
else
{
fprintf(stderr, "Unknown error while running command: %s\n", argv[0]);
}
rval = false;
}
for (int i = 0; i < m; i++)
{
delete [] wargv[i];
}
delete [] wargv;
return rval;
}
#endif
#ifndef _WIN32
int dicomfind_chdir(const char *dirname)
{
return chdir(dirname);
}
#else
int dicomfind_chdir(const char *dirname)
{
// use _wchdir to allow paths longer than the 260 char limit
int n = MultiByteToWideChar(CP_UTF8, 0, dirname, -1, nullptr, 0);
wchar_t *wp = new wchar_t[n];
MultiByteToWideChar(CP_UTF8, 0, dirname, -1, wp, n);
int rval = _wchdir(wp);
delete [] wp;
return rval;
}
#endif
#ifndef _WIN32
std::string dicomfind_getcwd()
{
char buffer[2048];
return getcwd(buffer, sizeof(buffer));
}
#else
std::string dicomfind_getcwd()
{
wchar_t wbuffer[2048];
wchar_t *wp = _wgetcwd(wbuffer, sizeof(wbuffer)/sizeof(wchar_t));
int n = WideCharToMultiByte(
CP_UTF8, 0, wp, -1, nullptr, 0, nullptr, nullptr);
char *cp = new char[n];
WideCharToMultiByte(
CP_UTF8, 0, wp, -1, cp, n, nullptr, nullptr);
std::string s = cp;
delete [] cp;
return s;
}
#endif
// The type used to store an operation
struct Operation
{
Operation(const char *type) : Type(type) {}
std::string Type;
std::vector<std::string> Args;
};
// Apply the given operations to the given list of files
void dicomfind_operations(
std::vector<Operation>& operationList, vtkStringArray *sa,
const std::string& originalDir)
{
for (std::vector<Operation>::iterator op = operationList.begin();
op != operationList.end();
++op)
{
if (op->Type == "-print" || op->Type == "-print0")
{
char endchar = (op->Type == "-print0" ? '\0' : '\n');
for (int kk = 0; kk < sa->GetNumberOfValues(); kk++)
{
fprintf(stdout, "%s", sa->GetValue(kk).c_str());
fputc(endchar, stdout);
}
fflush(stdout);
}
else if (op->Type == "-exec" || op->Type == "-execdir")
{
bool execdir = (op->Type == "-execdir");
// Count the number of times {} appears in exec args
size_t subcount = 0;
for (size_t jj = 0; jj < op->Args.size(); jj++)
{
subcount += (op->Args[jj].find("{}") != std::string::npos);
}
// remember the current subdirectory
std::string currentSubdir;
if (op->Args.back() == ";")
{
// call program for each file
for (int kk = 0; kk < sa->GetNumberOfValues(); kk++)
{
size_t sub_argc = op->Args.size() + subcount - 1;
char **sub_argv = new char *[sub_argc+1];
std::vector<std::string> temp_args(subcount);
size_t subc = 0;
size_t ii = 0;
size_t nn = op->Args.size()-1;
for (size_t jj = 0; jj < nn; jj++)
{
const std::string& arg = op->Args[jj];
size_t pos = arg.find("{}");
if (pos != std::string::npos)
{
const char *sub = sa->GetValue(kk).c_str();
if (execdir)
{
sub = dicomfind_basename(sub);
}
std::string& temp_arg = temp_args[subc++];
temp_arg = arg;
do
{
temp_arg.replace(pos, 2, sub);
pos = temp_arg.find("{}", pos + strlen(sub));
}
while (pos != std::string::npos);
sub_argv[ii++] = const_cast<char *>(temp_arg.c_str());
}
else
{
sub_argv[ii++] = const_cast<char *>(arg.c_str());
}
}
sub_argv[ii] = nullptr;
if (execdir)
{
std::string dirname =
dicomfind_dirname(sa->GetValue(kk).c_str());
if (dirname != currentSubdir)
{
dicomfind_chdir(originalDir.c_str());
dicomfind_chdir(dirname.c_str());
}
}
if (!execute_command(sub_argv[0], sub_argv))
{
fprintf(stderr, "failure!");
}
delete [] sub_argv;
}
if (execdir && currentSubdir != "")
{
dicomfind_chdir(originalDir.c_str());
}
}
else
{
// call program for each series
// for execdir, what if series is split across directories?
// need to call executable once per directory, using only
// the files in that directory.
size_t sub_argc = op->Args.size() +
subcount*sa->GetNumberOfTuples() - 1;
char **sub_argv = new char *[sub_argc+1];
std::vector<std::string> temp_args(subcount*sa->GetNumberOfValues());
size_t subc = 0;
// for execdir, keep a list of directories that are done
std::vector<std::string> done_dirs;
std::string doing_dir;
bool notdone = true;
while (notdone)
{
notdone = false;
if (execdir)
{
bool foundDirToProcess = false;
for (vtkIdType kk = 0; kk < sa->GetNumberOfValues(); kk++)
{
std::string dirname =
dicomfind_dirname(sa->GetValue(kk).c_str());
if (!foundDirToProcess)
{
bool dirIsDone = false;
for (size_t ll = 0; ll < done_dirs.size(); ll++)
{
if (dirname == done_dirs[ll])
{
dirIsDone = true;
break;
}
}
if (!dirIsDone)
{
foundDirToProcess = true;
doing_dir = dirname;
done_dirs.push_back(dirname);
break;
}
}
}
if (foundDirToProcess)
{
notdone = true;
}
else
{
break;
}
}
size_t ii = 0;
size_t nn = op->Args.size()-1;
for (size_t jj = 0; jj < nn; jj++)
{
const std::string& arg = op->Args[jj];
size_t pos = arg.find("{}");
if (pos != std::string::npos)
{
for (vtkIdType kk = 0; kk < sa->GetNumberOfValues(); kk++)
{
const char *sub = sa->GetValue(kk).c_str();
if (execdir)
{
std::string dirname = dicomfind_dirname(sub);
if (dirname != doing_dir)
{
continue;
}
sub = dicomfind_basename(sub);
}
std::string& temp_arg = temp_args[subc++];
temp_arg = arg;
pos = temp_arg.find("{}");
do
{
temp_arg.replace(pos, 2, sub);
pos = temp_arg.find("{}", pos + strlen(sub));
}
while (pos != std::string::npos);
sub_argv[ii++] = const_cast<char *>(temp_arg.c_str());
}
}
else
{
sub_argv[ii++] = const_cast<char *>(arg.c_str());
}
}
sub_argv[ii] = nullptr;
if (execdir)
{
if (doing_dir != currentSubdir)
{
dicomfind_chdir(originalDir.c_str());
dicomfind_chdir(doing_dir.c_str());
}
}
if (!execute_command(sub_argv[0], sub_argv))
{
fprintf(stderr, "failure!");
}
}
if (execdir && currentSubdir != "")
{
dicomfind_chdir(originalDir.c_str());
}
delete [] sub_argv;
}
}
}
}
// Delay wildcard expansion for -name option
MAINMACRO_PASSTHROUGH(-name);
// This program will dump all the metadata in the given file
int MAINMACRO(int argc, char *argv[])
{
// redirect all VTK errors to stderr
vtkConsoleOutputWindow::Install();
std::vector<Operation> operationList;
int rval = 0;
int scandepth = std::numeric_limits<int>::max();
const char *pattern = "";
QueryTagList qtlist;
vtkDICOMItem query;
bool followSymlinks = true;
bool onlyDicomdir = false;
bool ignoreDicomdir = false;
bool requirePixelData = false;
bool findSeries = false;
vtkDICOMCharacterSet charset;
vtkSmartPointer<vtkStringArray> a = vtkSmartPointer<vtkStringArray>::New();
// always query SpecificCharacterSet
query.Set(DC::SpecificCharacterSet, vtkDICOMValue(VR::CS));
// always query the functional sequences for advanced files
query.Set(DC::SharedFunctionalGroupsSequence, vtkDICOMValue(VR::SQ));
query.Set(DC::PerFrameFunctionalGroupsSequence, vtkDICOMValue(VR::SQ));
if (argc < 2)
{
dicomfind_usage(stdout, dicomfind_basename(argv[0]));
return rval;
}
else if (argc == 2 && strcmp(argv[1], "--help") == 0)
{
dicomfind_help(stdout, dicomfind_basename(argv[0]));
return rval;
}
else if (argc == 2 && strcmp(argv[1], "--version") == 0)
{
dicomfind_version(stdout, dicomfind_basename(argv[0]));
return rval;
}
for (int argi = 1; argi < argc; argi++)
{
const char *arg = argv[argi];
if (strcmp(arg, "-P") == 0)
{
followSymlinks = false;
}
else if (strcmp(arg, "-L") == 0)
{
followSymlinks = true;
}
else if (strcmp(arg, "-q") == 0)
{
if (argi + 1 == argc || argv[argi+1][0] == '-')
{
fprintf(stderr, "%s must be followed by a file.\n\n", arg);
dicomfind_usage(stderr, dicomfind_basename(argv[0]));
return 1;
}
const char *qfile = argv[++argi];
if (!dicomcli_readquery(qfile, &query, &qtlist))
{
fprintf(stderr, "Can't read query file %s\n\n", qfile);
return 1;
}
}
else if (strcmp(arg, "-u") == 0)
{
if (argi + 1 == argc || argv[argi+1][0] == '-')
{
fprintf(stderr, "Error: %s must be followed by a file.\n\n", arg);
dicomfind_usage(stderr, dicomfind_basename(argv[0]));
return 1;
}
const char *qfile = argv[++argi];
if (!dicomcli_readuids(qfile, &query, &qtlist))
{
fprintf(stderr, "Error: Can't read uid file %s\n\n", qfile);
return 1;
}
}
else if (strcmp(arg, "-k") == 0)
{
vtkDICOMTag tag;
++argi;
if (argi == argc)
{
fprintf(stderr, "%s must be followed by gggg,eeee=value "
"where gggg,eeee is a DICOM tag.\n\n", arg);
return 1;
}
if (!dicomcli_readkey(argv[argi], &query, &qtlist))
{
return 1;
}
}
else if (strcmp(arg, "-maxdepth") == 0)
{
++argi;
if (argi == argc)
{
fprintf(stderr, "%s must be followed by an argument.\n\n", arg);
return 1;
}
scandepth = static_cast<int>(atol(argv[argi]));
}
else if (strcmp(arg, "-name") == 0)
{
++argi;
if (argi == argc)
{
fprintf(stderr, "%s must be followed by an argument.\n\n", arg);
return 1;
}
pattern = argv[argi];
}
else if (strcmp(arg, "-image") == 0)
{
requirePixelData = true;
}
else if (strcmp(arg, "-series") == 0)
{
findSeries = true;
}
else if (strcmp(arg, "-print") == 0 ||
strcmp(arg, "-print0") == 0)
{
operationList.push_back(arg);
}
else if (strcmp(arg, "-exec") == 0 ||
strcmp(arg, "-execdir") == 0)
{
operationList.push_back(arg);
int argj = ++argi;
for (; argj < argc; argj++)
{
if (strcmp(argv[argj], ";") == 0 ||
strcmp(argv[argj], "+") == 0)
{
break;
}
}
if (argj == argc)
{
fprintf(stderr, "%s must be terminated with + or \\; "
"(plus or semicolon).\n\n",
arg);
return 1;
}
for (; argi <= argj; argi++)
{
operationList.back().Args.push_back(argv[argi]);
}
argi = argj;
}
else if (strcmp(arg, "--directory-only") == 0)
{
onlyDicomdir = true;
}
else if (strcmp(arg, "--ignore-dicomdir") == 0)
{
ignoreDicomdir = true;
}
else if (strcmp(arg, "--charset") == 0)
{
++argi;
if (argi == argc || argv[argi][0] == '-')
{
fprintf(stderr, "%s must be followed by a valid character set\n\n",
arg);
return 1;
}
charset = vtkDICOMCharacterSet(argv[argi]);
if (charset.GetKey() == vtkDICOMCharacterSet::Unknown)
{
fprintf(stderr, "%s %s is not a known character set\n\n",
arg, argv[argi]);
return 1;
}
}
else if (arg[0] == '-')
{
fprintf(stderr, "unrecognized option %s.\n\n", arg);
dicomfind_usage(stderr, dicomfind_basename(argv[0]));
return 1;
}
else
{
a->InsertNextValue(arg);
}
}
// if no operations were specified, default to "print"
if (operationList.empty())
{
operationList.push_back("-print");
}
// Remember the current directory
std::string originalDir = dicomfind_getcwd();
// Write data for every input directory
if (a->GetNumberOfTuples() > 0)
{
vtkSmartPointer<vtkDICOMDirectory> finder =
vtkSmartPointer<vtkDICOMDirectory>::New();
finder->SetDefaultCharacterSet(charset);
finder->SetInputFileNames(a);
finder->SetFilePattern(pattern);
finder->SetScanDepth(scandepth);
finder->SetFindQuery(query);
finder->SetIgnoreDicomdir(ignoreDicomdir);
if (onlyDicomdir)
{
finder->SetQueryFilesToNever();
}
finder->SetFollowSymlinks(followSymlinks);
finder->SetRequirePixelData(requirePixelData);
finder->SetFindLevel(
findSeries ? vtkDICOMDirectory::SERIES : vtkDICOMDirectory::IMAGE);
finder->Update();
for (int j = 0; j < finder->GetNumberOfStudies(); j++)
{
int k0 = finder->GetFirstSeriesForStudy(j);
int k1 = finder->GetLastSeriesForStudy(j);
for (int k = k0; k <= k1; k++)
{
vtkStringArray *sa = finder->GetFileNamesForSeries(k);
dicomfind_operations(operationList, sa, originalDir);
}
}
}
return rval;
}