private Attributes readFrom(ArchiveInstanceLocator inst) throws IOException { try (DicomInputStream din = new DicomInputStream(service.getFile(inst).toFile())) { IncludeBulkData includeBulkData = IncludeBulkData.URI; int stopTag = -1; if (withoutBulkData) { if (((ArchiveInstanceLocator) inst).isWithoutBulkdata()) { includeBulkData = IncludeBulkData.YES; } else { includeBulkData = IncludeBulkData.NO; stopTag = Tag.PixelData; } } din.setIncludeBulkData(includeBulkData); return din.readDataset(-1, stopTag); } }
private void readMetadata() throws IOException { if (metadata != null) return; if (iis == null) throw new IllegalStateException("Input not set"); dis = new DicomInputStream(new ImageInputStreamAdapter(iis)); dis.setIncludeBulkData(IncludeBulkData.URI); dis.setBulkDataDescriptor(BulkDataDescriptor.PIXELDATA); dis.setURI("java:iis"); // avoid copy of pixeldata to temporary file Attributes fmi = dis.readFileMetaInformation(); Attributes ds = dis.readDataset(-1, -1); metadata = new DicomMetaData(fmi, ds); Object pixeldata = ds.getValue(Tag.PixelData, pixeldataVR); if (pixeldata != null) { frames = ds.getInt(Tag.NumberOfFrames, 1); width = ds.getInt(Tag.Columns, 0); height = ds.getInt(Tag.Rows, 0); samples = ds.getInt(Tag.SamplesPerPixel, 1); banded = samples > 1 && ds.getInt(Tag.PlanarConfiguration, 0) != 0; bitsAllocated = ds.getInt(Tag.BitsAllocated, 8); bitsStored = ds.getInt(Tag.BitsStored, bitsAllocated); dataType = bitsAllocated <= 8 ? DataBuffer.TYPE_BYTE : DataBuffer.TYPE_USHORT; pmi = PhotometricInterpretation.fromString( ds.getString(Tag.PhotometricInterpretation, "MONOCHROME2")); if (pixeldata instanceof BulkData) { iis.setByteOrder(ds.bigEndian() ? ByteOrder.BIG_ENDIAN : ByteOrder.LITTLE_ENDIAN); this.frameLength = pmi.frameLength(width, height, samples, bitsAllocated); this.pixeldata = (BulkData) pixeldata; } else { String tsuid = dis.getTransferSyntax(); ImageReaderParam param = ImageReaderFactory.getImageReaderParam(tsuid); if (param == null) throw new IOException("Unsupported Transfer Syntax: " + tsuid); this.decompressor = ImageReaderFactory.getImageReader(param); this.patchJpegLS = param.patchJPEGLS; this.pixeldataFragments = (Fragments) pixeldata; } } }
private DatasetWithFMI readFrom(ArchiveInstanceLocator inst) throws IOException { try (DicomInputStream din = new DicomInputStream(storescuService.getFile(inst).toFile())) { din.setIncludeBulkData(IncludeBulkData.URI); return din.readDatasetWithFMI(); } }