Index: branches/HeuristicLab.DataImporter/HeuristicLab.DataImporter.Command/ChangeValues/FilterSavitzkyGolayCommand.cs
===================================================================
--- branches/HeuristicLab.DataImporter/HeuristicLab.DataImporter.Command/ChangeValues/FilterSavitzkyGolayCommand.cs	(revision 6682)
+++ branches/HeuristicLab.DataImporter/HeuristicLab.DataImporter.Command/ChangeValues/FilterSavitzkyGolayCommand.cs	(revision 6706)
@@ -45,4 +45,6 @@
     public int Order { get; set; }
 
+    public int OrderOfDerivative { get; set; }
+
     private FilterSavitzkyGolayCommand()
       : base(null, string.Empty, null) {
@@ -56,4 +58,5 @@
       this.WindowRight = 16;
       this.Order = 2;
+      this.OrderOfDerivative = 0;
     }
 
@@ -77,5 +80,5 @@
           column = (DoubleColumn)ColumnGroup.GetColumn(col);
           oldColumns.Add(col, column);
-          ColumnGroup.ReplaceColumn(col, CalcNewColumn(column, this.WindowLeft, this.WindowRight, this.Order));
+          ColumnGroup.ReplaceColumn(col, CalcNewColumn(column, this.WindowLeft, this.WindowRight, this.OrderOfDerivative, this.Order));
         }
       }
@@ -97,7 +100,7 @@
     }
 
