Examples of DicomDirReader


Examples of org.dcm4che3.media.DicomDirReader

        return new File(cl.getResource(name).toURI());
    }

    @Test
    public void testInitDicomDirReader() throws Exception {
        DicomDirReader r = new DicomDirReader(toFile("DICOMDIR"));
        try {
            assertEquals("1.3.6.1.4.1.5962.1.5.1175775772.5737.0",
                    r.getFileSetUID());
            assertNull(r.getFileSetID());
            assertEquals(0, r.getFileSetConsistencyFlag());
            assertFalse(r.isEmpty());
        } finally {
            r.close();
        }
    }
View Full Code Here

Examples of org.dcm4che3.media.DicomDirReader

        }
    }

    @Test
    public void testReadAll() throws Exception {
        DicomDirReader r = new DicomDirReader(toFile("DICOMDIR"));
        try {
            assertEquals(44, readNext(r, r.readFirstRootDirectoryRecord()));
        } finally {
            r.close();
        }
    }
View Full Code Here

Examples of org.dcm4che3.media.DicomDirReader

                    fsInfo.getDescriptorFileCharset());
        ddReader = ddWriter = DicomDirWriter.open(dicomDir);
    }

    private void openDicomDirForReadOnly() throws IOException {
        ddReader = new DicomDirReader(dicomDir);
    }
View Full Code Here

Examples of org.dcm4che3.media.DicomDirReader

            List<InstanceLocator> list = new ArrayList<InstanceLocator>();
            String[] patIDs = keys.getStrings(Tag.PatientID);
            String[] studyIUIDs = keys.getStrings(Tag.StudyInstanceUID);
            String[] seriesIUIDs = keys.getStrings(Tag.SeriesInstanceUID);
            String[] sopIUIDs = keys.getStrings(Tag.SOPInstanceUID);
            DicomDirReader ddr = ddReader;
            Attributes patRec = ddr.findPatientRecord(patIDs);
            while (patRec != null) {
                Attributes studyRec = ddr.findStudyRecord(patRec, studyIUIDs);
                while (studyRec != null) {
                    Attributes seriesRec = ddr.findSeriesRecord(studyRec, seriesIUIDs);
                    while (seriesRec != null) {
                        Attributes instRec = ddr.findLowerInstanceRecord(seriesRec, true, sopIUIDs);
                        while (instRec != null) {
                            String cuid = instRec.getString(Tag.ReferencedSOPClassUIDInFile);
                            String iuid = instRec.getString(Tag.ReferencedSOPInstanceUIDInFile);
                            String tsuid = instRec.getString(Tag.ReferencedTransferSyntaxUIDInFile);
                            String[] fileIDs = instRec.getStrings(Tag.ReferencedFileID);
                            String uri = ddr.toFile(fileIDs).toURI().toString();
                            list.add(new InstanceLocator(cuid, iuid, tsuid, uri));
                            if (sopIUIDs != null && sopIUIDs.length == 1)
                                break;
   
                            instRec = ddr.findNextInstanceRecord(instRec, true, sopIUIDs);
                        }
                        if (seriesIUIDs != null && seriesIUIDs.length == 1)
                            break;
   
                        seriesRec = ddr.findNextSeriesRecord(seriesRec, seriesIUIDs);
                    }
                    if (studyIUIDs != null && studyIUIDs.length == 1)
                        break;
   
                    studyRec = ddr.findNextStudyRecord(studyRec, studyIUIDs);
                }
                if (patIDs != null && patIDs.length == 1)
                    break;
   
                    patRec = ddr.findNextPatientRecord(patRec, patIDs);
            }
            return list;
        } catch (IOException e) {
            throw new DicomServiceException(Status.UnableToCalculateNumberOfMatches, e);
        }
View Full Code Here

Examples of org.dcm4che3.media.DicomDirReader

        for (int i = 0; i < sopIUIDs.length; i++) {
            Attributes item = requestSeq.get(i);
            map.put(sopIUIDs[i] = item.getString(Tag.ReferencedSOPInstanceUID),
                    item.getString(Tag.ReferencedSOPClassUID));
        }
        DicomDirReader ddr = ddReader;
        try {
            Attributes patRec = ddr.findPatientRecord();
            while (patRec != null) {
                Attributes studyRec = ddr.findStudyRecord(patRec);
                while (studyRec != null) {
                    Attributes seriesRec = ddr.findSeriesRecord(studyRec);
                    while (seriesRec != null) {
                        Attributes instRec = ddr.findLowerInstanceRecord(seriesRec, true, sopIUIDs);
                        while (instRec != null) {
                            String iuid = instRec.getString(Tag.ReferencedSOPInstanceUIDInFile);
                            String cuid = map.remove(iuid);
                            if (cuid.equals(instRec.getString(Tag.ReferencedSOPClassUIDInFile)))
                                successSeq.add(refSOP(iuid, cuid, Status.Success));
                            else
                                failedSeq.add(refSOP(iuid, cuid, Status.ClassInstanceConflict));
                            instRec = ddr.findNextInstanceRecord(instRec, true, sopIUIDs);
                        }
                        seriesRec = ddr.findNextSeriesRecord(seriesRec);
                    }
                    studyRec = ddr.findNextStudyRecord(studyRec);
                }
                patRec = ddr.findNextPatientRecord(patRec);
            }
        } catch (IOException e) {
            LOG.info("Failed to M-READ " + dicomDir, e);
            throw new DicomServiceException(Status.ProcessingFailure, e);
        }
View Full Code Here

Examples of org.dcm4che3.media.DicomDirReader

        protected QueryTask calculateMatches(Association as, PresentationContext pc,
                Attributes rq, Attributes keys) throws DicomServiceException {
            QueryRetrieveLevel level = QueryRetrieveLevel.valueOf(keys, qrLevels);
            level.validateQueryKeys(keys, rootLevel,
                    rootLevel == QueryRetrieveLevel.IMAGE || relational(as, rq));
            DicomDirReader ddr = getDicomDirReader();
            String availability =  getInstanceAvailability();
            switch(level) {
            case PATIENT:
                return new PatientQueryTask(as, pc, rq, keys, ddr, availability);
            case STUDY:
View Full Code Here

Examples of org.dcm4che3.media.DicomDirReader

        }
    }

    public void compact(File f, File bak) throws IOException {
        File tmp = File.createTempFile("DICOMDIR", null, f.getParentFile());
        DicomDirReader r = new DicomDirReader(f);
        try {
            fsInfo.setFilesetUID(r.getFileSetUID());
            fsInfo.setFilesetID(r.getFileSetID());
            fsInfo.setDescriptorFile(
                    r.getDescriptorFile());
            fsInfo.setDescriptorFileCharset(
                    r.getDescriptorFileCharacterSet());
            create(tmp);
            copyFrom(r);
        } finally {
            close();
            try { r.close(); } catch (IOException ignore) {}
        }
        bak.delete();
        rename(f, bak);
        rename(tmp, f);
    }
View Full Code Here

Examples of org.dcm4che3.media.DicomDirReader

        out = null;
    }

    public void openForReadOnly(File file) throws IOException {
        this.file = file;
        in = new DicomDirReader(file);
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.