comparison Applications/Dicomizer.cpp @ 129:806d1bb56918

cleaning up options in Dicomizer
author Sebastien Jodogne <s.jodogne@gmail.com>
date Fri, 02 Feb 2018 18:11:32 +0100
parents 7a3f4d580625
children 4f3945a2b725
comparison
equal deleted inserted replaced
128:788dd04b87f5 129:806d1bb56918
46 #include <dcmtk/dcmdata/dcuid.h> 46 #include <dcmtk/dcmdata/dcuid.h>
47 #include <dcmtk/dcmdata/dcvrobow.h> 47 #include <dcmtk/dcmdata/dcvrobow.h>
48 #include <dcmtk/dcmdata/dcvrat.h> 48 #include <dcmtk/dcmdata/dcvrat.h>
49 49
50 50
51 static const char* OPTION_COLOR = "color";
52 static const char* OPTION_COMPRESSION = "compression";
53 static const char* OPTION_DATASET = "dataset";
54 static const char* OPTION_FOLDER = "folder";
55 static const char* OPTION_FOLDER_PATTERN = "folder-pattern";
56 static const char* OPTION_HELP = "help";
57 static const char* OPTION_ICC_PROFILE = "icc-profile";
58 static const char* OPTION_IMAGED_DEPTH = "imaged-depth";
59 static const char* OPTION_IMAGED_HEIGHT = "imaged-height";
60 static const char* OPTION_IMAGED_WIDTH = "imaged-width";
61 static const char* OPTION_INPUT = "input";
62 static const char* OPTION_JPEG_QUALITY = "jpeg-quality";
63 static const char* OPTION_LEVELS = "levels";
64 static const char* OPTION_LOWER_LEVELS = "lower-levels";
65 static const char* OPTION_MAX_SIZE = "max-size";
66 static const char* OPTION_OFFSET_X = "offset-x";
67 static const char* OPTION_OFFSET_Y = "offset-y";
68 static const char* OPTION_OPENSLIDE = "openslide";
69 static const char* OPTION_OPTICAL_PATH = "optical-path";
70 static const char* OPTION_PYRAMID = "pyramid";
71 static const char* OPTION_REENCODE = "reencode";
72 static const char* OPTION_REPAINT = "repaint";
73 static const char* OPTION_SAFETY = "safety";
74 static const char* OPTION_SAMPLE_DATASET = "sample-dataset";
75 static const char* OPTION_SMOOTH = "smooth";
76 static const char* OPTION_THREADS = "threads";
77 static const char* OPTION_TILE_HEIGHT = "tile-height";
78 static const char* OPTION_TILE_WIDTH = "tile-width";
79 static const char* OPTION_VERBOSE = "verbose";
80 static const char* OPTION_VERSION = "version";
81
82
51 static void TranscodePyramid(OrthancWSI::PyramidWriterBase& target, 83 static void TranscodePyramid(OrthancWSI::PyramidWriterBase& target,
52 OrthancWSI::ITiledPyramid& source, 84 OrthancWSI::ITiledPyramid& source,
53 const OrthancWSI::DicomizerParameters& parameters) 85 const OrthancWSI::DicomizerParameters& parameters)
54 { 86 {
55 Orthanc::BagOfTasks tasks; 87 Orthanc::BagOfTasks tasks;
159 191
160 LOG(WARNING) << "Size of target tiles: " << target.GetTileWidth() << "x" << target.GetTileHeight(); 192 LOG(WARNING) << "Size of target tiles: " << target.GetTileWidth() << "x" << target.GetTileHeight();
161 193
162 if (target.GetImageCompression() == OrthancWSI::ImageCompression_Jpeg) 194 if (target.GetImageCompression() == OrthancWSI::ImageCompression_Jpeg)
163 { 195 {
164 LOG(WARNING) << "Target image compression: Jpeg with quality " << static_cast<int>(target.GetJpegQuality()); 196 LOG(WARNING) << "Target image compression: Jpeg with quality "
197 << static_cast<int>(target.GetJpegQuality());
165 target.SetJpegQuality(target.GetJpegQuality()); 198 target.SetJpegQuality(target.GetJpegQuality());
166 } 199 }
167 else 200 else
168 { 201 {
169 LOG(WARNING) << "Target image compression: " << OrthancWSI::EnumerationToString(target.GetImageCompression()); 202 LOG(WARNING) << "Target image compression: "
203 << OrthancWSI::EnumerationToString(target.GetImageCompression());
170 } 204 }
171 205
172 if (stats.GetTileWidth() % target.GetTileWidth() != 0 || 206 if (stats.GetTileWidth() % target.GetTileWidth() != 0 ||
173 stats.GetTileHeight() % target.GetTileHeight() != 0) 207 stats.GetTileHeight() % target.GetTileHeight() != 0)
174 { 208 {
175 LOG(ERROR) << "When resampling the tile size, it must be a integer divisor of the original tile size"; 209 LOG(ERROR) << "When resampling the tile size, "
210 << "it must be a integer divisor of the original tile size";
176 throw Orthanc::OrthancException(Orthanc::ErrorCode_IncompatibleImageSize); 211 throw Orthanc::OrthancException(Orthanc::ErrorCode_IncompatibleImageSize);
177 } 212 }
178 213
179 if (target.GetTileWidth() <= 16 || 214 if (target.GetTileWidth() <= 16 ||
180 target.GetTileHeight() <= 16) 215 target.GetTileHeight() <= 16)
466 char* argv[]) 501 char* argv[])
467 { 502 {
468 // Declare the supported parameters 503 // Declare the supported parameters
469 boost::program_options::options_description generic("Generic options"); 504 boost::program_options::options_description generic("Generic options");
470 generic.add_options() 505 generic.add_options()
471 ("help", "Display this help and exit") 506 (OPTION_HELP, "Display this help and exit")
472 ("version", "Output version information and exit") 507 (OPTION_VERSION, "Output version information and exit")
473 ("verbose", "Be verbose in logs") 508 (OPTION_VERBOSE, "Be verbose in logs")
474 ("threads", boost::program_options::value<int>()->default_value(parameters.GetThreadsCount()), 509 (OPTION_THREADS,
510 boost::program_options::value<int>()->default_value(parameters.GetThreadsCount()),
475 "Number of processing threads to be used") 511 "Number of processing threads to be used")
476 ("openslide", boost::program_options::value<std::string>(), 512 (OPTION_OPENSLIDE, boost::program_options::value<std::string>(),
477 "Path to the shared library of OpenSlide (not necessary if converting from standard hierarchical TIFF)") 513 "Path to the shared library of OpenSlide "
514 "(not necessary if converting from standard hierarchical TIFF)")
478 ; 515 ;
479 516
480 boost::program_options::options_description source("Options for the source image"); 517 boost::program_options::options_description source("Options for the source image");
481 source.add_options() 518 source.add_options()
482 ("dataset", boost::program_options::value<std::string>(), "Path to a JSON file containing the DICOM dataset") 519 (OPTION_DATASET, boost::program_options::value<std::string>(),
483 ("sample-dataset", "Display a minimalistic sample DICOM dataset in JSON format, then exit") 520 "Path to a JSON file containing the DICOM dataset")
484 ("reencode", boost::program_options::value<bool>(), "Whether to re-encode each tile (no transcoding, much slower) (Boolean)") 521 (OPTION_SAMPLE_DATASET,
485 ("repaint", boost::program_options::value<bool>(), "Whether to repaint the background of the image (Boolean)") 522 "Display a minimalistic sample DICOM dataset in JSON format, then exit")
486 ("color", boost::program_options::value<std::string>(), "Color of the background (e.g. \"255,0,0\")") 523 (OPTION_REENCODE, boost::program_options::value<bool>(),
524 "Whether to re-encode each tile (no transcoding, much slower) (Boolean)")
525 (OPTION_REPAINT, boost::program_options::value<bool>(),
526 "Whether to repaint the background of the image (Boolean)")
527 (OPTION_COLOR, boost::program_options::value<std::string>(),
528 "Color of the background (e.g. \"255,0,0\")")
487 ; 529 ;
488 530
489 boost::program_options::options_description pyramid("Options to construct the pyramid"); 531 boost::program_options::options_description pyramid("Options to construct the pyramid");
490 pyramid.add_options() 532 pyramid.add_options()
491 ("pyramid", boost::program_options::value<bool>()->default_value(false), 533 (OPTION_PYRAMID, boost::program_options::value<bool>()->default_value(false),
492 "Reconstruct the full pyramid (slow) (Boolean)") 534 "Reconstruct the full pyramid (slow) (Boolean)")
493 ("smooth", boost::program_options::value<bool>()->default_value(false), 535 (OPTION_SMOOTH, boost::program_options::value<bool>()->default_value(false),
494 "Apply smoothing when reconstructing the pyramid " 536 "Apply smoothing when reconstructing the pyramid "
495 "(slower, but higher quality) (Boolean)") 537 "(slower, but higher quality) (Boolean)")
496 ("levels", boost::program_options::value<int>(), "Number of levels in the target pyramid") 538 (OPTION_LEVELS, boost::program_options::value<int>(),
539 "Number of levels in the target pyramid")
497 ; 540 ;
498 541
499 boost::program_options::options_description target("Options for the target image"); 542 boost::program_options::options_description target("Options for the target image");
500 target.add_options() 543 target.add_options()
501 ("tile-width", boost::program_options::value<int>(), "Width of the tiles in the target image") 544 (OPTION_TILE_WIDTH, boost::program_options::value<int>(),
502 ("tile-height", boost::program_options::value<int>(), "Height of the tiles in the target image") 545 "Width of the tiles in the target image")
503 ("compression", boost::program_options::value<std::string>(), 546 (OPTION_TILE_HEIGHT, boost::program_options::value<int>(),
547 "Height of the tiles in the target image")
548 (OPTION_COMPRESSION, boost::program_options::value<std::string>(),
504 "Compression of the target image (\"none\", \"jpeg\" or \"jpeg2000\")") 549 "Compression of the target image (\"none\", \"jpeg\" or \"jpeg2000\")")
505 ("jpeg-quality", boost::program_options::value<int>(), "Set quality level for JPEG (0..100)") 550 (OPTION_JPEG_QUALITY, boost::program_options::value<int>(),
506 ("max-size", boost::program_options::value<int>()->default_value(10), "Maximum size per DICOM instance (in MB), 0 means no limit on the file size") 551 "Set quality level for JPEG (0..100)")
507 ("folder", boost::program_options::value<std::string>(), 552 (OPTION_MAX_SIZE, boost::program_options::value<int>()->default_value(10),
553 "Maximum size per DICOM instance (in MB), 0 means no limit on the file size")
554 (OPTION_FOLDER, boost::program_options::value<std::string>(),
508 "Folder where to store the output DICOM instances") 555 "Folder where to store the output DICOM instances")
509 ("folder-pattern", boost::program_options::value<std::string>()->default_value("wsi-%06d.dcm"), 556 (OPTION_FOLDER_PATTERN,
557 boost::program_options::value<std::string>()->default_value("wsi-%06d.dcm"),
510 "Pattern for the files in the output folder") 558 "Pattern for the files in the output folder")
511 ("orthanc", boost::program_options::value<std::string>()->default_value("http://localhost:8042/"), 559 ("orthanc", boost::program_options::value<std::string>()->default_value("http://localhost:8042/"),
512 "URL to the REST API of the target Orthanc server") 560 "URL to the REST API of the target Orthanc server")
513 ; 561 ;
514 562
515 boost::program_options::options_description volumeOptions("Description of the imaged volume"); 563 boost::program_options::options_description volumeOptions("Description of the imaged volume");
516 volumeOptions.add_options() 564 volumeOptions.add_options()
517 ("imaged-width", boost::program_options::value<float>()->default_value(15), "With of the specimen (in mm)") 565 (OPTION_IMAGED_WIDTH, boost::program_options::value<float>()->default_value(15),
518 ("imaged-height", boost::program_options::value<float>()->default_value(15), "Height of the specimen (in mm)") 566 "Width of the specimen (in mm)")
519 ("imaged-depth", boost::program_options::value<float>()->default_value(1), "Depth of the specimen (in mm)") 567 (OPTION_IMAGED_HEIGHT, boost::program_options::value<float>()->default_value(15),
520 ("offset-x", boost::program_options::value<float>()->default_value(20), 568 "Height of the specimen (in mm)")
569 (OPTION_IMAGED_DEPTH, boost::program_options::value<float>()->default_value(1),
570 "Depth of the specimen (in mm)")
571 (OPTION_OFFSET_X, boost::program_options::value<float>()->default_value(20),
521 "X offset the specimen, wrt. slide coordinates origin (in mm)") 572 "X offset the specimen, wrt. slide coordinates origin (in mm)")
522 ("offset-y", boost::program_options::value<float>()->default_value(40), 573 (OPTION_OFFSET_Y, boost::program_options::value<float>()->default_value(40),
523 "Y offset the specimen, wrt. slide coordinates origin (in mm)") 574 "Y offset the specimen, wrt. slide coordinates origin (in mm)")
524 ; 575 ;
525 576
526 boost::program_options::options_description restOptions("HTTP/HTTPS client configuration to access the Orthanc REST API"); 577 boost::program_options::options_description restOptions
578 ("HTTP/HTTPS client configuration to access the Orthanc REST API");
527 OrthancWSI::ApplicationToolbox::AddRestApiOptions(restOptions); 579 OrthancWSI::ApplicationToolbox::AddRestApiOptions(restOptions);
528 580
529 boost::program_options::options_description advancedOptions("Advanced options"); 581 boost::program_options::options_description advancedOptions("Advanced options");
530 advancedOptions.add_options() 582 advancedOptions.add_options()
531 ("optical-path", boost::program_options::value<std::string>()->default_value("brightfield"), 583 (OPTION_OPTICAL_PATH, boost::program_options::value<std::string>()->default_value("brightfield"),
532 "Optical path to be automatically added to the DICOM dataset (\"none\" or \"brightfield\")") 584 "Optical path to be automatically added to the DICOM dataset (\"none\" or \"brightfield\")")
533 ("icc-profile", boost::program_options::value<std::string>(), 585 (OPTION_ICC_PROFILE, boost::program_options::value<std::string>(),
534 "Path to the ICC profile to be included. If empty, a default sRGB profile will be added.") 586 "Path to the ICC profile to be included. If empty, a default sRGB profile will be added.")
535 ("safety", boost::program_options::value<bool>()->default_value(true), 587 (OPTION_SAFETY, boost::program_options::value<bool>()->default_value(true),
536 "Whether to do additional checks to verify the source image is supported (might slow down) (Boolean)") 588 "Whether to do additional checks to verify the source image is supported (might slow down) (Boolean)")
537 ("lower-levels", boost::program_options::value<int>(), "Number of pyramid levels up to which multithreading " 589 (OPTION_LOWER_LEVELS, boost::program_options::value<int>(),
590 "Number of pyramid levels up to which multithreading "
538 "should be applied (only for performance/memory tuning)") 591 "should be applied (only for performance/memory tuning)")
539 ; 592 ;
540 593
541 boost::program_options::options_description hidden; 594 boost::program_options::options_description hidden;
542 hidden.add_options() 595 hidden.add_options()
543 ("input", boost::program_options::value<std::string>(), "Input file"); 596 (OPTION_INPUT, boost::program_options::value<std::string>(),
597 "Input file");
544 ; 598 ;
545 599
546 boost::program_options::options_description allWithoutHidden; 600 boost::program_options::options_description allWithoutHidden;
547 allWithoutHidden 601 allWithoutHidden
548 .add(generic) 602 .add(generic)
555 609
556 boost::program_options::options_description all = allWithoutHidden; 610 boost::program_options::options_description all = allWithoutHidden;
557 all.add(hidden); 611 all.add(hidden);
558 612
559 boost::program_options::positional_options_description positional; 613 boost::program_options::positional_options_description positional;
560 positional.add("input", 1); 614 positional.add(OPTION_INPUT, 1);
561 615
562 boost::program_options::variables_map options; 616 boost::program_options::variables_map options;
563 bool error = false; 617 bool error = false;
564 618
565 try 619 try
573 LOG(ERROR) << "Error while parsing the command-line arguments: " << e.what(); 627 LOG(ERROR) << "Error while parsing the command-line arguments: " << e.what();
574 error = true; 628 error = true;
575 } 629 }
576 630
577 if (!error && 631 if (!error &&
578 options.count("sample-dataset")) 632 options.count(OPTION_SAMPLE_DATASET))
579 { 633 {
580 std::string sample; 634 std::string sample;
581 Orthanc::EmbeddedResources::GetFileResource(sample, Orthanc::EmbeddedResources::SAMPLE_DATASET); 635 Orthanc::EmbeddedResources::GetFileResource(sample, Orthanc::EmbeddedResources::SAMPLE_DATASET);
582 636
583 std::cout << std::endl << sample << std::endl; 637 std::cout << std::endl << sample << std::endl;
584 638
585 return false; 639 return false;
586 } 640 }
587 641
588 if (!error && 642 if (!error &&
589 options.count("help") == 0 && 643 options.count(OPTION_HELP) == 0 &&
590 options.count("version") == 0 && 644 options.count(OPTION_VERSION) == 0 &&
591 options.count("input") != 1) 645 options.count(OPTION_INPUT) != 1)
592 { 646 {
593 LOG(ERROR) << "No input file was specified"; 647 LOG(ERROR) << "No input file was specified";
594 error = true; 648 error = true;
595 } 649 }
596 650
597 if (error || options.count("help")) 651 if (error || options.count(OPTION_HELP))
598 { 652 {
599 std::cout << std::endl 653 std::cout << std::endl
600 << "Usage: " << argv[0] << " [OPTION]... [INPUT]" 654 << "Usage: " << argv[0] << " [OPTION]... [INPUT]"
601 << std::endl 655 << std::endl
602 << "Orthanc, lightweight, RESTful DICOM server for healthcare and medical research." 656 << "Orthanc, lightweight, RESTful DICOM server for healthcare and medical research."
612 } 666 }
613 667
614 return false; 668 return false;
615 } 669 }
616 670
617 if (options.count("version")) 671 if (options.count(OPTION_VERSION))
618 { 672 {
619 OrthancWSI::ApplicationToolbox::PrintVersion(argv[0]); 673 OrthancWSI::ApplicationToolbox::PrintVersion(argv[0]);
620 return false; 674 return false;
621 } 675 }
622 676
623 if (options.count("verbose")) 677 if (options.count(OPTION_VERBOSE))
624 { 678 {
625 Orthanc::Logging::EnableInfoLevel(true); 679 Orthanc::Logging::EnableInfoLevel(true);
626 } 680 }
627 681
628 if (options.count("openslide")) 682 if (options.count(OPTION_OPENSLIDE))
629 { 683 {
630 OrthancWSI::OpenSlideLibrary::Initialize(options["openslide"].as<std::string>()); 684 OrthancWSI::OpenSlideLibrary::Initialize(options[OPTION_OPENSLIDE].as<std::string>());
631 } 685 }
632 686
633 if (options.count("pyramid") && 687 if (options.count(OPTION_PYRAMID) &&
634 options["pyramid"].as<bool>()) 688 options[OPTION_PYRAMID].as<bool>())
635 { 689 {
636 parameters.SetReconstructPyramid(true); 690 parameters.SetReconstructPyramid(true);
637 } 691 }
638 692
639 if (options.count("smooth") && 693 if (options.count(OPTION_SMOOTH) &&
640 options["smooth"].as<bool>()) 694 options[OPTION_SMOOTH].as<bool>())
641 { 695 {
642 parameters.SetSmoothEnabled(true); 696 parameters.SetSmoothEnabled(true);
643 } 697 }
644 698
645 if (options.count("safety") && 699 if (options.count(OPTION_SAFETY) &&
646 options["safety"].as<bool>()) 700 options[OPTION_SAFETY].as<bool>())
647 { 701 {
648 parameters.SetSafetyCheck(true); 702 parameters.SetSafetyCheck(true);
649 } 703 }
650 704
651 if (options.count("reencode") && 705 if (options.count(OPTION_REENCODE) &&
652 options["reencode"].as<bool>()) 706 options[OPTION_REENCODE].as<bool>())
653 { 707 {
654 parameters.SetForceReencode(true); 708 parameters.SetForceReencode(true);
655 } 709 }
656 710
657 if (options.count("repaint") && 711 if (options.count(OPTION_REPAINT) &&
658 options["repaint"].as<bool>()) 712 options[OPTION_REPAINT].as<bool>())
659 { 713 {
660 parameters.SetRepaintBackground(true); 714 parameters.SetRepaintBackground(true);
661 } 715 }
662 716
663 if (options.count("tile-width") || 717 if (options.count(OPTION_TILE_WIDTH) ||
664 options.count("tile-height")) 718 options.count(OPTION_TILE_HEIGHT))
665 { 719 {
666 int w = 0; 720 int w = 0;
667 if (options.count("tile-width")) 721 if (options.count(OPTION_TILE_WIDTH))
668 { 722 {
669 w = options["tile-width"].as<int>(); 723 w = options[OPTION_TILE_WIDTH].as<int>();
670 } 724 }
671 725
672 unsigned int h = 0; 726 unsigned int h = 0;
673 if (options.count("tile-height")) 727 if (options.count(OPTION_TILE_HEIGHT))
674 { 728 {
675 h = options["tile-height"].as<int>(); 729 h = options[OPTION_TILE_HEIGHT].as<int>();
676 } 730 }
677 731
678 if (w < 0 || h < 0) 732 if (w < 0 || h < 0)
679 { 733 {
680 LOG(ERROR) << "Negative target tile size specified: " << w << "x" << h; 734 LOG(ERROR) << "Negative target tile size specified: " << w << "x" << h;
682 } 736 }
683 737
684 parameters.SetTargetTileSize(w, h); 738 parameters.SetTargetTileSize(w, h);
685 } 739 }
686 740
687 parameters.SetInputFile(options["input"].as<std::string>()); 741 parameters.SetInputFile(options[OPTION_INPUT].as<std::string>());
688 742
689 if (options.count("color")) 743 if (options.count(OPTION_COLOR))
690 { 744 {
691 uint8_t r, g, b; 745 uint8_t r, g, b;
692 OrthancWSI::ApplicationToolbox::ParseColor(r, g, b, options["color"].as<std::string>()); 746 OrthancWSI::ApplicationToolbox::ParseColor(r, g, b, options[OPTION_COLOR].as<std::string>());
693 parameters.SetBackgroundColor(r, g, b); 747 parameters.SetBackgroundColor(r, g, b);
694 } 748 }
695 749
696 if (options.count("compression")) 750 if (options.count(OPTION_COMPRESSION))
697 { 751 {
698 std::string s = options["compression"].as<std::string>(); 752 std::string s = options[OPTION_COMPRESSION].as<std::string>();
699 if (s == "none") 753 if (s == "none")
700 { 754 {
701 parameters.SetTargetCompression(OrthancWSI::ImageCompression_None); 755 parameters.SetTargetCompression(OrthancWSI::ImageCompression_None);
702 } 756 }
703 else if (s == "jpeg") 757 else if (s == "jpeg")
713 LOG(ERROR) << "Unknown image compression for the target image: " << s; 767 LOG(ERROR) << "Unknown image compression for the target image: " << s;
714 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange); 768 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange);
715 } 769 }
716 } 770 }
717 771
718 if (options.count("jpeg-quality")) 772 if (options.count(OPTION_JPEG_QUALITY))
719 { 773 {
720 parameters.SetJpegQuality(options["jpeg-quality"].as<int>()); 774 parameters.SetJpegQuality(options[OPTION_JPEG_QUALITY].as<int>());
721 } 775 }
722 776
723 if (options.count("levels")) 777 if (options.count(OPTION_LEVELS))
724 { 778 {
725 parameters.SetPyramidLevelsCount(options["levels"].as<int>()); 779 parameters.SetPyramidLevelsCount(options[OPTION_LEVELS].as<int>());
726 } 780 }
727 781
728 if (options.count("lower-levels")) 782 if (options.count(OPTION_LOWER_LEVELS))
729 { 783 {
730 parameters.SetPyramidLowerLevelsCount(options["lower-levels"].as<int>()); 784 parameters.SetPyramidLowerLevelsCount(options[OPTION_LOWER_LEVELS].as<int>());
731 } 785 }
732 786
733 if (options.count("threads")) 787 if (options.count(OPTION_THREADS))
734 { 788 {
735 parameters.SetThreadsCount(options["threads"].as<int>()); 789 parameters.SetThreadsCount(options[OPTION_THREADS].as<int>());
736 } 790 }
737 791
738 if (options.count("max-size")) 792 if (options.count(OPTION_MAX_SIZE))
739 { 793 {
740 parameters.SetDicomMaxFileSize(options["max-size"].as<int>() * 1024 * 1024); 794 parameters.SetDicomMaxFileSize(options[OPTION_MAX_SIZE].as<int>() * 1024 * 1024);
741 } 795 }
742 796
743 if (options.count("folder")) 797 if (options.count(OPTION_FOLDER))
744 { 798 {
745 parameters.SetTargetFolder(options["folder"].as<std::string>()); 799 parameters.SetTargetFolder(options[OPTION_FOLDER].as<std::string>());
746 } 800 }
747 801
748 if (options.count("folder-pattern")) 802 if (options.count(OPTION_FOLDER_PATTERN))
749 { 803 {
750 parameters.SetTargetFolderPattern(options["folder-pattern"].as<std::string>()); 804 parameters.SetTargetFolderPattern(options[OPTION_FOLDER_PATTERN].as<std::string>());
751 } 805 }
752 806
753 OrthancWSI::ApplicationToolbox::SetupRestApi(parameters.GetOrthancParameters(), options); 807 OrthancWSI::ApplicationToolbox::SetupRestApi(parameters.GetOrthancParameters(), options);
754 808
755 if (options.count("dataset")) 809 if (options.count(OPTION_DATASET))
756 { 810 {
757 parameters.SetDatasetPath(options["dataset"].as<std::string>()); 811 parameters.SetDatasetPath(options[OPTION_DATASET].as<std::string>());
758 } 812 }
759 813
760 if (options.count("imaged-width")) 814 if (options.count(OPTION_IMAGED_WIDTH))
761 { 815 {
762 volume.SetWidth(options["imaged-width"].as<float>()); 816 volume.SetWidth(options[OPTION_IMAGED_WIDTH].as<float>());
763 } 817 }
764 818
765 if (options.count("imaged-height")) 819 if (options.count(OPTION_IMAGED_HEIGHT))
766 { 820 {
767 volume.SetHeight(options["imaged-height"].as<float>()); 821 volume.SetHeight(options[OPTION_IMAGED_HEIGHT].as<float>());
768 } 822 }
769 823
770 if (options.count("imaged-depth")) 824 if (options.count(OPTION_IMAGED_DEPTH))
771 { 825 {
772 volume.SetDepth(options["imaged-depth"].as<float>()); 826 volume.SetDepth(options[OPTION_IMAGED_DEPTH].as<float>());
773 } 827 }
774 828
775 if (options.count("offset-x")) 829 if (options.count(OPTION_OFFSET_X))
776 { 830 {
777 volume.SetOffsetX(options["offset-x"].as<float>()); 831 volume.SetOffsetX(options[OPTION_OFFSET_X].as<float>());
778 } 832 }
779 833
780 if (options.count("offset-y")) 834 if (options.count(OPTION_OFFSET_Y))
781 { 835 {
782 volume.SetOffsetY(options["offset-y"].as<float>()); 836 volume.SetOffsetY(options[OPTION_OFFSET_Y].as<float>());
783 } 837 }
784 838
785 if (options.count("optical-path")) 839 if (options.count(OPTION_OPTICAL_PATH))
786 { 840 {
787 std::string s = options["optical-path"].as<std::string>(); 841 std::string s = options[OPTION_OPTICAL_PATH].as<std::string>();
788 if (s == "none") 842 if (s == "none")
789 { 843 {
790 parameters.SetOpticalPath(OrthancWSI::OpticalPath_None); 844 parameters.SetOpticalPath(OrthancWSI::OpticalPath_None);
791 } 845 }
792 else if (s == "brightfield") 846 else if (s == "brightfield")
798 LOG(ERROR) << "Unknown optical path definition: " << s; 852 LOG(ERROR) << "Unknown optical path definition: " << s;
799 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange); 853 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange);
800 } 854 }
801 } 855 }
802 856
803 if (options.count("icc-profile")) 857 if (options.count(OPTION_ICC_PROFILE))
804 { 858 {
805 parameters.SetIccProfilePath(options["icc-profile"].as<std::string>()); 859 parameters.SetIccProfilePath(options[OPTION_ICC_PROFILE].as<std::string>());
806 } 860 }
807 861
808 return true; 862 return true;
809 } 863 }
810 864