comparison Applications/Dicomizer.cpp @ 289:5f783bf882fe

add warning about anisotropic pixel spacing
author Sebastien Jodogne <s.jodogne@gmail.com>
date Thu, 13 Jul 2023 12:49:50 +0200
parents ea08ace91b81
children fa734a851551
comparison
equal deleted inserted replaced
288:a1efc5c39615 289:5f783bf882fe
642 ; 642 ;
643 643
644 boost::program_options::options_description volumeOptions("Description of the imaged volume"); 644 boost::program_options::options_description volumeOptions("Description of the imaged volume");
645 volumeOptions.add_options() 645 volumeOptions.add_options()
646 (OPTION_IMAGED_WIDTH, boost::program_options::value<float>(), 646 (OPTION_IMAGED_WIDTH, boost::program_options::value<float>(),
647 "Width of the specimen (in mm), defaults to 15mm if missing") 647 "Width of the specimen (in mm), in the coordinate system of the glass slide, defaults to 15mm if missing")
648 (OPTION_IMAGED_HEIGHT, boost::program_options::value<float>(), 648 (OPTION_IMAGED_HEIGHT, boost::program_options::value<float>(),
649 "Height of the specimen (in mm), defaults to 15mm if missing") 649 "Height of the specimen (in mm), in the coordinate system of the glass slide, defaults to 15mm if missing")
650 (OPTION_IMAGED_DEPTH, boost::program_options::value<float>()->default_value(1), 650 (OPTION_IMAGED_DEPTH, boost::program_options::value<float>()->default_value(1),
651 "Depth of the specimen (in mm)") 651 "Depth of the specimen (in mm)")
652 (OPTION_OFFSET_X, boost::program_options::value<float>()->default_value(20), 652 (OPTION_OFFSET_X, boost::program_options::value<float>()->default_value(20),
653 "X offset the specimen, wrt. slide coordinates origin (in mm)") 653 "X offset the specimen, wrt. slide coordinates origin (in mm)")
654 (OPTION_OFFSET_Y, boost::program_options::value<float>()->default_value(40), 654 (OPTION_OFFSET_Y, boost::program_options::value<float>()->default_value(40),
1125 if (source.get() == NULL) 1125 if (source.get() == NULL)
1126 { 1126 {
1127 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadFileFormat); 1127 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadFileFormat);
1128 } 1128 }
1129 1129
1130 // In the 2 lines below, remember to switch X/Y when going from physical to pixel coordinates!
1131 float pixelSpacingX = volume.GetWidth() / static_cast<float>(source->GetLevelHeight(0));
1132 float pixelSpacingY = volume.GetHeight() / static_cast<float>(source->GetLevelWidth(0));
1133 if (std::abs(pixelSpacingX - pixelSpacingY) >= 100.0f * std::numeric_limits<float>::epsilon())
1134 {
1135 LOG(WARNING) << "Your pixel spacing is different along the X and Y axes, make sure that "
1136 << "you have not inversed the --" << OPTION_IMAGED_WIDTH << " and the --"
1137 << OPTION_IMAGED_HEIGHT << " options: " << pixelSpacingX << " vs. " << pixelSpacingY;
1138 }
1139
1130 LOG(WARNING) << "Compression of the individual source tiles: " << OrthancWSI::EnumerationToString(sourceCompression); 1140 LOG(WARNING) << "Compression of the individual source tiles: " << OrthancWSI::EnumerationToString(sourceCompression);
1131 1141
1132 // Create the shared DICOM tags 1142 // Create the shared DICOM tags
1133 std::unique_ptr<DcmDataset> dataset(ParseDataset(parameters.GetDatasetPath())); 1143 std::unique_ptr<DcmDataset> dataset(ParseDataset(parameters.GetDatasetPath()));
1134 EnrichDataset(*dataset, *source, sourceCompression, parameters, volume); 1144 EnrichDataset(*dataset, *source, sourceCompression, parameters, volume);