public void LoadMedicalVolumeTest() { var dir = TestData.GetFullImagesPath(@"sample_dicom"); var acceptanceTests = new ModerateGeometricAcceptanceTest(string.Empty, string.Empty); var medicalVolumes = MedIO.LoadAllDicomSeriesInFolderAsync(dir, acceptanceTests).Result; Assert.AreEqual(1, medicalVolumes.Count); var medicalVolume = medicalVolumes.First().Volume; Assert.IsTrue(medicalVolume.Struct.Contours.Any(x => x.StructureSetRoi.RoiName == "Bladder")); Assert.IsTrue(medicalVolume.Struct.Contours.Any(x => x.StructureSetRoi.RoiName == "Femur_L")); RtStructWriter.SaveRtStruct(_tempfile, medicalVolume.Struct); DicomFile file = DicomFile.Open(_tempfile); var identifiers = medicalVolume.Identifiers.First(); var reloaded = RtStructReader.LoadContours( file.Dataset, medicalVolume.Volume.Transform.DicomToData, identifiers.Series.SeriesInstanceUid, identifiers.Study.StudyInstanceUid).Item1; Assert.IsTrue(reloaded.Contours.Any(x => x.StructureSetRoi.RoiName == "Bladder")); Assert.IsTrue(reloaded.Contours.Any(x => x.StructureSetRoi.RoiName == "Femur_L")); }
/// <summary> /// Creates a single Dicom file that contains a radiotherapy structure, /// derived from a set of contours and rendering information. /// </summary> /// <param name="contours">The contours and their rendering information.</param> /// <param name="dicomIdentifiers">The Dicom identifiers for the scan to which the contours belong.</param> /// <param name="volumeTransform">The Dicom-to-data transformation of the scan to which the contours belong.</param> /// <returns></returns> public static DicomFileAndPath ContoursToDicomRtFile(IEnumerable <ContourRenderingInformation> contours, IReadOnlyList <DicomIdentifiers> dicomIdentifiers, VolumeTransform volumeTransform) { var radiotherapyStruct = ContoursToRadiotherapyStruct(contours, dicomIdentifiers, volumeTransform); return(new DicomFileAndPath(RtStructWriter.GetRtStructFile(radiotherapyStruct), "RTStruct.dcm")); }
/// <summary> /// Returns a task to save the given rtStruct to disk. /// </summary> /// <param name="filename"></param> /// <param name="rtStruct"></param> /// <returns></returns> public static async Task SaveRtStructAsync(string filename, RadiotherapyStruct rtStruct) { await Task.Run( () => RtStructWriter.SaveRtStruct(filename, rtStruct)); }