Skip to content

Commit 8a1f9c1

Browse files
committed
Add logging of groom and optimize parameters to file log
1 parent 11e047b commit 8a1f9c1

File tree

7 files changed

+41
-1
lines changed

7 files changed

+41
-1
lines changed

Libs/Analyze/MeshGenerator.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,8 @@ MeshHandle MeshGenerator::build_mesh_from_file(std::string filename, float iso_v
165165
}
166166
} else if (is_image) {
167167
try {
168+
ImageUtils::register_itk_factories();
169+
168170
// read file using ITK
169171
using ReaderType = itk::ImageFileReader<ImageType>;
170172
ReaderType::Pointer reader = ReaderType::New();

Libs/Groom/GroomParameters.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,6 @@ class GroomParameters {
137137
bool get_skip_grooming();
138138
void set_skip_grooming(bool skip);
139139

140-
141140
bool get_shared_boundary();
142141
void set_shared_boundary(bool shared_boundary);
143142

@@ -152,6 +151,8 @@ class GroomParameters {
152151

153152
void restore_defaults();
154153

154+
Parameters get_parameters() const { return params_; }
155+
155156
// constants
156157
const static std::string GROOM_SMOOTH_VTK_LAPLACIAN_C;
157158
const static std::string GROOM_SMOOTH_VTK_WINDOWED_SINC_C;

Libs/Image/ImageUtils.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@
22

33
#include <itkPointSet.h>
44

5+
// ITK image factories
6+
#include <itkMetaImageIOFactory.h>
7+
#include <itkNiftiImageIOFactory.h>
8+
#include <itkNrrdImageIOFactory.h>
9+
510
namespace shapeworks {
611

712
PhysicalRegion ImageUtils::boundingBox(const std::vector<std::string>& filenames, Image::PixelType isoValue) {
@@ -39,6 +44,18 @@ PhysicalRegion ImageUtils::boundingBox(const std::vector<std::reference_wrapper<
3944
return bbox;
4045
}
4146

47+
void ImageUtils::register_itk_factories()
48+
{
49+
static bool registered = false;
50+
if (!registered) {
51+
// register all the factories
52+
itk::NrrdImageIOFactory::RegisterOneFactory();
53+
itk::NiftiImageIOFactory::RegisterOneFactory();
54+
itk::MetaImageIOFactory::RegisterOneFactory();
55+
registered = true;
56+
}
57+
}
58+
4259
ImageUtils::TPSTransform::Pointer ImageUtils::createWarpTransform(const std::string& source_landmarks_file,
4360
const std::string& target_landmarks_file,
4461
const int stride) {

Libs/Image/ImageUtils.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ class ImageUtils {
2222
using TPSTransform = itk::ThinPlateSplineKernelTransform<double, 3>;
2323
static TPSTransform::Pointer createWarpTransform(const std::string& source_landmarks_file,
2424
const std::string& target_landmarks_file, const int stride = 1);
25+
26+
static void register_itk_factories();
27+
2528
};
2629

2730
} // namespace shapeworks

Libs/Optimize/OptimizeParameters.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -864,3 +864,6 @@ double OptimizeParameters::get_shared_boundary_weight() { return params_.get(Key
864864

865865
//---------------------------------------------------------------------------
866866
void OptimizeParameters::set_shared_boundary_weight(double value) { params_.set(Keys::shared_boundary_weight, value); }
867+
868+
//---------------------------------------------------------------------------
869+
Parameters OptimizeParameters::get_parameters() const { return params_; }

Libs/Optimize/OptimizeParameters.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,8 @@ class OptimizeParameters {
138138
double get_shared_boundary_weight();
139139
void set_shared_boundary_weight(double value);
140140

141+
Parameters get_parameters() const;
142+
141143
private:
142144
std::string get_output_prefix();
143145

Studio/Groom/GroomTool.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -591,6 +591,18 @@ void GroomTool::on_run_groom_button_clicked() {
591591
timer_.start();
592592

593593
SW_LOG("Please wait: running groom step...");
594+
595+
// log parameters
596+
SW_LOG_ONLY("Grooming parameters:");
597+
598+
for (const auto& domain_name : session_->get_project()->get_domain_names()) {
599+
auto params = GroomParameters(session_->get_project(), domain_name);
600+
SW_LOG_ONLY("Domain: " + domain_name);
601+
for (const auto& pair : params.get_parameters().get_map()) {
602+
SW_LOG_ONLY(pair.first + ": " + pair.second);
603+
}
604+
}
605+
594606
Q_EMIT progress(0);
595607

596608
groom_ = QSharedPointer<Groom>(new Groom(session_->get_project()));

0 commit comments

Comments
 (0)