void ColorDeconvolutionFilterPlugin::updateFilterFromSettingsPanel() {
  ColorDeconvolutionFilter<double>* filter = dynamic_cast<ColorDeconvolutionFilter<double>* >(_filter.get());
  if (_settingsPanel && filter) {
    QDoubleSpinBox* stain1R = _settingsPanel->findChild<QDoubleSpinBox*>("Stain1RSpinBox");
    QDoubleSpinBox* stain1G = _settingsPanel->findChild<QDoubleSpinBox*>("Stain1GSpinBox");
    QDoubleSpinBox* stain1B = _settingsPanel->findChild<QDoubleSpinBox*>("Stain1BSpinBox");
    QDoubleSpinBox* stain2R = _settingsPanel->findChild<QDoubleSpinBox*>("Stain2RSpinBox");
    QDoubleSpinBox* stain2G = _settingsPanel->findChild<QDoubleSpinBox*>("Stain2GSpinBox");
    QDoubleSpinBox* stain2B = _settingsPanel->findChild<QDoubleSpinBox*>("Stain2BSpinBox");
    QDoubleSpinBox* stain3R = _settingsPanel->findChild<QDoubleSpinBox*>("Stain3RSpinBox");
    QDoubleSpinBox* stain3G = _settingsPanel->findChild<QDoubleSpinBox*>("Stain3GSpinBox");
    QDoubleSpinBox* stain3B = _settingsPanel->findChild<QDoubleSpinBox*>("Stain3BSpinBox");
    QDoubleSpinBox* rThreshold = _settingsPanel->findChild<QDoubleSpinBox*>("RThreshold");
    QDoubleSpinBox* gThreshold = _settingsPanel->findChild<QDoubleSpinBox*>("GThreshold");
    QDoubleSpinBox* bThreshold = _settingsPanel->findChild<QDoubleSpinBox*>("BThreshold");
    QDoubleSpinBox* globalThreshold = _settingsPanel->findChild<QDoubleSpinBox*>("GlobalThreshold");
    QComboBox* outputStain = _settingsPanel->findChild<QComboBox*>("OutputStainComboBox");
    filter->setGlobalDensityThreshold(globalThreshold->value());
    std::vector<double> rgbThresholds;
    rgbThresholds.push_back(rThreshold->value());
    rgbThresholds.push_back(gThreshold->value());
    rgbThresholds.push_back(bThreshold->value());
    filter->setRGBDensityThresholds(rgbThresholds);
    std::vector<std::vector<double> > stains(3, std::vector<double>(3, 0));
    stains[0][0] = stain1R->value();
    stains[0][1] = stain1G->value();
    stains[0][2] = stain1B->value();
    stains[1][0] = stain2R->value();
    stains[1][1] = stain2G->value();
    stains[1][2] = stain2B->value();
    stains[2][0] = stain3R->value();
    stains[2][1] = stain3G->value();
    stains[2][2] = stain3B->value();
    filter->setStain(stains[0], stains[1], stains[2]);
    filter->setOutputStain(outputStain->currentIndex());
    emit filterParametersChanged();
  }
}