public void Execute(ScriptContext context /*, System.Windows.Window window*/) { // snippet 1 // assume a registration is in context. MIRSRegistration mirsReg = context.Registration; if (mirsReg == null) { MessageBox.Show("This script requires a registration to be selected.", "Varian Developer"); return; } // look for MatchPoints structure on source and target image. MIRSImage registeredImage = mirsReg.RegisteredImage; MIRSImage sourceImage = mirsReg.SourceImage; MessageBox.Show("Fixed image ID = " + registeredImage.Id); MessageBox.Show("Moving image ID = " + sourceImage.Id); // snippet 1 // get the match points from the fixed image var listSS = registeredImage.Image.StructureSets; PointsStructure matchPtsRegistered = null; foreach (Structure s in listSS.First().Structures) { if (s is PointsStructure && s.StructureType == StructureType.Registration) { matchPtsRegistered = (PointsStructure)s; break; } } #if false // Equivalent LINQ query: PointsStructure matchPtsFixed = (from s in listSS.First().Structures where (s is PointsStructure) && (s.StructureType == StructureType.Registration) select s).FirstOrDefault(); #endif // get the match points from the moving image listSS = sourceImage.Image.StructureSets; PointsStructure matchPtsSource = null; foreach (Structure s in listSS.First().Structures) { if (s is PointsStructure && s.StructureType == StructureType.Registration) { matchPtsSource = (PointsStructure)s; break; } } // transform points through the registration matrix. VVector[] transformed = mirsReg.TransformPoints(matchPtsSource.Points); // compute some TRE statistics RegStats stats = new RegStats(); stats.computeStats(matchPtsSource.Points, matchPtsRegistered.Points, transformed); // generate a report string htmlReportPath = GenerateReport(context, mirsReg, matchPtsSource.Points, matchPtsRegistered.Points, transformed, stats); // 'Start' generated HTML file to launch browser window System.Diagnostics.Process.Start(htmlReportPath); // Sleep for a few seconds to let internet browser window to start System.Threading.Thread.Sleep(TimeSpan.FromSeconds(3)); }