public static void CalculateDigitalCoincidenceTOF(PETCoincidenceTOF In, ref PETDigitalCoincidenceTOF OutE) { OutE.I1 = (byte)iForX(In.XPlus1, In.XMinus1); OutE.J1 = (byte)jForY(In.YPlus1, In.YMinus1); OutE.I2 = (byte)iForX(In.XPlus2, In.XMinus2); OutE.J2 = (byte)jForY(In.YPlus2, In.YMinus2); OutE.Position1 = In.Position1; OutE.Position2 = In.Position2; OutE.Timestamp1 = In.Timestamp1; OutE.Timestamp2 = In.Timestamp2; // OutE.Flags = In.Flags; }
public static void CalculateCoincidenceTOFForDigital(PETDigitalCoincidenceTOF In, ref PETCoincidenceTOF OutE) { OutE.XPlus1 = XPlusForI(In.I1); OutE.XMinus1 = XMinusForI(In.I1); OutE.XPlus2 = XPlusForI(In.I2); OutE.XMinus2 = XMinusForI(In.I2); OutE.YPlus1 = YPlusForJ(In.J1); OutE.YMinus1 = YMinusForJ(In.J1); OutE.YPlus2 = YPlusForJ(In.J2); OutE.YMinus2 = YMinusForJ(In.J2); OutE.Position1 = In.Position1; OutE.Position2 = In.Position2; OutE.Timestamp1 = In.Timestamp1; OutE.Timestamp2 = In.Timestamp2; // OutE.Flags = In.Flags; }
public void Build(string path) { var sins = new double[numSins][, ]; for (int i = 0; i < numSins; i++) { sins[i] = new double[indexer.NumDirs, indexer.NumLines]; } Bitmap bmp = new Bitmap(1024, 1024); Graphics gr = Graphics.FromImage(bmp); gr.TranslateTransform(bmp.Width / 2f, bmp.Height / 2f); List <string> fileList = new List <string>(); if (Directory.Exists(path)) { DirectoryInfo di = new DirectoryInfo(path); FileSystemInfo[] files = di.GetFileSystemInfos(); foreach (var file in files) { fileList.Add(file.FullName); } } foreach (var file in fileList) { var clist = WorkWithFiles.ReadCoincList(file); foreach (var c in clist) { PETDigitalCoincidenceTOF cIJ = new PETDigitalCoincidenceTOF(); EventConverter.CalculateDigitalCoincidenceTOF(c, ref cIJ); int Ring1 = indexer.GetRing(c.Position1, cIJ.J1); int Ring2 = indexer.GetRing(c.Position2, cIJ.J2); var sinidx = Ring1 + Ring2; if (sinidx >= numSins) { continue; } int Dir = indexer.GetDir(c.Position1, c.Position2, cIJ.I1, cIJ.I2); int Line = indexer.GetLine(c.Position1, c.Position2, cIJ.I1, cIJ.I2); //if (isDebug && ++cnt % 1000 == 0) //{ // gr.DrawLine(Pens.White, 410 * (float)Math.Cos(Math.PI * Detector1 / 360), 410 * (float)Math.Sin(Math.PI * Detector1 / 360), // 410 * (float)Math.Cos(Math.PI * Detector2 / 360), 410 * (float)Math.Sin(Math.PI * Detector2 / 360)); //} if (Line < 0) { continue; } sins[sinidx][Dir, Line]++; } } if (!Directory.Exists(outDir)) { Directory.CreateDirectory(outDir); } for (int i = 0; i < numSins; i++) { Sinogram sino = new Sinogram(sins[i], AnglesDistribution.Uniform(0, Math.PI, indexer.NumDirs)); Stream ostream = File.Create(string.Format("{0}\\{1}", outDir, string.Format("{0}.sg", i))); //using (StreamWriter w = new StreamWriter(ostream, Encoding.UTF8)) using (ostream) { Sinogram.SaveSinogramToStream(ostream, sino); } Sinogram.DumpSinogram(sins[i], string.Format("{0}\\{1}.png", outDir, i)); //if (isDebug) // bmp.Save(string.Format("{0}\\lines.png", arg.OutDir)); } }