public override void Run(Altaxo.Gui.Worksheet.Viewing.WorksheetController ctrl) { m_Table = ctrl.DataTable; var script = ctrl.DataTable.GetTableProperty(ExtractTableDataScriptPropertyName) as ExtractTableDataScript; if (script == null) { script = new ExtractTableDataScript(); } object[] args = new object[] { script, new ScriptExecutionHandler(EhScriptExecution) }; if (Current.Gui.ShowDialog(args, "WorksheetScript of " + m_Table.Name)) { m_Table.SetTableProperty(ExtractTableDataScriptPropertyName, args[0]); } m_Table = null; }
public virtual void Deserialize(DataTable s, Altaxo.Serialization.Xml.IXmlDeserializationInfo info, object parent) { s._tableName = info.GetString("Name"); s._dataColumns = (DataColumnCollection)info.GetValue("DataCols", s); s._dataColumns.ParentObject = s; s._propertyColumns = (DataColumnCollection)info.GetValue("PropCols", s); s._propertyColumns.ParentObject = s; // new in version 1 s._tableScript = (TableScript)info.GetValue("TableScript", s); // new in version 2 - Add table properties int numberproperties = info.OpenArray(); // "TableProperties" for (int i = 0; i < numberproperties; i++) { info.OpenElement(); // "e" string propkey = info.GetString("Key"); object propval = info.GetValue("Value", parent); info.CloseElement(); // "e" s.SetTableProperty(propkey, propval); } info.CloseArray(numberproperties); }
/// <summary> /// Makes a PLS (a partial least squares) analysis of the table or the selected columns / rows and stores the results in a newly created table. /// </summary> /// <param name="mainDocument">The main document of the application.</param> /// <param name="srctable">The table where the data come from.</param> /// <param name="selectedColumns">The selected columns.</param> /// <param name="selectedRows">The selected rows.</param> /// <param name="selectedPropertyColumns">The selected property column(s).</param> /// <param name="bHorizontalOrientedSpectrum">True if a spectrum is a single row, False if a spectrum is a single column.</param> /// <param name="plsOptions">Provides information about the max number of factors and the calculation of cross PRESS value.</param> /// <param name="preprocessOptions">Provides information about how to preprocess the spectra.</param> /// <returns></returns> public virtual string ExecuteAnalysis( Altaxo.AltaxoDocument mainDocument, Altaxo.Data.DataTable srctable, IAscendingIntegerCollection selectedColumns, IAscendingIntegerCollection selectedRows, IAscendingIntegerCollection selectedPropertyColumns, bool bHorizontalOrientedSpectrum, MultivariateAnalysisOptions plsOptions, SpectralPreprocessingOptions preprocessOptions ) { IMatrix matrixX, matrixY; IROVector xOfX; var plsContent = new MultivariateContentMemento(); plsContent.Analysis = this; // now we have to create a new table where to place the calculated factors and loads // we will do that in a vertical oriented manner, i.e. even if the loads are // here in horizontal vectors: in our table they are stored in (vertical) columns string newName = this.AnalysisName + " of " + Main.ProjectFolder.GetNamePart(srctable.Name); newName = Main.ProjectFolder.CreateFullName(srctable.Name, newName); Altaxo.Data.DataTable table = new Altaxo.Data.DataTable(newName); // Fill the Table using (var suspendToken = table.SuspendGetToken()) { table.SetTableProperty("Content", plsContent); plsContent.OriginalDataTableName = srctable.Name; // Get matrices GetXYMatrices( srctable, selectedColumns, selectedRows, selectedPropertyColumns, bHorizontalOrientedSpectrum, plsContent, out matrixX, out matrixY, out xOfX); StoreXOfX(xOfX, table); // Preprocess plsContent.SpectralPreprocessing = preprocessOptions; IVector meanX, scaleX, meanY, scaleY; MultivariateRegression.PreprocessForAnalysis(preprocessOptions, xOfX, matrixX, matrixY, out meanX, out scaleX, out meanY, out scaleY); StorePreprocessedData(meanX, scaleX, meanY, scaleY, table); // Analyze and Store IROVector press; ExecuteAnalysis( matrixX, matrixY, plsOptions, plsContent, table, out press); this.StorePRESSData(press, table); if (plsOptions.CrossPRESSCalculation != CrossPRESSCalculationType.None) CalculateCrossPRESS(xOfX, matrixX, matrixY, plsOptions, plsContent, table); StoreFRatioData(table, plsContent); StoreOriginalY(table, plsContent); suspendToken.Dispose(); } Current.Project.DataTableCollection.Add(table); // create a new worksheet without any columns Current.ProjectService.CreateNewWorksheet(table); return null; }
public override void Run(Altaxo.Gui.Worksheet.Viewing.WorksheetController ctrl) { m_Table = ctrl.DataTable; ExtractTableDataScript script = ctrl.DataTable.GetTableProperty(ExtractTableDataScriptPropertyName) as ExtractTableDataScript; if (script == null) script = new ExtractTableDataScript(); object[] args = new object[] { script, new ScriptExecutionHandler(this.EhScriptExecution) }; if (Current.Gui.ShowDialog(args, "WorksheetScript of " + m_Table.Name)) { m_Table.SetTableProperty(ExtractTableDataScriptPropertyName, args[0]); } this.m_Table = null; }
public virtual void Deserialize(DataTable s, Altaxo.Serialization.Xml.IXmlDeserializationInfo info, object parent) { s._tableName = info.GetString("Name"); s._dataColumns = (DataColumnCollection)info.GetValue("DataCols",s); s._dataColumns.ParentObject = s; s._propertyColumns = (DataColumnCollection)info.GetValue("PropCols",s); s._propertyColumns.ParentObject = s; // new in version 1 s._tableScript = (TableScript)info.GetValue("TableScript",s); // new in version 2 - Add table properties int numberproperties = info.OpenArray(); // "TableProperties" for(int i=0;i<numberproperties;i++) { info.OpenElement(); // "e" string propkey = info.GetString("Key"); object propval = info.GetValue("Value",parent); info.CloseElement(); // "e" s.SetTableProperty(propkey,propval); } info.CloseArray(numberproperties); }