public void TestGetWindowsWithExplanations() { var windows = new[] { new VoiWindow(1, 2), new VoiWindow(100, 200), new VoiWindow(100.1, 200.2), new VoiWindow(123.1, 456.2), new VoiWindow(123.567890123, -23.567890123) }; var dataset = new DicomAttributeCollection(); dataset[DicomTags.WindowCenter].SetStringValue(@"2\200\200.2\456.2\-23.567890123"); dataset[DicomTags.WindowWidth].SetStringValue(@"1\100\100.1\123.1\123.567890123"); dataset[DicomTags.WindowCenterWidthExplanation].SetStringValue(@"bob\alice\eve\james"); var actualWindows = VoiWindow.GetWindows(dataset).ToArray(); Assert.AreEqual(windows, actualWindows); Assert.AreEqual("bob", actualWindows[0].Explanation); Assert.AreEqual("alice", actualWindows[1].Explanation); Assert.AreEqual("eve", actualWindows[2].Explanation); Assert.AreEqual("james", actualWindows[3].Explanation); Assert.AreEqual("", actualWindows[4].Explanation); }
public void TestGetWindowsMissingWidths() { var dataset = new DicomAttributeCollection(); dataset[DicomTags.WindowCenter].SetStringValue(@"2\200\200.2\456.2\-23.567890123"); dataset[DicomTags.WindowWidth].SetEmptyValue(); var windows = VoiWindow.GetWindows(dataset).ToArray(); Assert.AreEqual(new VoiWindow[0], windows); }
public FusionOverlayData(IEnumerable <Frame> overlaySource) { var frames = new List <IFrameReference>(); foreach (Frame frame in overlaySource) { frames.Add(frame.CreateTransientReference()); } _frames = frames.AsReadOnly(); if (frames.Count > 0) { _voiWindows = new List <VoiWindow>(VoiWindow.GetWindows(frames[0].Sop.DataSource)).AsReadOnly(); } }
private static IEnumerable <VoiWindow> ComputeNormalizedVoiWindows(IImageSopProvider frame, double normalizedSlope, double normalizedIntercept) { var normalizedWindows = new List <VoiWindow>(VoiWindow.GetWindows(frame.Frame)); if (frame.ImageSop.Modality == @"PT" && frame.Frame.IsSubnormalRescale) { // for PET images with subnormal rescale, the VOI window will always be applied directly to the original stored pixel values // since MPR will not have access to original stored pixel values, we compute the VOI window through original modality LUT and inverted normalized modality LUT var normalizedVoiSlope = frame.Frame.RescaleSlope / normalizedSlope; var normalizedVoiIntercept = (frame.Frame.RescaleIntercept - normalizedIntercept) / normalizedSlope; for (var i = 0; i < normalizedWindows.Count; ++i) { var window = normalizedWindows[i]; // round the computed windows - the extra precision is not useful for display anyway normalizedWindows[i] = new VoiWindow(Math.Ceiling(window.Width * normalizedVoiSlope), Math.Round(window.Center * normalizedVoiSlope + normalizedVoiIntercept), window.Explanation); } } return(normalizedWindows); }
public void TestGetWindowsMismatchedPairs() { var windows = new[] { new VoiWindow(1, 2), new VoiWindow(100, 200), new VoiWindow(100.1, 200.2), new VoiWindow(123.1, 456.2) }; var dataset = new DicomAttributeCollection(); dataset[DicomTags.WindowCenter].SetStringValue(@"2\200\200.2\456.2\-23.567890123"); dataset[DicomTags.WindowWidth].SetStringValue(@"1\100\100.1\123.1"); var actualWindows = VoiWindow.GetWindows(dataset).ToArray(); Assert.AreEqual(windows, actualWindows); }
public FusionOverlayData(IEnumerable <Frame> overlaySource) { var frames = new List <IFrameReference>(); foreach (Frame frame in overlaySource) { frames.Add(frame.CreateTransientReference()); } _frames = frames.AsReadOnly(); if (frames.Count > 0) { // TODO: should this VOI window be based on volume header's normalized VOI windows? _voiWindows = new List <VoiWindow>(VoiWindow.GetWindows(frames[0].Frame)).AsReadOnly(); SourceSeriesInstanceUid = frames[0].Frame.SeriesInstanceUid; FrameOfReferenceUid = frames[0].Frame.FrameOfReferenceUid; Modality = frames[0].Sop.Modality; } }