-    private DoubleColumn CalcNewColumn(DoubleColumn oldColumn, int windowLeft, int windowRight, int order) {
+    private DoubleColumn CalcNewColumn(DoubleColumn oldColumn, int windowLeft, int windowRight, int derivativeOrder, int order) {
       double[] c;
-      SavitzkyGolay(Math.Abs(windowLeft), Math.Abs(windowRight), order, out c);
+      SavitzkyGolay(Math.Abs(windowLeft), Math.Abs(windowRight), derivativeOrder, order, out c);
 
       DoubleColumn newCol = (DoubleColumn)oldColumn.CreateCopyOfColumnWithoutValues();
@@ -117,30 +120,28 @@
     /// <param name="nl">number of samples to the left</param>
     /// <param name="nr">number of samples to the right</param>
-    /// <param name="m">order of the polynomial to fit</param>
+    /// <param name="ld">order of derivative (smoothing=0)</param>
+    /// <param name="order">order of the polynomial to fit</param>
     /// <param name="c">resulting coefficients for convolution, in correct order (t-nl, ... t-1, t+0, t+1, ... t+nr)</param>
-    private void SavitzkyGolay(int nl, int nr, int order, out double[] c) {
+    private void SavitzkyGolay(int nl, int nr, int ld, int order, out double[] c) {
       int np = nl + nr + 1;
-      int ld = 0;
-      int m = order;
 
       int j, k, imj, ipj, kk, mm;
       double fac = 0;
       double sum = 0;
-      if (np < nl + nr + 1 || nl < 0 || nr < 0 || ld > m || nl + nr < m) throw new ArgumentException();
+      if (nl < 0 || nr < 0 || ld > order || nl + nr < order) throw new ArgumentException();
 
-      int[] indx = new int[m + 1];
-      double[,] a = new double[m + 1, m + 1];
-      double[] b = new double[m + 1];
+      double[,] a = new double[order + 1, order + 1];
+      double[] b = new double[order + 1];
       c = new double[np];
 
-      for (ipj = 0; ipj <= (m << 1); ipj++) {
+      for (ipj = 0; ipj <= (order << 1); ipj++) {
         sum = (ipj > 0 ? 0.0 : 1.0);
         for (k = 1; k <= nr; k++) sum += Math.Pow((double)k, (double)ipj);
         for (k = 1; k <= nl; k++) sum += Math.Pow((double)-k, (double)ipj);
-        mm = Math.Min(ipj, 2 * m - ipj);
+        mm = Math.Min(ipj, 2 * order - ipj);
         for (imj = -mm; imj <= mm; imj += 2)
           a[(ipj + imj) / 2, (ipj - imj) / 2] = sum;
       }
-      for (j = 0; j < m + 1; j++) b[j] = 0;
+      for (j = 0; j < order + 1; j++) b[j] = 0;
       b[ld] = 1.0;
       alglib.densesolverreport rep;
@@ -153,5 +154,5 @@
         sum = x[0];
         fac = 1.0;
-        for (mm = 1; mm <= m; mm++) sum += x[mm] * (fac *= k);
+        for (mm = 1; mm <= order; mm++) sum += x[mm] * (fac *= k);
         kk = k + nl;
         c[kk] = sum;
Index: branches/HeuristicLab.DataImporter/HeuristicLab.DataImporter.Command/View/FilterSavitzkyGolayCommandView.Designer.cs
===================================================================
--- branches/HeuristicLab.DataImporter/HeuristicLab.DataImporter.Command/View/FilterSavitzkyGolayCommandView.Designer.cs	(revision 6682)
+++ branches/HeuristicLab.DataImporter/HeuristicLab.DataImporter.Command/View/FilterSavitzkyGolayCommandView.Designer.cs	(revision 6706)
@@ -51,7 +51,10 @@
       this.label3 = new System.Windows.Forms.Label();
       this.numOrder = new System.Windows.Forms.NumericUpDown();
+      this.numOrderOfDerivative = new System.Windows.Forms.NumericUpDown();
+      this.label4 = new System.Windows.Forms.Label();
       ((System.ComponentModel.ISupportInitialize)(this.numWindowLeft)).BeginInit();
       ((System.ComponentModel.ISupportInitialize)(this.numWindowRight)).BeginInit();
       ((System.ComponentModel.ISupportInitialize)(this.numOrder)).BeginInit();
+      ((System.ComponentModel.ISupportInitialize)(this.numOrderOfDerivative)).BeginInit();
       this.SuspendLayout();
       // 
@@ -71,5 +74,5 @@
       this.numWindowLeft.Name = "numWindowLeft";
       this.numWindowLeft.Size = new System.Drawing.Size(120, 20);
-      this.numWindowLeft.TabIndex = 0;
+      this.numWindowLeft.TabIndex = 1;
       this.numWindowLeft.Value = new decimal(new int[] {
             4,
@@ -85,5 +88,5 @@
       this.label1.Name = "label1";
       this.label1.Size = new System.Drawing.Size(101, 13);
-      this.label1.TabIndex = 1;
+      this.label1.TabIndex = 0;
       this.label1.Text = "Window start offset:";
       // 
@@ -94,5 +97,5 @@
       this.label2.Name = "label2";
       this.label2.Size = new System.Drawing.Size(99, 13);
-      this.label2.TabIndex = 3;
+      this.label2.TabIndex = 2;
       this.label2.Text = "Window end offset:";
       // 
@@ -107,5 +110,5 @@
       this.numWindowRight.Name = "numWindowRight";
       this.numWindowRight.Size = new System.Drawing.Size(120, 20);
-      this.numWindowRight.TabIndex = 2;
+      this.numWindowRight.TabIndex = 3;
       this.numWindowRight.Value = new decimal(new int[] {
             4,
@@ -118,13 +121,13 @@
       // 
       this.label3.AutoSize = true;
-      this.label3.Location = new System.Drawing.Point(8, 62);
+      this.label3.Location = new System.Drawing.Point(9, 89);
       this.label3.Name = "label3";
-      this.label3.Size = new System.Drawing.Size(36, 13);
-      this.label3.TabIndex = 4;
-      this.label3.Text = "Order:";
+      this.label3.Size = new System.Drawing.Size(100, 13);
+      this.label3.TabIndex = 6;
+      this.label3.Text = "Order of polynomial:";
       // 
       // numOrder
       // 
-      this.numOrder.Location = new System.Drawing.Point(115, 60);
+      this.numOrder.Location = new System.Drawing.Point(115, 87);
       this.numOrder.Maximum = new decimal(new int[] {
             8,
@@ -134,5 +137,5 @@
       this.numOrder.Name = "numOrder";
       this.numOrder.Size = new System.Drawing.Size(120, 20);
-      this.numOrder.TabIndex = 5;
+      this.numOrder.TabIndex = 7;
       this.numOrder.Value = new decimal(new int[] {
             2,
@@ -142,8 +145,32 @@
       this.numOrder.ValueChanged += new System.EventHandler(this.numOrder_ValueChanged);
       // 
+      // numOrderOfDerivative
+      // 
+      this.numOrderOfDerivative.Location = new System.Drawing.Point(115, 60);
+      this.numOrderOfDerivative.Maximum = new decimal(new int[] {
+            3,
+            0,
+            0,
+            0});
+      this.numOrderOfDerivative.Name = "numOrderOfDerivative";
+      this.numOrderOfDerivative.Size = new System.Drawing.Size(120, 20);
+      this.numOrderOfDerivative.TabIndex = 5;
+      this.numOrderOfDerivative.ValueChanged += new System.EventHandler(this.numOrderOfDerivative_ValueChanged);
+      // 
+      // label4
+      // 
+      this.label4.AutoSize = true;
+      this.label4.Location = new System.Drawing.Point(8, 62);
+      this.label4.Name = "label4";
+      this.label4.Size = new System.Drawing.Size(97, 13);
+      this.label4.TabIndex = 4;
+      this.label4.Text = "Order of derivative:";
+      // 
       // FilterSavitzkyGolayCommandView
       // 
       this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
       this.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
+      this.Controls.Add(this.numOrderOfDerivative);
+      this.Controls.Add(this.label4);
       this.Controls.Add(this.numOrder);
       this.Controls.Add(this.label3);
@@ -154,8 +181,9 @@
       this.Name = "FilterSavitzkyGolayCommandView";
       this.Padding = new System.Windows.Forms.Padding(5);
-      this.Size = new System.Drawing.Size(244, 98);
+      this.Size = new System.Drawing.Size(246, 117);
       ((System.ComponentModel.ISupportInitialize)(this.numWindowLeft)).EndInit();
       ((System.ComponentModel.ISupportInitialize)(this.numWindowRight)).EndInit();
       ((System.ComponentModel.ISupportInitialize)(this.numOrder)).EndInit();
+      ((System.ComponentModel.ISupportInitialize)(this.numOrderOfDerivative)).EndInit();
       this.ResumeLayout(false);
       this.PerformLayout();
@@ -170,4 +198,6 @@
     private System.Windows.Forms.Label label3;
     private System.Windows.Forms.NumericUpDown numOrder;
+    private System.Windows.Forms.NumericUpDown numOrderOfDerivative;
+    private System.Windows.Forms.Label label4;
   }
 }
Index: branches/HeuristicLab.DataImporter/HeuristicLab.DataImporter.Command/View/FilterSavitzkyGolayCommandView.cs
===================================================================
--- branches/HeuristicLab.DataImporter/HeuristicLab.DataImporter.Command/View/FilterSavitzkyGolayCommandView.cs	(revision 6682)
+++ branches/HeuristicLab.DataImporter/HeuristicLab.DataImporter.Command/View/FilterSavitzkyGolayCommandView.cs	(revision 6706)
@@ -53,4 +53,7 @@
       get { return this.Command.Order; }
     }
+    public int OrderOfDerivative {
+      get { return this.Command.OrderOfDerivative; }
+    }
 
     private void numWindowLeft_ValueChanged(object sender, System.EventArgs e) {
@@ -62,4 +65,12 @@
     }
 
+    private void numOrder_ValueChanged(object sender, EventArgs e) {
+      this.UpdateCommand();
+    }
+
+    private void numOrderOfDerivative_ValueChanged(object sender, EventArgs e) {
+      this.UpdateCommand();
+    }
+
     private void UpdateCommand() {
       if (Command != null) {
@@ -67,9 +78,6 @@
         this.Command.WindowRight = (int)this.numWindowRight.Value;
         this.Command.Order = (int)this.numOrder.Value;
+        this.Command.OrderOfDerivative = (int) this.numOrderOfDerivative.Value;
       }
-    }
-
-    private void numOrder_ValueChanged(object sender, EventArgs e) {
-      this.UpdateCommand();
     }
   }
