Exemplo n.º 1
0
  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);
    }
  }
 @Override
 public StoreContext spool(
     String localAETitle, String remoteAETitle, InputStream in, InstanceAvailableCallback callback)
     throws Exception {
   StoreContext context;
   ApplicationEntity localAE = aeCache.findApplicationEntity(localAETitle);
   StoreSession session = storeService.createStoreSession(storeService);
   session.setSource(
       new GenericParticipant(localAE.getConnections().get(0).getHostname(), "WadoRS Fetch"));
   session.setRemoteAET(remoteAETitle);
   ArchiveAEExtension arcAEExt =
       aeCache.get(localAETitle).getAEExtension(ArchiveAEExtension.class);
   session.setArchiveAEExtension(arcAEExt);
   storeService.init(session);
   context = storeService.createStoreContext(session);
   try {
     DicomInputStream din = new DicomInputStream(in);
     Attributes fmi = din.getFileMetaInformation();
     storeService.writeSpoolFile(context, fmi, din);
   } catch (Exception e) {
     throw new Exception("Failed to spool WadoRS response from AE " + remoteAETitle);
   }
   return context;
 }
Exemplo n.º 3
0
  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();
   }
 }
Exemplo n.º 5
0
 private boolean isRLELossless() {
   return dis.getTransferSyntax().equals(UID.RLELossless);
 }