Make layer distance changable. Refs #1.

As a side-effet, now the ordering of the layers is left-to-right rather
than right-to-left. This shouldn't matter in normal processing, but it
is interesting nonetheless.
This commit is contained in:
2018-04-09 14:32:57 +02:00
parent 8cdeefc37b
commit 1c942a7de7
5 changed files with 31 additions and 6 deletions

View File

@@ -16,6 +16,24 @@ static void check_file(const std::string& filename)
}
}
/**
* Create a boost::program_options::value for some variable.
*
* Utility method to make generating value wrappers less repetitive. This
* method automatically sets the default value to whatever the variable
* currently holds.
*
* @tparam T
* @param val Variable to be set/use as default.
* @return A value wrapper
*/
template<typename T>
inline static auto value_for(T& val)
{
return boost::program_options::value<T>(&val)
->default_value(val);
}
/**
* Parse a color string into a color array.
*
@@ -70,9 +88,10 @@ Options::Options(int argc, char * const argv[]):
("network,n", value<std::string>(&modelPath)->required(), "caffe model file for the network")
("labels,l", value<std::string>(&labelsPath), "labels file")
("means,m", value<std::string>(&meansPath), "means file")
("path-color,p", value<std::string>(), "color for paths")
("layer-opacity", value<float>(&layerTransparancy_), "Opacity for layers")
("interaction-opacity", value<float>(&interactionTransparancy_), "Opacity for interactions")
("path-color,p", value<std::string>()->default_value("#ffffff19"), "color for paths")
("layer-opacity", value_for(layerTransparancy_), "Opacity for layers")
("interaction-opacity", value_for(interactionTransparancy_), "Opacity for interactions")
("layer-distance", value_for(LAYER_X_OFFSET), "Distance between layers")
("dump,d", value<std::string>(&dumpPath), "dump convolutional images in this directory");
options_description composed = desc;

View File

@@ -236,7 +236,7 @@ void RenderingState::render(float time) const
glPushMatrix();
glTranslatef(5 * currentData->size(), 0, 0);
glTranslatef(-LAYER_X_OFFSET / 2 * currentData->size(), 0, 0);
for (auto i : Range(currentData->size())) {
glPushMatrix();

View File

@@ -1,7 +1,7 @@
#include <caffe/util/math_functions.hpp>
#include "utils.hpp"
const float fmri::LAYER_X_OFFSET = -10;
float fmri::LAYER_X_OFFSET = 10;
std::default_random_engine &fmri::rng()
{

View File

@@ -21,8 +21,10 @@ namespace fmri
/**
* The distance between layers in the visualisation.
*
* This value is set from the options parser when provided.
*/
extern const float LAYER_X_OFFSET;
extern float LAYER_X_OFFSET;
constexpr const float EPSILON = 1e-10f;

View File

@@ -98,6 +98,7 @@ private:
Gtk::FileChooserButton meansChooser;
Gtk::FileChooserButton inputChooser;
Gtk::ColorButton pathColor;
Gtk::Scale layerDistance;
Gtk::Scale layerTransparancy;
Gtk::Scale interactionTransparancy;
Gtk::Button startButton;
@@ -121,6 +122,7 @@ Launcher::Launcher()
meansChooser("Select means file"),
inputChooser("Select input directory", Gtk::FileChooserAction::FILE_CHOOSER_ACTION_SELECT_FOLDER),
pathColor(Gdk::RGBA("rgba(255, 255, 255, 0.1)")),
layerDistance(Gtk::Adjustment::create(10, 0, 100, 0, 0.1, 0)),
layerTransparancy(Gtk::Adjustment::create(1, 0, 1, 0.0, 1.f / 256)),
interactionTransparancy(Gtk::Adjustment::create(1, 0, 1, 0.0, 1.f / 256)),
startButton("Start FMRI")
@@ -157,6 +159,7 @@ Launcher::Launcher()
addRowWithLabel("Input directory", inputChooser);
addRowWithLabel("Means (optional)", meansChooser);
addRowWithLabel("Path color", pathColor);
addRowWithLabel("Layer distance", layerDistance);
addRowWithLabel("Layer transparancy", layerTransparancy);
addRowWithLabel("Interaction transparancy", interactionTransparancy);
@@ -197,6 +200,7 @@ void Launcher::start()
float_parameter(argv, "--layer-opacity", layerTransparancy.get_value());
float_parameter(argv, "--interaction-opacity", interactionTransparancy.get_value());
float_parameter(argv, "--layer-distance", layerDistance.get_value());
if (labelChooser.get_file()) {
argv.push_back(wrap_string("-l"));