public int[] getInts(int tag) { return getInts(null, tag, null); }
public int[] getInts(String privateCreator, int tag) { return getInts(privateCreator, tag, null); }
public int[] getDataElementsSigned() { return dcmItems.getInts(Tag.DataElementsSigned); }
private int[] lutDescriptor(Attributes ds, int descTag) { int[] desc = ds.getInts(descTag); if (desc == null) { throw new IllegalArgumentException("Missing LUT Descriptor!"); } if (desc.length != 3) { throw new IllegalArgumentException( "Illegal number of LUT Descriptor values: " + desc.length); } if (desc[0] < 0) throw new IllegalArgumentException( "Illegal LUT Descriptor: len=" + desc[0]); int bits = desc[2]; if (bits != 8 && bits != 16) throw new IllegalArgumentException( "Illegal LUT Descriptor: bits=" + bits); return desc; }
private int[] lutDescriptor(Attributes ds, int descTag) { int[] desc = ds.getInts(descTag); if (desc == null) { throw new IllegalArgumentException("Missing LUT Descriptor!"); } if (desc.length != 3) { throw new IllegalArgumentException( "Illegal number of LUT Descriptor values: " + desc.length); } if (desc[0] < 0) throw new IllegalArgumentException( "Illegal LUT Descriptor: len=" + desc[0]); int bits = desc[2]; if (bits != 8 && bits != 16) throw new IllegalArgumentException( "Illegal LUT Descriptor: bits=" + bits); return desc; }
private static float forImage(Attributes attrs, int aspectRatioTag, int... pixelSpacingTags) { int[] ratio = attrs.getInts(aspectRatioTag); if (ratio != null && ratio.length == 2 && ratio[0] > 0 && ratio[1] > 0) return (float) ratio[0] / ratio[1]; for (int pixelSpacingTag : pixelSpacingTags) { float[] spaces = attrs.getFloats(pixelSpacingTag); if (spaces != null && spaces.length == 2 && spaces[0] > 0 && spaces[1] > 0) return spaces[0] / spaces[1]; } return 1f; }
private static void promptAttributeIdentifierListTo(Attributes cmd, StringBuilder sb) { int[] tags = cmd.getInts(Tag.AttributeIdentifierList); if (tags == null) return; sb.append(StringUtils.LINE_SEPARATOR).append(" tags=["); if (tags.length > 0) { for (int tag : tags) sb.append(TagUtils.toString(tag)).append(", "); sb.setLength(sb.length()-2); } sb.append(']'); }
private static float forImage(Attributes attrs, int aspectRatioTag, int... pixelSpacingTags) { int[] ratio = attrs.getInts(aspectRatioTag); if (ratio != null && ratio.length == 2 && ratio[0] > 0 && ratio[1] > 0) return (float) ratio[0] / ratio[1]; for (int pixelSpacingTag : pixelSpacingTags) { float[] spaces = attrs.getFloats(pixelSpacingTag); if (spaces != null && spaces.length == 2 && spaces[0] > 0 && spaces[1] > 0) return spaces[0] / spaces[1]; } return 1f; }
private static void promptAttributeIdentifierListTo(Attributes cmd, StringBuilder sb) { int[] tags = cmd.getInts(Tag.AttributeIdentifierList); if (tags == null) return; sb.append(StringUtils.LINE_SEPARATOR).append(" tags=["); if (tags.length > 0) { for (int tag : tags) sb.append(TagUtils.toString(tag)).append(", "); sb.setLength(sb.length()-2); } sb.append(']'); }
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()); //$NON-NLS-1$ } return defaultValue; }
private LookupTable createLUT(StoredValue inBits, Attributes attrs) { if (attrs == null) return null; return createLUT(inBits, attrs.getInts(Tag.LUTDescriptor), attrs.getSafeBytes(Tag.LUTData), attrs.bigEndian()); }
private LookupTable createLUT(StoredValue inBits, Attributes attrs) { if (attrs == null) return null; return createLUT(inBits, attrs.getInts(Tag.LUTDescriptor), attrs.getSafeBytes(Tag.LUTData), attrs.bigEndian()); }
private Attributes selectVOILUT(Attributes psAttrs, String iuid, int frame) { Sequence voiLUTs = psAttrs.getSequence(Tag.SoftcopyVOILUTSequence); if (voiLUTs != null) for (Attributes voiLUT : voiLUTs) { Sequence refImgs = voiLUT.getSequence(Tag.ReferencedImageSequence); if (refImgs == null || refImgs.isEmpty()) return voiLUT; for (Attributes refImg : refImgs) { if (iuid.equals(refImg.getString(Tag.ReferencedSOPInstanceUID))) { int[] refFrames = refImg.getInts(Tag.ReferencedFrameNumber); if (refFrames == null || refFrames.length == 0) return voiLUT; for (int refFrame : refFrames) if (refFrame == frame) return voiLUT; } } } return null; }
private byte[] lutData(Attributes ds, int[] desc, int dataTag, int segmTag) { int len = desc[0] == 0 ? 0x10000 : desc[0]; int bits = desc[2]; byte[] data = ds.getSafeBytes(dataTag); if (data == null) { int[] segm = ds.getInts(segmTag); if (segm == null) { throw new IllegalArgumentException("Missing LUT Data!"); } if (bits == 8) { throw new IllegalArgumentException( "Segmented LUT Data with LUT Descriptor: bits=8"); } data = new byte[len]; inflateSegmentedLut(segm, data); } else if (bits == 16 || data.length != len) { if (data.length != len << 1) lutLengthMismatch(data.length, len); int hilo = ds.bigEndian() ? 0 : 1; if (bits == 8) hilo = 1 - hilo; // padded high bits -> use low bits data = LookupTableFactory.halfLength(data, hilo); } return data; }
private byte[] lutData(Attributes ds, int[] desc, int dataTag, int segmTag) { int len = desc[0] == 0 ? 0x10000 : desc[0]; int bits = desc[2]; byte[] data = ds.getSafeBytes(dataTag); if (data == null) { int[] segm = ds.getInts(segmTag); if (segm == null) { throw new IllegalArgumentException("Missing LUT Data!"); } if (bits == 8) { throw new IllegalArgumentException( "Segmented LUT Data with LUT Descriptor: bits=8"); } data = new byte[len]; inflateSegmentedLut(segm, data); } else if (bits == 16 || data.length != len) { if (data.length != len << 1) lutLengthMismatch(data.length, len); int hilo = ds.bigEndian() ? 0 : 1; if (bits == 8) hilo = 1 - hilo; // padded high bits -> use low bits data = LookupTableFactory.halfLength(data, hilo); } return data; }
public void setPresentationLUT(Attributes attrs) { Attributes pLUT = attrs.getNestedDataset(Tag.PresentationLUTSequence); if (pLUT != null) { int[] desc = pLUT.getInts(Tag.LUTDescriptor); if (desc != null && desc.length == 3) { int len = desc[0] == 0 ? 0x10000 : desc[0]; presentationLUT = createLUT(new StoredValue.Unsigned(log2(len)), resetOffset(desc), pLUT.getSafeBytes(Tag.LUTData), pLUT.bigEndian()); } } else { String pShape = attrs.getString(Tag.PresentationLUTShape); inverse = (pShape != null ? "INVERSE".equals(pShape) : "MONOCHROME1".equals( attrs.getString(Tag.PhotometricInterpretation))); } }
private void adjustReferencedImages(Attributes attrs, int sqtag) { Sequence sq = attrs.getSequence(sqtag); if (sq == null) return; ArrayList<Attributes> newRefs = new ArrayList<Attributes>(); for (Iterator<Attributes> itr = sq.iterator(); itr.hasNext();) { Attributes ref = (Attributes) itr.next(); String cuid = legacySOPClassUID(ref.getString(Tag.ReferencedSOPClassUID)); if (cuid == null) continue; itr.remove(); String iuid = uidMapper.get(ref.getString(Tag.ReferencedSOPInstanceUID)); int[] frames = ref.getInts(Tag.ReferencedFrameNumber); int n = frames == null ? nofAccessor.getNumberOfFrames(iuid) : frames.length; ref.remove(Tag.ReferencedFrameNumber); ref.setString(Tag.ReferencedSOPClassUID, VR.UI, cuid); for (int i = 0; i < n; i++) { Attributes newRef = new Attributes(ref); newRef.setString(Tag.ReferencedSOPInstanceUID, VR.UI, iuid + '.' + (frames != null ? frames[i] : (i+1))); newRefs.add(newRef); } } for (Attributes ref : newRefs) sq.add(ref); }
public void setPresentationLUT(Attributes attrs) { Attributes pLUT = attrs.getNestedDataset(Tag.PresentationLUTSequence); if (pLUT != null) { int[] desc = pLUT.getInts(Tag.LUTDescriptor); if (desc != null && desc.length == 3) { int len = desc[0] == 0 ? 0x10000 : desc[0]; presentationLUT = createLUT(new StoredValue.Unsigned(log2(len)), resetOffset(desc), pLUT.getSafeBytes(Tag.LUTData), pLUT.bigEndian()); } } else { String pShape = attrs.getString(Tag.PresentationLUTShape); inverse = (pShape != null ? "INVERSE".equals(pShape) : "MONOCHROME1".equals( attrs.getString(Tag.PhotometricInterpretation))); } }
private void adjustReferencedImages(Attributes attrs, int sqtag) { Sequence sq = attrs.getSequence(sqtag); if (sq == null) return; ArrayList<Attributes> newRefs = new ArrayList<Attributes>(); for (Iterator<Attributes> itr = sq.iterator(); itr.hasNext();) { Attributes ref = (Attributes) itr.next(); String cuid = legacySOPClassUID(ref.getString(Tag.ReferencedSOPClassUID)); if (cuid == null) continue; itr.remove(); String iuid = uidMapper.get(ref.getString(Tag.ReferencedSOPInstanceUID)); int[] frames = ref.getInts(Tag.ReferencedFrameNumber); int n = frames == null ? nofAccessor.getNumberOfFrames(iuid) : frames.length; ref.remove(Tag.ReferencedFrameNumber); ref.setString(Tag.ReferencedSOPClassUID, VR.UI, cuid); for (int i = 0; i < n; i++) { Attributes newRef = new Attributes(ref); newRef.setString(Tag.ReferencedSOPInstanceUID, VR.UI, iuid + '.' + (frames != null ? frames[i] : (i+1))); newRefs.add(newRef); } } for (Attributes ref : newRefs) sq.add(ref); }
int[] ovlyOrigin = attrs.getInts(tagOverlayOrigin); if (ovlyData == null) ovlyData = attrs.getSafeBytes(tagOverlayData);