public Object getValue(int tag, VR.Holder vr) { return getValue(null, tag, vr); }
public Object getValue(int a) { if (a == -1) return attr.hash; return attr.attributes.getValue(a); } public String getString(int a) {
public Object getValue(int tag) { return getValue(null, tag, null); }
public Object getValue(String privateCreator, int tag) { return getValue(privateCreator, tag, null); }
public void replaceSelected(Attributes others, int... selection) { for (int i = 0; i < size; i++) { if (Arrays.binarySearch(selection, tags[i]) >= 0) { values[i] = StringUtils.maskNull(others.getValue(tags[i]), Value.NULL); } } }
public Attributes getNestedDataset(String privateCreator, int sequenceTag, int itemIndex) { Object value = getValue(privateCreator, sequenceTag); if (!(value instanceof Sequence)) return null; Sequence sq = (Sequence) value; if (itemIndex >= sq.size()) return null; return sq.get(itemIndex); }
public Attributes getNestedDataset(List<ItemPointer> itemPointers) { Attributes item = this; for (ItemPointer ip : itemPointers) { Object value = item.getValue(ip.privateCreator, ip.sequenceTag); if (!(value instanceof Sequence)) return null; Sequence sq = (Sequence) value; if (ip.itemIndex >= sq.size()) return null; item = sq.get(ip.itemIndex); } return item; }
public Compressor(Attributes dataset, String from) { super(dataset, from); Object pixeldata = dataset.getValue(Tag.PixelData, pixeldataVR); if (pixeldata == null) return; if (pixeldata instanceof BulkData) { this.pixeldata = (BulkData) pixeldata; if (pmi.isSubSambled()) throw new UnsupportedOperationException( "Unsupported Photometric Interpretation: " + pmi); if (this.pixeldata.length() < length) throw new IllegalArgumentException( "Pixel data too short: " + this.pixeldata.length() + " instead " + length + " bytes"); } embeddedOverlays = Overlays.getEmbeddedOverlayGroupOffsets(dataset); }
private char processFile(File file) { try { Attributes dataset; try (DicomInputStream is = new DicomInputStream(file)) { is.setIncludeBulkData(DicomInputStream.IncludeBulkData.URI); dataset = is.readDataset(-1, -1); } VR.Holder vr = new VR.Holder(); Object value = dataset.getValue(Tag.PixelData, vr); if ((value instanceof BulkData) && vr.vr == VR.OW) { try (RandomAccessFile raf = new RandomAccessFile(file, "rw")) { toggleEndian(raf, (BulkData) value); } updated++; return '.'; } skipped++; return value == null ? 'p' : (value instanceof BulkData) ? 'b' : 'c'; } catch (IOException e) { System.err.println("Failed to update " + file + ':'); e.printStackTrace(System.err); failed++; } return 'E'; }
private void initPixelDataFromAttributes(Attributes ds) { VR.Holder holder = new VR.Holder(); Object value = ds.getValue(Tag.PixelData, holder); if (value != null) { imageDescriptor = new ImageDescriptor(ds); pixelDataVR = holder.vr; if (value instanceof BulkData) { pixelData = (BulkData) value; pixelDataLength = pixelData.length(); } else if( value instanceof byte[] ) { pixeldataBytes = (byte[]) value; pixelDataLength = pixeldataBytes.length; } else { // value instanceof Fragments pixelDataFragments = (Fragments) value; pixelDataLength = -1; } } }
appendAttribute(level, tag, sb); VR.Holder vr = new VR.Holder(); Object value = attrs.getValue(tag, vr); sb.append(' ').append(vr.vr); sb.append(" [");
private void readWaveformData(DicomSpecialElement media, Attributes dcm) throws Exception { Object wdata = dcm.getValue(Tag.WaveformData); ByteArrayOutputStream array = null; if (wdata instanceof BulkData) {
private static void setSequenceQueryAttrs(QidoRS main, String url, Sequence sequence, String seqKeyWork) { ElementDictionary dict = ElementDictionary.getStandardElementDictionary(); for(Attributes item : sequence) { for(int i=0; i < item.tags().length; i++) { int tag = item.tags()[i]; if(item.getSequence(tag) == null) { url+=(url.endsWith(".")?"":(url.contains("?")?"&":"?")) +keyWordOf(main, dict, tag, main.queryAttrs) +"="+(String) main.queryAttrs.getValue(tag); } else { url+=(url.endsWith(".")?"":(url.contains("?")?"&":"?")) +keyWordOf(main, dict, tag, main.queryAttrs)+"."; setSequenceQueryAttrs(main,url,main.queryAttrs.getSequence(tag) , keyWordOf(main, dict, tag, main.queryAttrs)); } } } }
private boolean matches(String privateCreator, int tag, boolean ignorePNCase, boolean matchNoValue, Sequence keySeq) { int n = keySeq.size(); if (n > 1) throw new IllegalArgumentException("Keys contain Sequence " + TagUtils.toString(tag) + " with " + n + " Items"); Attributes keys = keySeq.get(0); if (keys.isEmpty()) return true; Object value = getValue(privateCreator, tag); if (value == null || isEmpty(value)) return matchNoValue; if (value instanceof Sequence) { Sequence sq = (Sequence) value; for (Attributes item : sq) if (item.matches(keys, ignorePNCase, matchNoValue)) return true; } return false; }
@Override public void coerce(Attributes attrs, Attributes modified) { VR.Holder vr = new VR.Holder(); for (int nullifyTag : nullifyTags) { Object value = attrs.getValue(nullifyTag, vr); if (value != null && value != Value.NULL) { if (modified != null) modified.setValue(nullifyTag, vr.vr, attrs.remove(nullifyTag)); attrs.setNull(nullifyTag, vr.vr); } } if (next != null) next.coerce(attrs, modified); } }
Object data = dicomImageLoader.getDicomObject().getValue(Tag.EncapsulatedDocument); if (data instanceof BulkData) { BulkData bulkData = (BulkData) data;
height = TagD.getTagValue(dicomImageLoader, Tag.Rows, Integer.class); VR.Holder holder = new VR.Holder(); Object pixdata = dicomImageLoader.getDicomObject().getValue(Tag.PixelData, holder); if (pixdata instanceof Fragments) { Fragments fragments = (Fragments) pixdata;
private void addPixelData(Attributes dest, Attributes src, int frame) { VR.Holder vr = new VR.Holder(); Object pixelData = src.getValue(Tag.PixelData, vr); if (pixelData instanceof byte[]) { dest.setBytes(Tag.PixelData, vr.vr, extractPixelData( (byte[]) pixelData, frame, calcFrameLength(src))); } else if (pixelData instanceof BulkData) { dest.setValue(Tag.PixelData, vr.vr, extractPixelData( (BulkData) pixelData, frame, calcFrameLength(src))); } else { Fragments destFrags = dest.newFragments(Tag.PixelData, vr.vr, 2); destFrags.add(null); destFrags.add(((Fragments) pixelData).get(frame + 1)); } }
private void addPixelData(Attributes dest, Attributes src, int frame) { VR.Holder vr = new VR.Holder(); Object pixelData = src.getValue(Tag.PixelData, vr); if (pixelData instanceof byte[]) { dest.setBytes(Tag.PixelData, vr.vr, extractPixelData( (byte[]) pixelData, frame, calcFrameLength(src))); } else if (pixelData instanceof BulkData) { dest.setValue(Tag.PixelData, vr.vr, extractPixelData( (BulkData) pixelData, frame, calcFrameLength(src))); } else { Fragments destFrags = dest.newFragments(Tag.PixelData, vr.vr, 2); destFrags.add(null); destFrags.add(((Fragments) pixelData).get(frame + 1)); } }
dis.close(); Object pixeldata = dataset.getValue(Tag.PixelData); Compressor compressor = null; DicomOutputStream dos = null;