Package org.dcm4che3.io

Examples of org.dcm4che3.io.DicomInputStream


    protected DicomDirReader(File file, String mode) throws IOException {
        this.file = file;
        this.raf = new RandomAccessFile(file, mode);
        try {
            this.in = new DicomInputStream(new RAFInputStreamAdapter(raf));
            this.fmi = in.readFileMetaInformation();
            this.fsInfo = in.readDataset(-1, Tag.DirectoryRecordSequence);
            if (in.tag() != Tag.DirectoryRecordSequence)
                throw new IOException("Missing Directory Record Sequence");
        } catch (IOException e) {
View Full Code Here


        if (!from.renameTo(dest))
            throw new IOException("Failed to rename " + from + " to " + dest);
    }

    private static Attributes parse(File file) throws IOException {
        DicomInputStream in = new DicomInputStream(file);
        try {
            in.setIncludeBulkData(IncludeBulkData.NO);
            return in.readDataset(-1, Tag.PixelData);
        } finally {
            SafeClose.close(in);
        }
    }
View Full Code Here

    }

    private static Attributes readDataset(String name)
            throws Exception {
        ClassLoader cl = Thread.currentThread().getContextClassLoader();
        DicomInputStream in = new DicomInputStream(
                new File(cl.getResource(name).toURI()));
        try {
            return in.readDataset(-1, -1);
        } finally {
            in.close();
        }
    }
View Full Code Here

    private void readObject(ObjectInputStream in)
            throws IOException, ClassNotFoundException {
        in.defaultReadObject();
        init(in.readInt());
        @SuppressWarnings("resource")
        DicomInputStream din = new DicomInputStream(in,
                bigEndian ? UID.ExplicitVRBigEndianRetired
                          : UID.ExplicitVRLittleEndian);
        din.readAttributes(this, -1, Tag.ItemDelimitationItem);
    }
View Full Code Here

    @Override
    protected DataWriter createDataWriter(InstanceLocator inst, String tsuid)
            throws IOException {
        Attributes attrs;
        DicomInputStream in = new DicomInputStream(inst.getFile());
        try {
            if (withoutBulkData) {
                in.setIncludeBulkData(IncludeBulkData.NO);
                attrs = in.readDataset(-1, Tag.PixelData);
            } else {
                in.setIncludeBulkData(IncludeBulkData.URI);
                attrs = in.readDataset(-1, -1);
            }
        } finally {
            SafeClose.close(in);
        }
        return new DataWriterAdapter(attrs);
View Full Code Here

            throws Exception {
        return inst.tsuid;
    }

    protected DataWriter createDataWriter(T inst, String tsuid) throws Exception {
        DicomInputStream in = new DicomInputStream(inst.getFile());
        in.readFileMetaInformation();
        return new InputStreamDataWriter(in);
    }
View Full Code Here

        if (!file.exists())
            throw new DicomServiceException(Status.NoSuchObjectInstance).
                setUID(Tag.AffectedSOPInstanceUID, iuid);
        LOG.info("{}: M-UPDATE {}", as, file);
        Attributes data;
        DicomInputStream in = null;
        try {
            in = new DicomInputStream(file);
            data = in.readDataset(-1, -1);
        } catch (IOException e) {
            LOG.warn(as + ": Failed to read MPPS:", e);
            throw new DicomServiceException(Status.ProcessingFailure, e);
        } finally {
            SafeClose.close(in);
View Full Code Here

            throw new AAbort();
        }
    }

    private Attributes readCommand() throws IOException {
        DicomInputStream in =
                new DicomInputStream(this, UID.ImplicitVRLittleEndian);
        try {
            return in.readCommand();
        } finally {
            SafeClose.close(in);
        }
    }
View Full Code Here

        }
    }

    @Override
    public Attributes readDataset(String tsuid) throws IOException {
        DicomInputStream in = new DicomInputStream(this, tsuid);
        try {
            return in.readDataset(-1, -1);
        } finally {
            SafeClose.close(in);
        }
    }
View Full Code Here

        }
        String pid;
        String styuid;
        String seruid;
        String iuid;
        DicomInputStream din = null;
        try {
            din = new DicomInputStream(f);
            din.setIncludeBulkData(IncludeBulkData.NO);
            Attributes fmi = din.readFileMetaInformation();
            Attributes dataset = din.readDataset(-1, Tag.StudyID);
            iuid = (fmi != null)
                ? fmi.getString(Tag.MediaStorageSOPInstanceUID, null)
                : dataset.getString(Tag.SOPInstanceUID, null);
            if (iuid == null) {
                System.out.println();
                System.out.println(MessageFormat.format(
                        rb.getString("skip-file"), f));
                return 0;
            }
            pid = dataset.getString(Tag.PatientID, null);
            styuid = dataset.getString(Tag.StudyInstanceUID, null);
            seruid = dataset.getString(Tag.SeriesInstanceUID, null);
        } catch (IOException e) {
            System.out.println();
            System.out.println(
                    MessageFormat.format(rb.getString("failed-to-parse"),
                            f, e.getMessage()));
            return 0;
        } finally {
            if (din != null)
                try { din.close(); } catch (Exception ignore) {}
        }
        Attributes instRec;
        if (styuid != null && seruid != null) {
            Attributes patRec =
                in.findPatientRecord(pid == null ? styuid : pid);
View Full Code Here

TOP

Related Classes of org.dcm4che3.io.DicomInputStream

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.