public void InternalQueryTest2() { DicomDir dir = new DicomDir("."); dir.Empty(); ApplicationEntity storage = new ApplicationEntity("ImageServer", IPAddress.Parse("127.0.0.1"), 2000); StorageTest.Start(storage); StorageTest.store(@"EK\Capture\Dicom\DicomToolKit\Test\Data\DicomDir\Y2ASNFDS.dcm", storage, false); StorageTest.store(@"EK\Capture\Dicom\DicomToolKit\Test\Data\DicomDir\WNGVU1P1.dcm", storage, false); StorageTest.store(@"EK\Capture\Dicom\DicomToolKit\Test\Data\DicomDir\THGLUZ5J.dcm", storage, false); StorageTest.Stop(); ApplicationEntity host = new ApplicationEntity("IMAGESERVER", 2190); CFindTest.Start(host); CFindServiceSCU find = new CFindServiceSCU(SOPClass.StudyRootQueryRetrieveInformationModelFIND); find.Syntaxes.Add(Syntax.ExplicitVrLittleEndian); Association association = new Association(); association.AddService(find); if (association.Open(host.Title, host.Address, host.Port)) { Series series = new Series(); series[t.StudyInstanceUID].Value = "1.2.840.113564.109517115.2009111711190101521"; DataSet filter = new DataSet(); filter.Elements = series.Elements; filter.Set(t.QueryRetrieveLevel, "SERIES"); RecordCollection records = find.CFind(filter); RecordCollectionTest.WriteRecords(records); } else { System.Console.WriteLine("\ncan't Open."); } association.Close(); dir.Empty(); CFindTest.Stop(); }
public void FolderingTest() { string folder = Path.Combine(Tools.RootFolder, @"EK\Capture\Dicom\DicomToolKit\Test\Data\DicomDir"); string path = Path.Combine(folder, "FolderingTest"); DicomDir dir = new DicomDir(path); dir.Empty(); DirectoryInfo working = new DirectoryInfo(path); working = Directory.CreateDirectory(path); int n = 0; // add each test image to the DICOMDIR foreach (string file in Directory.GetFiles(folder, "*.dcm")) { dir.Add(file, @"parent\child"); n++; } // write it out dir.Save(); string temp = Path.Combine(path, @"parent\child"); temp = Path.Combine(temp, String.Format("{0:00000000}", n)); Assert.IsTrue(new FileInfo(temp).Exists); }
public void ManualCreateTest() { lock (sentry) { string folder = Path.Combine(Tools.RootFolder, @"EK\Capture\Dicom\DicomToolKit\Test\Data\DicomDir"); string path = Path.Combine(folder, "ManualCreateTest"); Directory.CreateDirectory(path); DicomDir dir = new DicomDir(path); dir.Empty(); DateTime now = DateTime.Now; Patient patient = dir.NewPatient("Sadler^Michael", "12345"); Study study = patient.NewStudy(now, now, Element.NewUid(), "1"); Series series = study.NewSeries("CR", Element.NewUid()); Image image = series.NewImage(Path.Combine(folder, "THGLUZ5J.dcm")); dir.Save(); string before = Dump(dir, "before"); dir = new DicomDir(path); string after = Dump(dir, "after"); Assert.AreEqual(before, after, "before does not match after"); } }
public void InternalCMoveTest() { // make sure DICOM at "." is empty DicomDir dir = new DicomDir("."); dir.Empty(); ApplicationEntity storage = new ApplicationEntity("ImageServer", IPAddress.Parse("127.0.0.1"), 2000); ApplicationEntity server = new ApplicationEntity("ImageServer", IPAddress.Parse("127.0.0.1"), 5104); Dictionary <string, ApplicationEntity> stations = new Dictionary <string, ApplicationEntity>(); stations.Add(storage.Title, storage); StorageTest.Start(storage); CMoveTest.Start(server, stations); // add three images to a DICOMDIR at "." StorageTest.store(@"EK\Capture\Dicom\DicomToolKit\Test\Data\DicomDir\Y2ASNFDS.dcm", storage, false); StorageTest.store(@"EK\Capture\Dicom\DicomToolKit\Test\Data\DicomDir\WNGVU1P1.dcm", storage, false); StorageTest.store(@"EK\Capture\Dicom\DicomToolKit\Test\Data\DicomDir\THGLUZ5J.dcm", storage, false); // ask for an image from a DICOMDIR at "." be delivered to a DICOMDIR at "." // should create a duplicate SOPInstanceUID, which results in a WARNING try { move(storage.Title, server); } catch (Exception) { } CMoveTest.Stop(); StorageTest.Stop(); }
public void ManualExtraTagsTest() { string folder = Path.Combine(Tools.RootFolder, @"EK\Capture\Dicom\DicomToolKit\Test\Data\DicomDir"); string path = Path.Combine(folder, "ManualExtraTagsTest"); DicomDir dir = new DicomDir(path); dir.Empty(); DirectoryInfo working = new DirectoryInfo(path); working = Directory.CreateDirectory(path); int n = 0; // add each test image to the DICOMDIR foreach (string file in Directory.GetFiles(folder, "*.dcm")) { DataSet temp = new DataSet(); temp.Read(file); // when you add an Image, you now get back a reference to the image Image image = dir.Add(temp, @"parent\child"); // and you can apply some logic to add tags // either hard code them image.Elements.Set(t.InstanceNumber, n); // or add them if they exist in the original image if (temp.Contains(t.ImagePositionPatient)) { image.Elements.Add(temp[t.ImagePositionPatient]); } else { image.Elements.Add(t.ImagePositionPatient, "1"); } if (temp.Contains(t.ImageOrientationPatient)) { image.Elements.Add(temp[t.ImageOrientationPatient]); } else { image.Elements.Add(t.ImageOrientationPatient, "2"); } n++; } // write it out dir.Save(); }
public static DicomDir Setup(string folder, string path) { DicomDir dir = new DicomDir(Path.Combine(folder, path)); dir.Empty(); // add each test image to the DICOMDIR foreach (string file in Directory.GetFiles(folder, "*.dcm")) { dir.Add(file); } // write it out dir.Save(); return(dir); }
public void BaseQueryTest() { DicomDir dir = new DicomDir("."); DateTime now = DateTime.Now; // create a patient with two studies, each with one series, // the first series with one image, the second with two Patient patient = dir.NewPatient("Patient^Test", "10"); Study study = patient.NewStudy(now, now, "10", "10"); Series series = study.NewSeries("CR", "10"); Image image = series.NewImage("10"); image.ReferencedSOPInstanceUIDinFile = "10"; study = patient.NewStudy(now, now, "20", "20"); series = study.NewSeries("CR", "20"); image = series.NewImage("20"); image.ReferencedSOPInstanceUIDinFile = "20"; image = series.NewImage("30"); image.ReferencedSOPInstanceUIDinFile = "30"; // create a patient with one study, containing two series, // the first series with two images, the second with one patient = dir.NewPatient("Subject^Test", "20"); study = patient.NewStudy(now, now, "30", "30"); series = study.NewSeries("DX", "30"); image = series.NewImage("40"); image.ReferencedSOPInstanceUIDinFile = "40"; image = series.NewImage("50"); image.ReferencedSOPInstanceUIDinFile = "50"; series = study.NewSeries("CR", "40"); image = series.NewImage("60"); image.ReferencedSOPInstanceUIDinFile = "60"; // create a patient with a single study and series containing thrww images patient = dir.NewPatient("Patietn^Pink", "30"); study = patient.NewStudy(now, now, "40", "40"); series = study.NewSeries("MG", "50"); image = series.NewImage("70"); image.ReferencedSOPInstanceUIDinFile = "70"; image = series.NewImage("80"); image.ReferencedSOPInstanceUIDinFile = "80"; image = series.NewImage("90"); image.ReferencedSOPInstanceUIDinFile = "90"; dir.Save(); /* P ST SE IM * 10 * 10 * 10 * 10 * 20 * 20 * 20 * 30 * 20 * 30 * 30 * 40 * 50 * 40 * 60 * 30 * 40 * 50 * 70 * 80 * 90 * */ patient = new Patient(); RecordCollection records = query("PATIENT", patient.Elements); Assert.AreEqual(3, records.Count); study = new Study(); records = query("STUDY", study.Elements); Assert.AreEqual(4, records.Count); series = new Series(); records = query("SERIES", series.Elements); Assert.AreEqual(5, records.Count); image = new Image(); records = query("IMAGE", image.Elements); Assert.AreEqual(9, records.Count); dir.Empty(); }
public void BaseQueryTest() { DicomDir dir = new DicomDir("."); DateTime now = DateTime.Now; // create a patient with two studies, each with one series, // the first series with one image, the second with two Patient patient = dir.NewPatient("10", "10"); Study study = patient.NewStudy(now, now, "10", "10"); Series series = study.NewSeries("CR", "10"); Image image = series.NewImage("10"); image.ReferencedSOPInstanceUIDinFile = "10"; study = patient.NewStudy(now, now, "20", "20"); series = study.NewSeries("CR", "20"); image = series.NewImage("20"); image.ReferencedSOPInstanceUIDinFile = "20"; image = series.NewImage("30"); image.ReferencedSOPInstanceUIDinFile = "30"; // create a patient with one study, containing two series, // the first series with two images, the second with one patient = dir.NewPatient("20", "20"); study = patient.NewStudy(now, now, "30", "30"); series = study.NewSeries("CR", "30"); image = series.NewImage("40"); image.ReferencedSOPInstanceUIDinFile = "40"; image = series.NewImage("50"); image.ReferencedSOPInstanceUIDinFile = "50"; series = study.NewSeries("CR", "40"); image = series.NewImage("60"); image.ReferencedSOPInstanceUIDinFile = "60"; // create a patient with a single study and series containing thrww images patient = dir.NewPatient("30", "30"); study = patient.NewStudy(now, now, "40", "40"); series = study.NewSeries("CR", "50"); image = series.NewImage("70"); image.ReferencedSOPInstanceUIDinFile = "70"; image = series.NewImage("80"); image.ReferencedSOPInstanceUIDinFile = "80"; image = series.NewImage("90"); image.ReferencedSOPInstanceUIDinFile = "90"; dir.Save(); /* P ST SE IM * 10 * 10 * 10 * 10 * 20 * 20 * 20 * 30 * 20 * 30 * 30 * 40 * 50 * 40 * 60 * 30 * 40 * 50 * 70 * 80 * 90 * */ Assert.AreEqual("10,20,30", query("PATIENT", "10")); Assert.AreEqual("10", query("STUDY", "10")); Assert.AreEqual("10", query("SERIES", "10")); Assert.AreEqual("20,30", query("STUDY", "20")); Assert.AreEqual("20,30", query("SERIES", "20")); Assert.AreEqual("40,50,60", query("PATIENT", "20")); Assert.AreEqual("40,50,60", query("STUDY", "30")); Assert.AreEqual("40,50", query("SERIES", "30")); Assert.AreEqual("60", query("SERIES", "40")); Assert.AreEqual("70,80,90", query("PATIENT", "30")); Assert.AreEqual("70,80,90", query("STUDY", "40")); Assert.AreEqual("70,80,90", query("SERIES", "50")); Assert.AreEqual("10", query("IMAGE", "10")); Assert.AreEqual("20", query("IMAGE", "20")); Assert.AreEqual("30", query("IMAGE", "30")); Assert.AreEqual("40", query("IMAGE", "40")); Assert.AreEqual("50", query("IMAGE", "50")); Assert.AreEqual("60", query("IMAGE", "60")); Assert.AreEqual("70", query("IMAGE", "70")); Assert.AreEqual("80", query("IMAGE", "80")); Assert.AreEqual("90", query("IMAGE", "90")); dir.Empty(); }