From 64c4603e737b96f7138da1a682cd1d6e41ee1d83 Mon Sep 17 00:00:00 2001 From: Nicolas Roduit Date: Thu, 21 Dec 2023 13:46:04 +0100 Subject: [PATCH] Use DicomUtils instead of DicomMediaUtils --- .../weasis/dicom/codec/DicomImageElement.java | 5 +- .../org/weasis/dicom/codec/DicomMediaIO.java | 6 +- .../java/org/weasis/dicom/codec/TagD.java | 15 +- .../weasis/dicom/codec/display/ShutterOp.java | 4 +- .../codec/macro/SOPInstanceReference.java | 4 +- .../dicom/codec/utils/DicomMediaUtils.java | 286 ++---------------- .../weasis/dicom/codec/utils/Ultrasound.java | 13 +- .../codec/utils/DicomMediaUtilsTest.java | 100 ------ .../weasis/dicom/explorer/DicomDirLoader.java | 3 +- .../dicom/explorer/pr/DicomPrSerializer.java | 8 +- .../dicom/explorer/pr/PrGraphicUtil.java | 17 +- .../dicom/explorer/rs/RsQueryResult.java | 4 +- .../dicom/qr/manisfest/CFindQueryResult.java | 4 +- .../main/java/org/weasis/dicom/rt/RtSet.java | 17 +- .../weasis/dicom/sr/SRDocumentContent.java | 4 +- .../org/weasis/dicom/viewer2d/PRManager.java | 11 +- .../weasis/dicom/wave/ChannelDefinition.java | 10 +- .../java/org/weasis/dicom/wave/WaveView.java | 11 +- .../wave/dockable/MeasureAnnotationTool.java | 17 +- 19 files changed, 91 insertions(+), 448 deletions(-) delete mode 100755 weasis-dicom/weasis-dicom-codec/src/test/java/org/weasis/dicom/codec/utils/DicomMediaUtilsTest.java diff --git a/weasis-dicom/weasis-dicom-codec/src/main/java/org/weasis/dicom/codec/DicomImageElement.java b/weasis-dicom/weasis-dicom-codec/src/main/java/org/weasis/dicom/codec/DicomImageElement.java index cd47e9f4a..3d7cb3e86 100755 --- a/weasis-dicom/weasis-dicom-codec/src/main/java/org/weasis/dicom/codec/DicomImageElement.java +++ b/weasis-dicom/weasis-dicom-codec/src/main/java/org/weasis/dicom/codec/DicomImageElement.java @@ -50,7 +50,6 @@ import org.weasis.dicom.codec.display.ShutterOp; import org.weasis.dicom.codec.display.WindowAndPresetsOp; import org.weasis.dicom.codec.geometry.GeometryOfSlice; -import org.weasis.dicom.codec.utils.DicomMediaUtils; import org.weasis.dicom.codec.utils.Ultrasound; import org.weasis.dicom.param.AttributeEditorContext; import org.weasis.opencv.data.ImageCV; @@ -145,9 +144,9 @@ private void initPixelValueUnit(String modality) { Ultrasound.getUniqueSpatialRegion(getMediaReader().getDicomObject()); if (spatialCalibration != null) { Double calibX = - DicomMediaUtils.getDoubleFromDicomElement(spatialCalibration, Tag.PhysicalDeltaX, null); + DicomUtils.getDoubleFromDicomElement(spatialCalibration, Tag.PhysicalDeltaX, null); Double calibY = - DicomMediaUtils.getDoubleFromDicomElement(spatialCalibration, Tag.PhysicalDeltaY, null); + DicomUtils.getDoubleFromDicomElement(spatialCalibration, Tag.PhysicalDeltaY, null); if (calibX != null && calibY != null) { calibX = Math.abs(calibX); calibY = Math.abs(calibY); diff --git a/weasis-dicom/weasis-dicom-codec/src/main/java/org/weasis/dicom/codec/DicomMediaIO.java b/weasis-dicom/weasis-dicom-codec/src/main/java/org/weasis/dicom/codec/DicomMediaIO.java index 42215db42..3d4b6ac9a 100755 --- a/weasis-dicom/weasis-dicom-codec/src/main/java/org/weasis/dicom/codec/DicomMediaIO.java +++ b/weasis-dicom/weasis-dicom-codec/src/main/java/org/weasis/dicom/codec/DicomMediaIO.java @@ -39,6 +39,7 @@ import org.dcm4che3.img.data.PrDicomObject; import org.dcm4che3.img.stream.DicomFileInputStream; import org.dcm4che3.img.stream.ImageDescriptor; +import org.dcm4che3.img.util.DicomUtils; import org.dcm4che3.io.DicomOutputStream; import org.opencv.core.Core; import org.opencv.core.CvType; @@ -479,7 +480,7 @@ private void writeInstanceTags(DicomMetaData md) { setTag(TagW.PatientPseudoUID, patientComparator.buildPatientPseudoUID()); Integer instNb = - DicomMediaUtils.getIntegerFromDicomElement( + DicomUtils.getIntegerFromDicomElement( header, Tag.InstanceNumber, instanceID.incrementAndGet()); setTag(TagD.get(Tag.InstanceNumber), instNb); setTag( @@ -563,8 +564,7 @@ private void writeImageValues(DicomMetaData md) { TagD.get(Tag.Units).readValue(header, this); TagD.get(Tag.NumberOfFrames).readValue(header, this); - int samplesPerPixel = - DicomMediaUtils.getIntegerFromDicomElement(header, Tag.SamplesPerPixel, 1); + int samplesPerPixel = DicomUtils.getIntegerFromDicomElement(header, Tag.SamplesPerPixel, 1); setTag(TagD.get(Tag.SamplesPerPixel), samplesPerPixel); String photometricInterpretation = header.getString(Tag.PhotometricInterpretation, "MONOCHROME2"); diff --git a/weasis-dicom/weasis-dicom-codec/src/main/java/org/weasis/dicom/codec/TagD.java b/weasis-dicom/weasis-dicom-codec/src/main/java/org/weasis/dicom/codec/TagD.java index f99b3e7e4..d44d3c36c 100755 --- a/weasis-dicom/weasis-dicom-codec/src/main/java/org/weasis/dicom/codec/TagD.java +++ b/weasis-dicom/weasis-dicom-codec/src/main/java/org/weasis/dicom/codec/TagD.java @@ -44,6 +44,7 @@ import org.dcm4che3.data.Tag; import org.dcm4che3.data.VR; import org.dcm4che3.img.util.DateTimeUtils; +import org.dcm4che3.img.util.DicomUtils; import org.dcm4che3.util.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -291,7 +292,7 @@ private Object readValue(Attributes dataset) { if (isStringFamilyType()) { value = vmMax > 1 - ? DicomMediaUtils.getStringArrayFromDicomElement( + ? DicomUtils.getStringArrayFromDicomElement( dataset, id, privateCreatorID, (String[]) defaultValue) : dataset.getString(privateCreatorID, id, (String) defaultValue); } else if (TagType.DICOM_DATE.equals(type) @@ -306,23 +307,23 @@ private Object readValue(Attributes dataset) { } else if (TagType.INTEGER.equals(type)) { value = vmMax > 1 - ? DicomMediaUtils.getIntArrayFromDicomElement( + ? DicomUtils.getIntArrayFromDicomElement( dataset, id, privateCreatorID, (int[]) defaultValue) - : DicomMediaUtils.getIntegerFromDicomElement( + : DicomUtils.getIntegerFromDicomElement( dataset, id, privateCreatorID, (Integer) defaultValue); } else if (TagType.FLOAT.equals(type)) { value = vmMax > 1 - ? DicomMediaUtils.getFloatArrayFromDicomElement( + ? DicomUtils.getFloatArrayFromDicomElement( dataset, id, privateCreatorID, (float[]) defaultValue) - : DicomMediaUtils.getFloatFromDicomElement( + : DicomUtils.getFloatFromDicomElement( dataset, id, privateCreatorID, (Float) defaultValue); } else if (TagType.DOUBLE.equals(type)) { value = vmMax > 1 - ? DicomMediaUtils.getDoubleArrayFromDicomElement( + ? DicomUtils.getDoubleArrayFromDicomElement( dataset, id, privateCreatorID, (double[]) defaultValue) - : DicomMediaUtils.getDoubleFromDicomElement( + : DicomUtils.getDoubleFromDicomElement( dataset, id, privateCreatorID, (Double) defaultValue); } else if (TagType.DICOM_SEQUENCE.equals(type)) { value = dataset.getSequence(privateCreatorID, id); diff --git a/weasis-dicom/weasis-dicom-codec/src/main/java/org/weasis/dicom/codec/display/ShutterOp.java b/weasis-dicom/weasis-dicom-codec/src/main/java/org/weasis/dicom/codec/display/ShutterOp.java index ec909f398..1a6c80302 100755 --- a/weasis-dicom/weasis-dicom-codec/src/main/java/org/weasis/dicom/codec/display/ShutterOp.java +++ b/weasis-dicom/weasis-dicom-codec/src/main/java/org/weasis/dicom/codec/display/ShutterOp.java @@ -20,6 +20,7 @@ import org.dcm4che3.data.Tag; import org.dcm4che3.img.data.OverlayData; import org.dcm4che3.img.data.PrDicomObject; +import org.dcm4che3.img.util.DicomUtils; import org.weasis.core.api.gui.util.ActionW; import org.weasis.core.api.image.AbstractOp; import org.weasis.core.api.image.ImageOpEvent; @@ -29,7 +30,6 @@ import org.weasis.core.util.LangUtil; import org.weasis.dicom.codec.PRSpecialElement; import org.weasis.dicom.codec.TagD; -import org.weasis.dicom.codec.utils.DicomMediaUtils; import org.weasis.opencv.data.ImageCV; import org.weasis.opencv.data.PlanarImage; import org.weasis.opencv.op.ImageProcessor; @@ -128,7 +128,7 @@ public void process() throws Exception { if (height != null && width != null) { Attributes attributes = pr.getDicomObject(); Integer shutterOverlayGroup = - DicomMediaUtils.getIntegerFromDicomElement(attributes, Tag.ShutterOverlayGroup, null); + DicomUtils.getIntegerFromDicomElement(attributes, Tag.ShutterOverlayGroup, null); if (shutterOverlayGroup != null) { PlanarImage overlayImg = OverlayData.getOverlayImage(result, overlays, frame); imgOverlay = diff --git a/weasis-dicom/weasis-dicom-codec/src/main/java/org/weasis/dicom/codec/macro/SOPInstanceReference.java b/weasis-dicom/weasis-dicom-codec/src/main/java/org/weasis/dicom/codec/macro/SOPInstanceReference.java index f3729e031..a2701fdb4 100755 --- a/weasis-dicom/weasis-dicom-codec/src/main/java/org/weasis/dicom/codec/macro/SOPInstanceReference.java +++ b/weasis-dicom/weasis-dicom-codec/src/main/java/org/weasis/dicom/codec/macro/SOPInstanceReference.java @@ -16,7 +16,7 @@ import org.dcm4che3.data.Sequence; import org.dcm4che3.data.Tag; import org.dcm4che3.data.VR; -import org.weasis.dicom.codec.utils.DicomMediaUtils; +import org.dcm4che3.img.util.DicomUtils; public class SOPInstanceReference extends Module { @@ -43,7 +43,7 @@ public static Collection toSOPInstanceReferenceMacros(Sequ } public int[] getReferencedFrameNumber() { - return DicomMediaUtils.getIntArrayFromDicomElement(dcmItems, Tag.ReferencedFrameNumber, null); + return DicomUtils.getIntAyrrayFromDicomElement(dcmItems, Tag.ReferencedFrameNumber, null); } /** diff --git a/weasis-dicom/weasis-dicom-codec/src/main/java/org/weasis/dicom/codec/utils/DicomMediaUtils.java b/weasis-dicom/weasis-dicom-codec/src/main/java/org/weasis/dicom/codec/utils/DicomMediaUtils.java index a08ec8265..21aa6f2cb 100755 --- a/weasis-dicom/weasis-dicom-codec/src/main/java/org/weasis/dicom/codec/utils/DicomMediaUtils.java +++ b/weasis-dicom/weasis-dicom-codec/src/main/java/org/weasis/dicom/codec/utils/DicomMediaUtils.java @@ -14,7 +14,6 @@ import java.time.LocalDate; import java.time.LocalDateTime; import java.time.LocalTime; -import java.time.temporal.ChronoUnit; import java.time.temporal.TemporalAccessor; import java.util.Arrays; import java.util.Date; @@ -39,6 +38,7 @@ import org.dcm4che3.img.lut.ModalityLutModule; import org.dcm4che3.img.lut.VoiLutModule; import org.dcm4che3.img.util.DicomObjectUtil; +import org.dcm4che3.img.util.DicomUtils; import org.dcm4che3.util.ByteUtils; import org.dcm4che3.util.TagUtils; import org.dcm4che3.util.UIDUtils; @@ -182,260 +182,6 @@ public static boolean containsLUTAttributes(Attributes dcmItems) { return containsRequiredAttributes(dcmItems, LUTAttributes); } - public static String getStringFromDicomElement(Attributes dicom, int tag) { - if (dicom == null || !dicom.containsValue(tag)) { - return null; - } - - String[] s = dicom.getStrings(tag); - if (s == null || s.length == 0) { - return null; - } - if (s.length == 1) { - return s[0]; - } - StringBuilder sb = new StringBuilder(s[0]); - for (int i = 1; i < s.length; i++) { - sb.append("\\").append(s[i]); - } - return sb.toString(); - } - - public static String[] getStringArrayFromDicomElement(Attributes dicom, int tag) { - return getStringArrayFromDicomElement(dicom, tag, (String) null); - } - - public static String[] getStringArrayFromDicomElement( - Attributes dicom, int tag, String privateCreatorID) { - if (dicom == null || !dicom.containsValue(tag)) { - return null; - } - return dicom.getStrings(privateCreatorID, tag); - } - - public static String[] getStringArrayFromDicomElement( - Attributes dicom, int tag, String[] defaultValue) { - return getStringArrayFromDicomElement(dicom, tag, null, defaultValue); - } - - public static String[] getStringArrayFromDicomElement( - Attributes dicom, int tag, String privateCreatorID, String[] defaultValue) { - if (dicom == null || !dicom.containsValue(tag)) { - return defaultValue; - } - String[] val = dicom.getStrings(privateCreatorID, tag); - if (val == null || val.length == 0) { - return defaultValue; - } - return val; - } - - public static Date getDateFromDicomElement(Attributes dicom, int tag, Date defaultValue) { - if (dicom == null || !dicom.containsValue(tag)) { - return defaultValue; - } - return dicom.getDate(tag, defaultValue); - } - - public static Date[] getDatesFromDicomElement( - Attributes dicom, int tag, String privateCreatorID, Date[] defaultValue) { - if (dicom == null || !dicom.containsValue(tag)) { - return defaultValue; - } - Date[] val = dicom.getDates(privateCreatorID, tag); - if (val == null || val.length == 0) { - return defaultValue; - } - return val; - } - - public static String getPatientAgeInPeriod(Attributes dicom, int tag, boolean computeOnlyIfNull) { - return getPatientAgeInPeriod(dicom, tag, null, null, computeOnlyIfNull); - } - - public static String getPatientAgeInPeriod( - Attributes dicom, - int tag, - String privateCreatorID, - String defaultValue, - boolean computeOnlyIfNull) { - if (dicom == null) { - return defaultValue; - } - - if (computeOnlyIfNull) { - String s = dicom.getString(privateCreatorID, tag, defaultValue); - if (StringUtil.hasText(s) && StringUtil.hasText(TagD.getDicomPeriod(s))) { - return s; - } - } - - Date date = - getDate( - dicom, - Tag.ContentDate, - Tag.AcquisitionDate, - Tag.DateOfSecondaryCapture, - Tag.SeriesDate, - Tag.StudyDate); - - if (date != null) { - Date birthdate = dicom.getDate(Tag.PatientBirthDate); - if (birthdate != null) { - return getPeriod(TagUtil.toLocalDate(birthdate), TagUtil.toLocalDate(date)); - } - } - return null; - } - - private static Date getDate(Attributes dicom, int... tagID) { - Date date; - for (int i : tagID) { - date = dicom.getDate(i); - if (date != null) { - return date; - } - } - return null; - } - - public static String getPeriod(LocalDate first, LocalDate last) { - Objects.requireNonNull(first); - Objects.requireNonNull(last); - - long years = ChronoUnit.YEARS.between(first, last); - if (years < 2) { - long months = ChronoUnit.MONTHS.between(first, last); - if (months < 2) { - return String.format("%03dD", ChronoUnit.DAYS.between(first, last)); // NON-NLS - } - return String.format("%03dM", months); // NON-NLS - } - return String.format("%03dY", years); // NON-NLS - } - - public static Float getFloatFromDicomElement(Attributes dicom, int tag, Float defaultValue) { - return getFloatFromDicomElement(dicom, tag, null, defaultValue); - } - - public static Float getFloatFromDicomElement( - Attributes dicom, int tag, String privateCreatorID, Float defaultValue) { - if (dicom == null || !dicom.containsValue(tag)) { - return defaultValue; - } - try { - return dicom.getFloat(privateCreatorID, tag, defaultValue == null ? 0.0F : defaultValue); - } catch (NumberFormatException e) { - LOGGER.error("Cannot parse Float of {}: {} ", TagUtils.toString(tag), e.getMessage()); - } - return defaultValue; - } - - public static Integer getIntegerFromDicomElement( - Attributes dicom, int tag, Integer defaultValue) { - return getIntegerFromDicomElement(dicom, tag, null, defaultValue); - } - - public static Integer getIntegerFromDicomElement( - Attributes dicom, int tag, String privateCreatorID, Integer defaultValue) { - if (dicom == null || !dicom.containsValue(tag)) { - return defaultValue; - } - try { - return dicom.getInt(privateCreatorID, tag, defaultValue == null ? 0 : defaultValue); - } catch (NumberFormatException e) { - LOGGER.error("Cannot parse Integer of {}: {} ", TagUtils.toString(tag), e.getMessage()); - } - return defaultValue; - } - - public static Long getLongFromDicomElement(Attributes dicom, int tag, Long defaultValue) { - return getLongFromDicomElement(dicom, tag, null, defaultValue); - } - - public static Long getLongFromDicomElement( - Attributes dicom, int tag, String privateCreatorID, Long defaultValue) { - if (dicom == null || !dicom.containsValue(tag)) { - return defaultValue; - } - try { - return dicom.getLong(privateCreatorID, tag, defaultValue == null ? 0L : defaultValue); - } catch (NumberFormatException e) { - LOGGER.error("Cannot parse Long of {}: {} ", TagUtils.toString(tag), e.getMessage()); - } - return defaultValue; - } - - public static Double getDoubleFromDicomElement(Attributes dicom, int tag, Double defaultValue) { - return getDoubleFromDicomElement(dicom, tag, null, defaultValue); - } - - public static Double getDoubleFromDicomElement( - Attributes dicom, int tag, String privateCreatorID, Double defaultValue) { - if (dicom == null || !dicom.containsValue(tag)) { - return defaultValue; - } - try { - return dicom.getDouble(privateCreatorID, tag, defaultValue == null ? 0.0 : defaultValue); - } catch (NumberFormatException e) { - LOGGER.error("Cannot parse Double of {}: {} ", TagUtils.toString(tag), e.getMessage()); - } - return defaultValue; - } - - public static int[] getIntArrayFromDicomElement(Attributes dicom, int tag, int[] defaultValue) { - return getIntArrayFromDicomElement(dicom, tag, null, defaultValue); - } - - public static int[] getIntArrayFromDicomElement( - Attributes dicom, int tag, String privateCreatorID, int[] defaultValue) { - if (dicom == null || !dicom.containsValue(tag)) { - return defaultValue; - } - try { - return dicom.getInts(privateCreatorID, tag); - } catch (NumberFormatException e) { - LOGGER.error("Cannot parse int[] of {}: {} ", TagUtils.toString(tag), e.getMessage()); - } - return defaultValue; - } - - public static float[] getFloatArrayFromDicomElement( - Attributes dicom, int tag, float[] defaultValue) { - return getFloatArrayFromDicomElement(dicom, tag, null, defaultValue); - } - - public static float[] getFloatArrayFromDicomElement( - Attributes dicom, int tag, String privateCreatorID, float[] defaultValue) { - if (dicom == null || !dicom.containsValue(tag)) { - return defaultValue; - } - try { - return dicom.getFloats(privateCreatorID, tag); - } catch (NumberFormatException e) { - LOGGER.error("Cannot parse float[] of {}: {} ", TagUtils.toString(tag), e.getMessage()); - } - return defaultValue; - } - - public static double[] getDoubleArrayFromDicomElement( - Attributes dicom, int tag, double[] defaultValue) { - return getDoubleArrayFromDicomElement(dicom, tag, null, defaultValue); - } - - public static double[] getDoubleArrayFromDicomElement( - Attributes dicom, int tag, String privateCreatorID, double[] defaultValue) { - if (dicom == null || !dicom.containsValue(tag)) { - return defaultValue; - } - try { - return dicom.getDoubles(privateCreatorID, tag); - } catch (NumberFormatException e) { - LOGGER.error("Cannot parse double[] of {}: {} ", TagUtils.toString(tag), e.getMessage()); - } - return defaultValue; - } - public static boolean hasOverlay(Attributes attrs) { if (attrs != null) { for (int i = 0; i < 16; i++) { @@ -542,7 +288,7 @@ else if (TagD.getUID(Level.SERIES).equals(group.getTagID())) { DicomMediaIO.tagManager.readTags(Level.SERIES, header, group); // Build patient age if not present group.setTagNoNull( - TagD.get(Tag.PatientAge), getPatientAgeInPeriod(header, Tag.PatientAge, true)); + TagD.get(Tag.PatientAge), DicomUtils.getPatientAgeInPeriod(header, Tag.PatientAge, true)); } } @@ -683,7 +429,7 @@ public static void computeSUVFactor(Attributes dicomObject, Taggable taggable, i // http://qibawiki.rsna.org/index.php?title=Standardized_Uptake_Value_%28SUV%29 String modality = TagD.getTagValue(taggable, Tag.Modality, String.class); if ("PT".equals(modality)) { - String correctedImage = getStringFromDicomElement(dicomObject, Tag.CorrectedImage); + String correctedImage = DicomUtils.getStringFromDicomElement(dicomObject, Tag.CorrectedImage); if (correctedImage != null && correctedImage.contains("ATTN") && correctedImage.contains("DECY")) { // NON-NLS @@ -712,22 +458,26 @@ public static void computeSUVFactor(Attributes dicomObject, Taggable taggable, i // GML = grams/milliliter // STDDEV = standard deviations if ("BQML".equals(units)) { - Float weight = getFloatFromDicomElement(dicomObject, Tag.PatientWeight, 0.0f); // in Kg + Float weight = + DicomUtils.getFloatFromDicomElement(dicomObject, Tag.PatientWeight, 0.0f); // in Kg if (MathUtil.isDifferentFromZero(weight)) { Attributes dcm = dicomObject.getNestedDataset(Tag.RadiopharmaceuticalInformationSequence, index); if (dcm != null) { - Float totalDose = getFloatFromDicomElement(dcm, Tag.RadionuclideTotalDose, null); - Float halfLife = getFloatFromDicomElement(dcm, Tag.RadionuclideHalfLife, null); + Float totalDose = + DicomUtils.getFloatFromDicomElement(dcm, Tag.RadionuclideTotalDose, null); + Float halfLife = + DicomUtils.getFloatFromDicomElement(dcm, Tag.RadionuclideHalfLife, null); Date injectTime = - getDateFromDicomElement(dcm, Tag.RadiopharmaceuticalStartTime, null); + DicomUtils.getDateFromDicomElement(dcm, Tag.RadiopharmaceuticalStartTime, null); Date injectDateTime = - getDateFromDicomElement(dcm, Tag.RadiopharmaceuticalStartDateTime, null); + DicomUtils.getDateFromDicomElement( + dcm, Tag.RadiopharmaceuticalStartDateTime, null); Date acquisitionDateTime = TagUtil.dateTime( - getDateFromDicomElement(dicomObject, Tag.AcquisitionDate, null), - getDateFromDicomElement(dicomObject, Tag.AcquisitionTime, null)); - Date scanDate = getDateFromDicomElement(dicomObject, Tag.SeriesDate, null); + DicomUtils.getDateFromDicomElement(dicomObject, Tag.AcquisitionDate, null), + DicomUtils.getDateFromDicomElement(dicomObject, Tag.AcquisitionTime, null)); + Date scanDate = DicomUtils.getDateFromDicomElement(dicomObject, Tag.SeriesDate, null); if ("START".equals(dicomObject.getString(Tag.DecayCorrection)) && totalDose != null && halfLife != null @@ -736,13 +486,15 @@ public static void computeSUVFactor(Attributes dicomObject, Taggable taggable, i double time = 0.0; long scanDateTime = TagUtil.dateTime( - scanDate, getDateFromDicomElement(dicomObject, Tag.SeriesTime, null)) + scanDate, + DicomUtils.getDateFromDicomElement(dicomObject, Tag.SeriesTime, null)) .getTime(); if (injectDateTime == null) { if (scanDateTime > acquisitionDateTime.getTime()) { // per GE docs, may have been updated during post-processing into new series String privateCreator = dicomObject.getString(0x00090010); - Date privateScanDateTime = getDateFromDicomElement(dcm, 0x0009100d, null); + Date privateScanDateTime = + DicomUtils.getDateFromDicomElement(dcm, 0x0009100d, null); if ("GEMS_PETD_01".equals(privateCreator) // NON-NLS && privateScanDateTime != null) { scanDate = privateScanDateTime; diff --git a/weasis-dicom/weasis-dicom-codec/src/main/java/org/weasis/dicom/codec/utils/Ultrasound.java b/weasis-dicom/weasis-dicom-codec/src/main/java/org/weasis/dicom/codec/utils/Ultrasound.java index 0d43225c2..a7ec7f274 100755 --- a/weasis-dicom/weasis-dicom-codec/src/main/java/org/weasis/dicom/codec/utils/Ultrasound.java +++ b/weasis-dicom/weasis-dicom-codec/src/main/java/org/weasis/dicom/codec/utils/Ultrasound.java @@ -16,6 +16,7 @@ import org.dcm4che3.data.Attributes; import org.dcm4che3.data.Sequence; import org.dcm4che3.data.Tag; +import org.dcm4che3.img.util.DicomUtils; public class Ultrasound { @@ -44,11 +45,11 @@ public static Attributes getUniqueSpatialRegion(Attributes attributes) { spatialCalib = r; } else { Double calib1X = - DicomMediaUtils.getDoubleFromDicomElement(spatialCalib, Tag.PhysicalDeltaX, null); + DicomUtils.getDoubleFromDicomElement(spatialCalib, Tag.PhysicalDeltaX, null); Double calib1Y = - DicomMediaUtils.getDoubleFromDicomElement(spatialCalib, Tag.PhysicalDeltaY, null); - Double calib2X = DicomMediaUtils.getDoubleFromDicomElement(r, Tag.PhysicalDeltaX, null); - Double calib2Y = DicomMediaUtils.getDoubleFromDicomElement(r, Tag.PhysicalDeltaY, null); + DicomUtils.getDoubleFromDicomElement(spatialCalib, Tag.PhysicalDeltaY, null); + Double calib2X = DicomUtils.getDoubleFromDicomElement(r, Tag.PhysicalDeltaX, null); + Double calib2Y = DicomUtils.getDoubleFromDicomElement(r, Tag.PhysicalDeltaY, null); if (!Objects.equals(calib1X, calib2X) || !Objects.equals(calib1Y, calib2Y)) { return null; // currently, cannot handle multiple spatial calibration } @@ -60,9 +61,9 @@ public static Attributes getUniqueSpatialRegion(Attributes attributes) { public static Integer getUnitsForXY(Attributes region) { Integer unitX = - DicomMediaUtils.getIntegerFromDicomElement(region, Tag.PhysicalUnitsXDirection, null); + DicomUtils.getIntegerFromDicomElement(region, Tag.PhysicalUnitsXDirection, null); Integer unitY = - DicomMediaUtils.getIntegerFromDicomElement(region, Tag.PhysicalUnitsYDirection, null); + DicomUtils.getIntegerFromDicomElement(region, Tag.PhysicalUnitsYDirection, null); if (unitX != null && unitX.equals(unitY)) { return unitX; } diff --git a/weasis-dicom/weasis-dicom-codec/src/test/java/org/weasis/dicom/codec/utils/DicomMediaUtilsTest.java b/weasis-dicom/weasis-dicom-codec/src/test/java/org/weasis/dicom/codec/utils/DicomMediaUtilsTest.java deleted file mode 100755 index cef40928c..000000000 --- a/weasis-dicom/weasis-dicom-codec/src/test/java/org/weasis/dicom/codec/utils/DicomMediaUtilsTest.java +++ /dev/null @@ -1,100 +0,0 @@ -/* - * Copyright (c) 2009-2020 Weasis Team and other contributors. - * - * This program and the accompanying materials are made available under the terms of the Eclipse - * Public License 2.0 which is available at https://www.eclipse.org/legal/epl-2.0, or the Apache - * License, Version 2.0 which is available at https://www.apache.org/licenses/LICENSE-2.0. - * - * SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 - */ -package org.weasis.dicom.codec.utils; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.assertThatThrownBy; - -import java.time.LocalDate; -import org.dcm4che3.data.Attributes; -import org.dcm4che3.data.Tag; -import org.dcm4che3.data.VR; -import org.junit.jupiter.api.BeforeAll; -import org.junit.jupiter.api.Test; -import org.weasis.dicom.codec.TagD; - -class DicomMediaUtilsTest { - public static final String[] STRING_ARRAY = {"RECTANGULAR", "CIRCULAR", "POLYGONAL"}; // NON-NLS - - private static final Attributes attributes = new Attributes(); - - @BeforeAll - static void setup() { - attributes.setString(Tag.ShutterShape, VR.CS, STRING_ARRAY); - } - - @Test - void testGetPeriod() { - assertThat( - DicomMediaUtils.getPeriod(TagD.getDicomDate("19610625"), TagD.getDicomDate("20120624"))) - .isEqualTo("050Y"); // NON-NLS - assertThat( - DicomMediaUtils.getPeriod(TagD.getDicomDate("19610625"), TagD.getDicomDate("20120625"))) - .isEqualTo("051Y"); // NON-NLS - assertThat( - DicomMediaUtils.getPeriod(TagD.getDicomDate("19610714"), TagD.getDicomDate("20120625"))) - .isEqualTo("050Y"); // NON-NLS - - assertThat( - DicomMediaUtils.getPeriod(TagD.getDicomDate("20120103"), TagD.getDicomDate("20120625"))) - .isEqualTo("005M"); // NON-NLS - assertThat( - DicomMediaUtils.getPeriod(TagD.getDicomDate("20120525"), TagD.getDicomDate("20120625"))) - .isEqualTo("031D"); // NON-NLS - assertThat( - DicomMediaUtils.getPeriod(TagD.getDicomDate("20120622"), TagD.getDicomDate("20120625"))) - .isEqualTo("003D"); // NON-NLS - - assertThat( - DicomMediaUtils.getPeriod(TagD.getDicomDate("20000229"), TagD.getDicomDate("20110301"))) - .isEqualTo("011Y"); // NON-NLS - assertThat( - DicomMediaUtils.getPeriod(TagD.getDicomDate("20000229"), TagD.getDicomDate("20110228"))) - .isEqualTo("010Y"); // NON-NLS - assertThat( - DicomMediaUtils.getPeriod(TagD.getDicomDate("20000229"), TagD.getDicomDate("20120228"))) - .isEqualTo("011Y"); // NON-NLS - assertThat( - DicomMediaUtils.getPeriod(TagD.getDicomDate("20000229"), TagD.getDicomDate("20120229"))) - .isEqualTo("012Y"); // NON-NLS - assertThat( - DicomMediaUtils.getPeriod(TagD.getDicomDate("20000229"), TagD.getDicomDate("20120301"))) - .isEqualTo("012Y"); // NON-NLS - assertThat( - DicomMediaUtils.getPeriod(TagD.getDicomDate("20000228"), TagD.getDicomDate("20120228"))) - .isEqualTo("012Y"); // NON-NLS - assertThat( - DicomMediaUtils.getPeriod(TagD.getDicomDate("20000228"), TagD.getDicomDate("20120229"))) - .isEqualTo("012Y"); // NON-NLS - - LocalDate date1 = TagD.getDicomDate("20000228"); - LocalDate date2 = TagD.getDicomDate("20122406"); // invalid => null - assertThatThrownBy(() -> DicomMediaUtils.getPeriod(date1, date2)) - .isInstanceOf(NullPointerException.class); - } - - @Test - void testGetStringFromDicomElement() { - assertThat(DicomMediaUtils.getStringFromDicomElement(attributes, Tag.ShutterShape)) - .isEqualTo("RECTANGULAR\\CIRCULAR\\POLYGONAL"); // NON-NLS - assertThat(DicomMediaUtils.getStringFromDicomElement(attributes, Tag.ShutterPresentationValue)) - .isNull(); - } - - @Test - void testGetStringArrayFromDicomElementAttributesInt() { - assertThat(DicomMediaUtils.getStringArrayFromDicomElement(attributes, Tag.ShutterShape)) - .containsExactly(STRING_ARRAY); - assertThat( - DicomMediaUtils.getStringArrayFromDicomElement( - attributes, Tag.ShutterPresentationValue)) - .isNull(); - } -} diff --git a/weasis-dicom/weasis-dicom-explorer/src/main/java/org/weasis/dicom/explorer/DicomDirLoader.java b/weasis-dicom/weasis-dicom-explorer/src/main/java/org/weasis/dicom/explorer/DicomDirLoader.java index b6c5829cd..74e0b6e99 100755 --- a/weasis-dicom/weasis-dicom-explorer/src/main/java/org/weasis/dicom/explorer/DicomDirLoader.java +++ b/weasis-dicom/weasis-dicom-explorer/src/main/java/org/weasis/dicom/explorer/DicomDirLoader.java @@ -24,6 +24,7 @@ import org.dcm4che3.img.Transcoder; import org.dcm4che3.img.stream.BytesWithImageDescriptor; import org.dcm4che3.img.stream.ImageDescriptor; +import org.dcm4che3.img.util.DicomUtils; import org.dcm4che3.media.DicomDirReader; import org.dcm4che3.media.DicomDirWriter; import org.dcm4che3.media.RecordFactory; @@ -200,7 +201,7 @@ private void parseSeries( String sopInstanceUID = instance.getString(Tag.ReferencedSOPInstanceUIDInFile); if (sopInstanceUID != null) { Integer frame = - DicomMediaUtils.getIntegerFromDicomElement(instance, Tag.InstanceNumber, null); + DicomUtils.getIntegerFromDicomElement(instance, Tag.InstanceNumber, null); SopInstance sop = seriesInstanceList.getSopInstance(sopInstanceUID, frame); if (sop == null) { File file = toFileName(instance, reader); diff --git a/weasis-dicom/weasis-dicom-explorer/src/main/java/org/weasis/dicom/explorer/pr/DicomPrSerializer.java b/weasis-dicom/weasis-dicom-explorer/src/main/java/org/weasis/dicom/explorer/pr/DicomPrSerializer.java index 53721bd2c..a46381c78 100755 --- a/weasis-dicom/weasis-dicom-explorer/src/main/java/org/weasis/dicom/explorer/pr/DicomPrSerializer.java +++ b/weasis-dicom/weasis-dicom-explorer/src/main/java/org/weasis/dicom/explorer/pr/DicomPrSerializer.java @@ -395,11 +395,11 @@ public static void transformShapeToContour(Graphic graphic, Sequence graphicSeq) dcm = getBasicGraphic(graphic); points.add(new Point2D.Double(pts[0], pts[1])); } - case PathIterator.SEG_LINETO, PathIterator.SEG_CLOSE -> points.add( - new Point2D.Double(pts[0], pts[1])); + case PathIterator.SEG_LINETO, PathIterator.SEG_CLOSE -> + points.add(new Point2D.Double(pts[0], pts[1])); case PathIterator.SEG_CUBICTO, PathIterator.SEG_QUADTO -> - // should never append with FlatteningPathIterator - throw new IllegalStateException("cubic iterator is not supported"); + // should never append with FlatteningPathIterator + throw new IllegalStateException("cubic iterator is not supported"); } iterator.next(); } diff --git a/weasis-dicom/weasis-dicom-explorer/src/main/java/org/weasis/dicom/explorer/pr/PrGraphicUtil.java b/weasis-dicom/weasis-dicom-explorer/src/main/java/org/weasis/dicom/explorer/pr/PrGraphicUtil.java index acafa7043..58c1aa481 100755 --- a/weasis-dicom/weasis-dicom-explorer/src/main/java/org/weasis/dicom/explorer/pr/PrGraphicUtil.java +++ b/weasis-dicom/weasis-dicom-explorer/src/main/java/org/weasis/dicom/explorer/pr/PrGraphicUtil.java @@ -23,6 +23,7 @@ import org.dcm4che3.data.Tag; import org.dcm4che3.img.data.CIELab; import org.dcm4che3.img.util.DicomObjectUtil; +import org.dcm4che3.img.util.DicomUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.weasis.core.api.media.data.ImageElement; @@ -38,7 +39,6 @@ import org.weasis.core.ui.serialize.XmlSerializer; import org.weasis.core.util.MathUtil; import org.weasis.dicom.codec.PresentationStateReader; -import org.weasis.dicom.codec.utils.DicomMediaUtils; public class PrGraphicUtil { private static final Logger LOGGER = LoggerFactory.getLogger(PrGraphicUtil.class); @@ -79,10 +79,10 @@ public static Graphic buildGraphic( boolean isDisp = !dcmSR && "DISPLAY".equalsIgnoreCase(go.getString(Tag.GraphicAnnotationUnits)); String type = go.getString(Tag.GraphicType); - Integer groupID = DicomMediaUtils.getIntegerFromDicomElement(go, Tag.GraphicGroupID, null); + Integer groupID = DicomUtils.getIntegerFromDicomElement(go, Tag.GraphicGroupID, null); boolean filled = getBooleanValue(go, Tag.GraphicFilled); Attributes style = go.getNestedDataset(Tag.LineStyleSequence); - Float thickness = DicomMediaUtils.getFloatFromDicomElement(style, Tag.LineThickness, 1.0f); + Float thickness = DicomUtils.getFloatFromDicomElement(style, Tag.LineThickness, 1.0f); boolean dashed = isDashedLine(style); Color color = getPatternColor(style, defaultColor); @@ -90,7 +90,7 @@ public static Graphic buildGraphic( color = getFillPatternColor(fillStyle, color); Graphic shape = null; - float[] points = DicomMediaUtils.getFloatArrayFromDicomElement(go, Tag.GraphicData, null); + float[] points = DicomUtils.getFloatArrayFromDicomElement(go, Tag.GraphicData, null); if (isDisp && inverse != null) { float[] dstpoints = new float[points.length]; inverse.transform(points, 0, dstpoints, 0, points.length / 2); @@ -296,8 +296,7 @@ public static Color getPatternColor(Attributes style, Color defaultColor) { if (style != null) { int[] rgb = CIELab.dicomLab2rgb(style.getInts(Tag.PatternOnColorCIELabValue)); color = DicomObjectUtil.getRGBColor(0xFFFF, rgb); - Float fillOpacity = - DicomMediaUtils.getFloatFromDicomElement(style, Tag.PatternOnOpacity, null); + Float fillOpacity = DicomUtils.getFloatFromDicomElement(style, Tag.PatternOnOpacity, null); if (fillOpacity != null && fillOpacity < 1.0F) { int opacity = (int) (fillOpacity * 255); color = new Color((opacity << 24) | (color.getRGB() & 0x00ffffff), true); @@ -333,10 +332,10 @@ public static Graphic buildCompoundGraphic( String type = go.getString(Tag.CompoundGraphicType); String id = go.getString(Tag.CompoundGraphicInstanceID); - Integer groupID = DicomMediaUtils.getIntegerFromDicomElement(go, Tag.GraphicGroupID, null); + Integer groupID = DicomUtils.getIntegerFromDicomElement(go, Tag.GraphicGroupID, null); boolean filled = getBooleanValue(go, Tag.GraphicFilled); Attributes style = go.getNestedDataset(Tag.LineStyleSequence); - Float thickness = DicomMediaUtils.getFloatFromDicomElement(style, Tag.LineThickness, 1.0f); + Float thickness = DicomUtils.getFloatFromDicomElement(style, Tag.LineThickness, 1.0f); boolean dashed = isDashedLine(style); Color color = getPatternColor(style, defaultColor); @@ -344,7 +343,7 @@ public static Graphic buildCompoundGraphic( color = getFillPatternColor(fillStyle, color); Graphic shape = null; - float[] points = DicomMediaUtils.getFloatArrayFromDicomElement(go, Tag.GraphicData, null); + float[] points = DicomUtils.getFloatArrayFromDicomElement(go, Tag.GraphicData, null); if (isDisp && inverse != null) { float[] dstpoints = new float[points.length]; inverse.transform(points, 0, dstpoints, 0, points.length / 2); diff --git a/weasis-dicom/weasis-dicom-explorer/src/main/java/org/weasis/dicom/explorer/rs/RsQueryResult.java b/weasis-dicom/weasis-dicom-explorer/src/main/java/org/weasis/dicom/explorer/rs/RsQueryResult.java index 5d60e1b12..40580fea4 100755 --- a/weasis-dicom/weasis-dicom-explorer/src/main/java/org/weasis/dicom/explorer/rs/RsQueryResult.java +++ b/weasis-dicom/weasis-dicom-explorer/src/main/java/org/weasis/dicom/explorer/rs/RsQueryResult.java @@ -22,6 +22,7 @@ import java.util.Set; import org.dcm4che3.data.Attributes; import org.dcm4che3.data.Tag; +import org.dcm4che3.img.util.DicomUtils; import org.dcm4che3.json.JSONReader; import org.dcm4che3.json.JSONReader.Callback; import org.slf4j.Logger; @@ -40,7 +41,6 @@ import org.weasis.dicom.codec.DicomSeries; import org.weasis.dicom.codec.TagD; import org.weasis.dicom.codec.TagD.Level; -import org.weasis.dicom.codec.utils.DicomMediaUtils; import org.weasis.dicom.codec.utils.PatientComparator; import org.weasis.dicom.codec.utils.SeriesInstanceList; import org.weasis.dicom.explorer.DicomModel; @@ -484,7 +484,7 @@ public static void addSopInstance( Attributes instanceDataSet, SeriesInstanceList seriesInstanceList, String seriesRetrieveURL) { String sopUID = instanceDataSet.getString(Tag.SOPInstanceUID); Integer frame = - DicomMediaUtils.getIntegerFromDicomElement(instanceDataSet, Tag.InstanceNumber, null); + DicomUtils.getIntegerFromDicomElement(instanceDataSet, Tag.InstanceNumber, null); SopInstance sop = seriesInstanceList.getSopInstance(sopUID, frame); if (sop == null) { diff --git a/weasis-dicom/weasis-dicom-qr/src/main/java/org/weasis/dicom/qr/manisfest/CFindQueryResult.java b/weasis-dicom/weasis-dicom-qr/src/main/java/org/weasis/dicom/qr/manisfest/CFindQueryResult.java index 4c66ae7d9..43e8c1758 100755 --- a/weasis-dicom/weasis-dicom-qr/src/main/java/org/weasis/dicom/qr/manisfest/CFindQueryResult.java +++ b/weasis-dicom/weasis-dicom-qr/src/main/java/org/weasis/dicom/qr/manisfest/CFindQueryResult.java @@ -12,10 +12,10 @@ import java.util.List; import org.dcm4che3.data.Attributes; import org.dcm4che3.data.Tag; +import org.dcm4che3.img.util.DicomUtils; import org.dcm4che3.net.service.QueryRetrieveLevel; import org.weasis.core.api.media.data.MediaSeriesGroup; import org.weasis.core.util.StringUtil; -import org.weasis.dicom.codec.utils.DicomMediaUtils; import org.weasis.dicom.explorer.DicomModel; import org.weasis.dicom.explorer.mf.DicomModelQueryResult; import org.weasis.dicom.mf.AbstractQueryResult; @@ -118,7 +118,7 @@ private static void fillInstance( for (Attributes instanceDataSet : instances) { Integer frame = - DicomMediaUtils.getIntegerFromDicomElement(instanceDataSet, Tag.InstanceNumber, null); + DicomUtils.getIntegerFromDicomElement(instanceDataSet, Tag.InstanceNumber, null); String sopUID = instanceDataSet.getString(Tag.SOPInstanceUID); SopInstance sop = s.getSopInstance(sopUID, frame); if (sop == null) { diff --git a/weasis-dicom/weasis-dicom-rt/src/main/java/org/weasis/dicom/rt/RtSet.java b/weasis-dicom/weasis-dicom-rt/src/main/java/org/weasis/dicom/rt/RtSet.java index fc4c6901c..56a9549cc 100755 --- a/weasis-dicom/weasis-dicom-rt/src/main/java/org/weasis/dicom/rt/RtSet.java +++ b/weasis-dicom/weasis-dicom-rt/src/main/java/org/weasis/dicom/rt/RtSet.java @@ -32,6 +32,7 @@ import org.dcm4che3.data.Tag; import org.dcm4che3.data.UID; import org.dcm4che3.img.util.DicomObjectUtil; +import org.dcm4che3.img.util.DicomUtils; import org.joml.Vector3d; import org.opencv.core.CvType; import org.opencv.core.Mat; @@ -48,7 +49,6 @@ import org.weasis.dicom.codec.DcmMediaReader; import org.weasis.dicom.codec.DicomImageElement; import org.weasis.dicom.codec.TagD; -import org.weasis.dicom.codec.utils.DicomMediaUtils; /** * RtSet is a collection of linked DICOM-RT entities that form the whole treatment case (Plans, @@ -313,14 +313,12 @@ private void initStructures(RtSpecialElement rtElement) { // Determine all the plane properties plane.setGeometricType(contour.getString(Tag.ContourGeometricType)); plane.setContourSlabThickness( - DicomMediaUtils.getDoubleFromDicomElement( - contour, Tag.ContourSlabThickness, null)); + DicomUtils.getDoubleFromDicomElement(contour, Tag.ContourSlabThickness, null)); plane.setContourOffsetVector( - DicomMediaUtils.getDoubleArrayFromDicomElement( + DicomUtils.getDoubleArrayFromDicomElement( contour, Tag.ContourOffsetVector, null)); Integer pts = - DicomMediaUtils.getIntegerFromDicomElement( - contour, Tag.NumberOfContourPoints, -1); + DicomUtils.getIntegerFromDicomElement(contour, Tag.NumberOfContourPoints, -1); plane.setContourPoints(pts); double[] points = contour.getDoubles(Tag.ContourData); @@ -420,7 +418,7 @@ private void initPlan(RtSpecialElement rtElement) { // Prescribed dose in Gy Double targetDose = - DicomMediaUtils.getDoubleFromDicomElement(doseRef, Tag.TargetPrescriptionDose, null); + DicomUtils.getDoubleFromDicomElement(doseRef, Tag.TargetPrescriptionDose, null); if (targetDose != null) { @@ -462,7 +460,7 @@ else if ("VOLUME".equals(doseRefStructType) if (MathUtil.isEqualToZero(plan.getRxDose())) { Attributes fractionGroup = dcmItems.getNestedDataset(Tag.FractionGroupSequence); Integer fx = - DicomMediaUtils.getIntegerFromDicomElement( + DicomUtils.getIntegerFromDicomElement( fractionGroup, Tag.NumberOfFractionsPlanned, null); if (fx != null) { Sequence refBeamSeq = fractionGroup.getSequence(Tag.ReferencedBeamSequence); @@ -470,8 +468,7 @@ else if ("VOLUME".equals(doseRefStructType) for (Attributes beam : refBeamSeq) { if (beam.contains(Tag.BeamDose) && beam.containsValue(Tag.BeamDose)) { Double rxDose = plan.getRxDose(); - Double beamDose = - DicomMediaUtils.getDoubleFromDicomElement(beam, Tag.BeamDose, null); + Double beamDose = DicomUtils.getDoubleFromDicomElement(beam, Tag.BeamDose, null); if (beamDose != null && rxDose != null) { plan.setRxDose(rxDose + (beamDose * fx * 100)); } diff --git a/weasis-dicom/weasis-dicom-sr/src/main/java/org/weasis/dicom/sr/SRDocumentContent.java b/weasis-dicom/weasis-dicom-sr/src/main/java/org/weasis/dicom/sr/SRDocumentContent.java index 1277a69b6..a8610fc41 100755 --- a/weasis-dicom/weasis-dicom-sr/src/main/java/org/weasis/dicom/sr/SRDocumentContent.java +++ b/weasis-dicom/weasis-dicom-sr/src/main/java/org/weasis/dicom/sr/SRDocumentContent.java @@ -11,7 +11,7 @@ import org.dcm4che3.data.Attributes; import org.dcm4che3.data.Tag; -import org.weasis.dicom.codec.utils.DicomMediaUtils; +import org.dcm4che3.img.util.DicomUtils; public class SRDocumentContent extends SRDocumentContentModule { @@ -24,7 +24,7 @@ public String getRelationshipType() { } public int[] getReferencedContentItemIdentifier() { - return DicomMediaUtils.getIntArrayFromDicomElement( + return DicomUtils.getIntAyrrayFromDicomElement( dcmItems, Tag.ReferencedContentItemIdentifier, null); } } diff --git a/weasis-dicom/weasis-dicom-viewer2d/src/main/java/org/weasis/dicom/viewer2d/PRManager.java b/weasis-dicom/weasis-dicom-viewer2d/src/main/java/org/weasis/dicom/viewer2d/PRManager.java index 904f4b867..1bcd147fc 100755 --- a/weasis-dicom/weasis-dicom-viewer2d/src/main/java/org/weasis/dicom/viewer2d/PRManager.java +++ b/weasis-dicom/weasis-dicom-viewer2d/src/main/java/org/weasis/dicom/viewer2d/PRManager.java @@ -29,6 +29,7 @@ import org.dcm4che3.img.data.PrDicomObject; import org.dcm4che3.img.lut.PresetWindowLevel; import org.dcm4che3.img.util.DicomObjectUtil; +import org.dcm4che3.img.util.DicomUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.weasis.core.api.gui.util.ActionState; @@ -65,7 +66,6 @@ import org.weasis.dicom.codec.PRSpecialElement; import org.weasis.dicom.codec.PresentationStateReader; import org.weasis.dicom.codec.TagD; -import org.weasis.dicom.codec.utils.DicomMediaUtils; import org.weasis.dicom.explorer.DicomModel; import org.weasis.dicom.explorer.pr.PrGraphicUtil; import org.weasis.opencv.data.PlanarImage; @@ -337,15 +337,15 @@ private static ArrayList readGraphicAnnotation( layers.add(layer); Integer grayVal = - DicomMediaUtils.getIntegerFromDicomElement( + DicomUtils.getIntegerFromDicomElement( glm, Tag.GraphicLayerRecommendedDisplayGrayscaleValue, null); int[] colorRgb = CIELab.dicomLab2rgb( - DicomMediaUtils.getIntArrayFromDicomElement( + DicomUtils.getIntAyrrayFromDicomElement( glm, Tag.GraphicLayerRecommendedDisplayCIELabValue, null)); if (colorRgb.length == 0) { colorRgb = - DicomMediaUtils.getIntArrayFromDicomElement( + DicomUtils.getIntAyrrayFromDicomElement( glm, Tag.GraphicLayerRecommendedDisplayRGBValue, null); if (colorRgb == null && grayVal == null) { Color c = @@ -378,8 +378,7 @@ private static ArrayList readGraphicAnnotation( if (txos != null) { for (Attributes txo : txos) { Attributes style = txo.getNestedDataset(Tag.LineStyleSequence); - Float thickness = - DicomMediaUtils.getFloatFromDicomElement(style, Tag.LineThickness, 1.0f); + Float thickness = DicomUtils.getFloatFromDicomElement(style, Tag.LineThickness, 1.0f); if (style != null) { int[] rgb = CIELab.dicomLab2rgb(style.getInts(Tag.PatternOnColorCIELabValue)); rgbColor = DicomObjectUtil.getRGBColor(0xFFFF, rgb); diff --git a/weasis-dicom/weasis-dicom-wave/src/main/java/org/weasis/dicom/wave/ChannelDefinition.java b/weasis-dicom/weasis-dicom-wave/src/main/java/org/weasis/dicom/wave/ChannelDefinition.java index cc3521c0a..b784a028c 100755 --- a/weasis-dicom/weasis-dicom-wave/src/main/java/org/weasis/dicom/wave/ChannelDefinition.java +++ b/weasis-dicom/weasis-dicom-wave/src/main/java/org/weasis/dicom/wave/ChannelDefinition.java @@ -12,8 +12,8 @@ import java.util.Objects; import org.dcm4che3.data.Attributes; import org.dcm4che3.data.Tag; +import org.dcm4che3.img.util.DicomUtils; import org.weasis.dicom.codec.macro.Code; -import org.weasis.dicom.codec.utils.DicomMediaUtils; public class ChannelDefinition { @@ -35,8 +35,7 @@ public ChannelDefinition(Attributes dcm, int position) { Objects.requireNonNull( dcm.getNestedDataset(Tag.ChannelSourceSequence), "no ChannelSourceSequence"); this.lead = Lead.buildLead(new Code(channelSourceSequence)); - Double chSensisvity = - DicomMediaUtils.getDoubleFromDicomElement(dcm, Tag.ChannelSensitivity, null); + Double chSensisvity = DicomUtils.getDoubleFromDicomElement(dcm, Tag.ChannelSensitivity, null); if (chSensisvity == null) { this.baseline = 0.0; this.amplitudeUnit = @@ -45,10 +44,9 @@ public ChannelDefinition(Attributes dcm, int position) { org.weasis.core.api.image.util.Unit.PIXEL.getAbbreviation(), 1.0); } else { - this.baseline = DicomMediaUtils.getDoubleFromDicomElement(dcm, Tag.ChannelBaseline, 0.0); + this.baseline = DicomUtils.getDoubleFromDicomElement(dcm, Tag.ChannelBaseline, 0.0); Double sCorrectionFactor = - DicomMediaUtils.getDoubleFromDicomElement( - dcm, Tag.ChannelSensitivityCorrectionFactor, 1.0); + DicomUtils.getDoubleFromDicomElement(dcm, Tag.ChannelSensitivityCorrectionFactor, 1.0); Attributes chs = Objects.requireNonNull( dcm.getNestedDataset(Tag.ChannelSensitivityUnitsSequence), diff --git a/weasis-dicom/weasis-dicom-wave/src/main/java/org/weasis/dicom/wave/WaveView.java b/weasis-dicom/weasis-dicom-wave/src/main/java/org/weasis/dicom/wave/WaveView.java index a33124bc0..583eb9730 100755 --- a/weasis-dicom/weasis-dicom-wave/src/main/java/org/weasis/dicom/wave/WaveView.java +++ b/weasis-dicom/weasis-dicom-wave/src/main/java/org/weasis/dicom/wave/WaveView.java @@ -39,6 +39,7 @@ import org.dcm4che3.data.BulkData; import org.dcm4che3.data.Sequence; import org.dcm4che3.data.Tag; +import org.dcm4che3.img.util.DicomUtils; import org.dcm4che3.util.StreamUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -57,7 +58,6 @@ import org.weasis.dicom.codec.DicomMediaIO; import org.weasis.dicom.codec.DicomSpecialElement; import org.weasis.dicom.codec.TagD; -import org.weasis.dicom.codec.utils.DicomMediaUtils; import org.weasis.dicom.explorer.DicomExplorer; import org.weasis.dicom.explorer.DicomModel; import org.weasis.dicom.wave.dockable.MeasureAnnotationTool; @@ -265,7 +265,7 @@ private void displayECG(DicomSpecialElement media) throws Exception { Attributes dcm = Optional.of(attributes.getNestedDataset(Tag.WaveformSequence)).get(); this.channelNumber = - DicomMediaUtils.getIntegerFromDicomElement(dcm, Tag.NumberOfWaveformChannels, 0); + DicomUtils.getIntegerFromDicomElement(dcm, Tag.NumberOfWaveformChannels, 0); Sequence chDefSeq = Optional.of(dcm.getSequence(Tag.ChannelDefinitionSequence)).get(); this.channels.clear(); for (int i = 0; i < chDefSeq.size(); i++) { @@ -276,8 +276,8 @@ private void displayECG(DicomSpecialElement media) throws Exception { String originality = dcm.getString(Tag.WaveformOriginality); this.sampleNumber = - DicomMediaUtils.getIntegerFromDicomElement(dcm, Tag.NumberOfWaveformSamples, 0); - double frequency = DicomMediaUtils.getDoubleFromDicomElement(dcm, Tag.SamplingFrequency, 1.0); + DicomUtils.getIntegerFromDicomElement(dcm, Tag.NumberOfWaveformSamples, 0); + double frequency = DicomUtils.getDoubleFromDicomElement(dcm, Tag.SamplingFrequency, 1.0); this.seconds = sampleNumber / frequency; this.samplesPerSecond = (int) (sampleNumber / seconds); @@ -346,8 +346,7 @@ private void readWaveformData(Attributes dcm) throws IOException { throw new IOException("Cannot read Waveform data"); } - int bitsAllocated = - DicomMediaUtils.getIntegerFromDicomElement(dcm, Tag.WaveformBitsAllocated, 0); + int bitsAllocated = DicomUtils.getIntegerFromDicomElement(dcm, Tag.WaveformBitsAllocated, 0); ByteBuffer byteBuffer = ByteBuffer.wrap(array.toByteArray()); byteBuffer.order(dcm.bigEndian() ? ByteOrder.BIG_ENDIAN : ByteOrder.LITTLE_ENDIAN); diff --git a/weasis-dicom/weasis-dicom-wave/src/main/java/org/weasis/dicom/wave/dockable/MeasureAnnotationTool.java b/weasis-dicom/weasis-dicom-wave/src/main/java/org/weasis/dicom/wave/dockable/MeasureAnnotationTool.java index 5f3458049..5ca30bb94 100755 --- a/weasis-dicom/weasis-dicom-wave/src/main/java/org/weasis/dicom/wave/dockable/MeasureAnnotationTool.java +++ b/weasis-dicom/weasis-dicom-wave/src/main/java/org/weasis/dicom/wave/dockable/MeasureAnnotationTool.java @@ -29,6 +29,7 @@ import org.dcm4che3.data.Attributes; import org.dcm4che3.data.Sequence; import org.dcm4che3.data.Tag; +import org.dcm4che3.img.util.DicomUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.weasis.core.api.gui.Insertable; @@ -47,7 +48,6 @@ import org.weasis.core.util.StringUtil; import org.weasis.dicom.codec.DicomSpecialElement; import org.weasis.dicom.codec.TagD; -import org.weasis.dicom.codec.utils.DicomMediaUtils; import org.weasis.dicom.explorer.DicomModel; import org.weasis.dicom.wave.Messages; @@ -259,20 +259,18 @@ private void readFiltersFrequency(Attributes attributes, List list) { if (!chDefSeq.isEmpty()) { Attributes item = chDefSeq.get(0); - double filterLow = - DicomMediaUtils.getDoubleFromDicomElement(item, Tag.FilterLowFrequency, 0.0); + double filterLow = DicomUtils.getDoubleFromDicomElement(item, Tag.FilterLowFrequency, 0.0); addValueToModel(list, TagD.get(Tag.FilterLowFrequency), filterLow + " Hz"); // NON-NLS - double filterHigh = - DicomMediaUtils.getDoubleFromDicomElement(item, Tag.FilterHighFrequency, 0.0); + double filterHigh = DicomUtils.getDoubleFromDicomElement(item, Tag.FilterHighFrequency, 0.0); addValueToModel(list, TagD.get(Tag.FilterHighFrequency), filterHigh + " Hz"); // NON-NLS double notchFilter = - DicomMediaUtils.getDoubleFromDicomElement(item, Tag.NotchFilterFrequency, 0.0); + DicomUtils.getDoubleFromDicomElement(item, Tag.NotchFilterFrequency, 0.0); addValueToModel(list, TagD.get(Tag.NotchFilterFrequency), notchFilter + " Hz"); // NON-NLS for (int i = 1; i < chDefSeq.size(); i++) { item = chDefSeq.get(i); String title = item.getNestedDataset(Tag.ChannelSourceSequence).getString(Tag.CodeMeaning); - double low = DicomMediaUtils.getDoubleFromDicomElement(item, Tag.FilterLowFrequency, 0.0); + double low = DicomUtils.getDoubleFromDicomElement(item, Tag.FilterLowFrequency, 0.0); if (low != filterLow) { addValueToModel( list, @@ -280,7 +278,7 @@ private void readFiltersFrequency(Attributes attributes, List list) { low + " Hz"); // NON-NLS } - double high = DicomMediaUtils.getDoubleFromDicomElement(item, Tag.FilterHighFrequency, 0.0); + double high = DicomUtils.getDoubleFromDicomElement(item, Tag.FilterHighFrequency, 0.0); if (high != filterHigh) { addValueToModel( list, @@ -288,8 +286,7 @@ private void readFiltersFrequency(Attributes attributes, List list) { high + " Hz"); // NON-NLS } - double notch = - DicomMediaUtils.getDoubleFromDicomElement(item, Tag.NotchFilterFrequency, 0.0); + double notch = DicomUtils.getDoubleFromDicomElement(item, Tag.NotchFilterFrequency, 0.0); if (notch != notchFilter) { addValueToModel( list,