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); }
private void OnImageStored(object sender, ImageStoredEventArgs e) { if (this.InvokeRequired) { this.Invoke(new ImageStoredEventHandler(OnImageStored), new object[] { sender, e }); } else { try { if (pacsmode) { DataSet dicom = e.DataSet; DicomDir dir = new DicomDir("."); dir.Add(dicom); dir.Save(); } else { NewBrowser(e.DataSet); } } catch (Exception ex) { MessageBox.Show(Logging.Log(ex)); } } }
public static void OnImageStored(object sender, ImageStoredEventArgs e) { DataSet dicom = e.DataSet; DicomDir dir = new DicomDir("."); dir.Add(dicom); dir.Save(); }
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 SaveToDicomDir(ReceivedDicomElements receivedDicomElements, string dicomDirName) { var message = " -- DicomDir : " + dicomDirName + ", "; var hasError = true; try { if (receivedDicomElements.ImageSource == ImageSource.LocalDicomFile) { message += "File : " + receivedDicomElements.FileName; } else { message += string.Format("AeTitle : {0}, IpAddress : {1}", receivedDicomElements.CallingAeTitle, receivedDicomElements.IpAddress); } var dicomDirPath = Path.Combine(StorageRootPath, dicomDirName); var dicomDir = new DicomDir(dicomDirPath); dicomDir.Add(receivedDicomElements.Elements); dicomDir.Save(); receivedDicomElements.OnDicomDirSaved(dicomDirName); dicomServiceWorkerUser.OnDicomDirSaved(receivedDicomElements, dicomDirName); message = "Save to dicom dir successfull!" + message; hasError = false; } catch (Exception ex) { message = "Save to dicom dir failed!" + message + " " + ex.Message; } finally { dicomServiceWorkerUser.ShowMessage(message, hasError, false); } }