org.dcm4che3.io.DicomInputStream Java Examples
The following examples show how to use
org.dcm4che3.io.DicomInputStream.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MDICOM.java From aws-big-data-blog with Apache License 2.0 | 6 votes |
public static String dicomJsonContent(File dicomFile) { String dicomJsonString = ""; try (ByteArrayOutputStream baos = new ByteArrayOutputStream(); DicomInputStream dis = new DicomInputStream(dicomFile)) { IncludeBulkData includeBulkData = IncludeBulkData.URI; dis.setIncludeBulkData(includeBulkData); JsonGenerator jsonGen = Json.createGenerator(baos); JSONWriter jsonWriter = new JSONWriter(jsonGen); dis.setDicomInputHandler(jsonWriter); dis.readDataset(-1, -1); jsonGen.flush(); dicomJsonString = new String(baos.toByteArray(), "UTF-8"); } catch (Exception e) { System.out.println("error processing dicom: " + e.getMessage()); } return dicomJsonString; }
Example #2
Source File: DicomStreamUtilTest.java From healthcare-dicom-dicomweb-adapter with Apache License 2.0 | 5 votes |
@Test public void testDicomStreamWithFileMetaHeader_correctTransferSyntax() throws Exception { FakePDVInputStream streamNoHeader = new FakePDVInputStream(TestUtils.streamDICOMStripHeaders(TestUtils.TEST_MR_FILE)); String sopClassUID = UID.MRImageStorage; String sopInstanceUID = "1.0.0.0"; String transferSyntax = UID.ExplicitVRLittleEndian; InputStream streamWithHeader = DicomStreamUtil.dicomStreamWithFileMetaHeader( sopInstanceUID, sopClassUID, transferSyntax, streamNoHeader); DicomInputStream dicomInputStream = new DicomInputStream(streamWithHeader); Attributes attrs = dicomInputStream.getFileMetaInformation(); assertThat(attrs.getString(Tag.TransferSyntaxUID)).isEqualTo(transferSyntax); }
Example #3
Source File: CStoreServiceTest.java From healthcare-dicom-dicomweb-adapter with Apache License 2.0 | 5 votes |
private void basicCStoreServiceTest( boolean connectionError, int httpStatus, int expectedDimseStatus, MockDestinationConfig[] destinationConfigs, String sopClassUID, String sopInstanceUID, String testFile, String transcodeToSyntax) throws Exception { DicomInputStream in = (DicomInputStream) TestUtils.streamDICOMStripHeaders(testFile); InputStreamDataWriter data = new InputStreamDataWriter(in); // Create C-STORE DICOM server. int serverPort = createDicomServer(connectionError, httpStatus, destinationConfigs, transcodeToSyntax); // Associate with peer AE. Association association = associate(serverHostname, serverPort, sopClassUID, in.getTransferSyntax()); // Send the DICOM file. DimseRSPAssert rspAssert = new DimseRSPAssert(association, expectedDimseStatus); association.cstore( sopClassUID, sopInstanceUID, 1, data, in.getTransferSyntax(), rspAssert); association.waitForOutstandingRSP(); // Close the association. association.release(); association.waitForSocketClose(); rspAssert.assertResult(); }
Example #4
Source File: DicomClient.java From healthcare-dicom-dicomweb-adapter with Apache License 2.0 | 5 votes |
public void cstore( String sopClassUid, String sopInstanceUid, String transferSyntaxUid, DicomInputStream din, DimseRSPHandler responseHandler) throws IOException, InterruptedException { InputStreamDataWriter data = new InputStreamDataWriter(din); association.cstore( sopClassUid, sopInstanceUid, /* priority */ 1, data, transferSyntaxUid, responseHandler); }
Example #5
Source File: DicomClientTest.java From healthcare-dicom-dicomweb-adapter with Apache License 2.0 | 5 votes |
@Before public void setUp() throws Exception { clientAE = new ApplicationEntity(clientAET); Connection conn = new Connection(); DeviceUtil.createClientDevice(clientAE, conn); clientAE.addConnection(conn); dicom = new DicomInputStream(TestUtils.streamTestFile(TestUtils.TEST_MR_FILE)); }
Example #6
Source File: ExportMessageReceiverTest.java From healthcare-dicom-dicomweb-adapter with Apache License 2.0 | 5 votes |
@Before public void setUp() throws Exception { clientAE = new ApplicationEntity(clientAET); Connection conn = new Connection(); DeviceUtil.createClientDevice(clientAE, conn); clientAE.addConnection(conn); dicom = new DicomInputStream(TestUtils.streamTestFile(TestUtils.TEST_MR_FILE)); }
Example #7
Source File: ServiceUtil.java From weasis-dicom-tools with Eclipse Public License 2.0 | 5 votes |
public static void safeClose(DicomInputStream in) { if (in != null) { for (File file : in.getBulkDataFiles()) { FileUtil.delete(file); } } }
Example #8
Source File: ForwardUtil.java From weasis-dicom-tools with Eclipse Public License 2.0 | 5 votes |
private static List<File> cleanOrGetBulkDataFiles(DicomInputStream in, boolean clean) { FileUtil.safeClose(in); if (clean) { // Force to clean if tmp bulk files ServiceUtil.safeClose(in); } else if (in != null) { // Return tmp bulk files return in.getBulkDataFiles(); } return null; }
Example #9
Source File: GetSCU.java From weasis-dicom-tools with Eclipse Public License 2.0 | 5 votes |
public void retrieve(File f) throws IOException, InterruptedException { Attributes attrs = new Attributes(); try (DicomInputStream dis = new DicomInputStream(f)) { attrs.addSelected(dis.readDataset(-1, -1), inFilter); } attrs.addAll(keys); retrieve(attrs); }
Example #10
Source File: StoreSCP.java From weasis-dicom-tools with Eclipse Public License 2.0 | 5 votes |
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); } }
Example #11
Source File: MoveSCU.java From weasis-dicom-tools with Eclipse Public License 2.0 | 5 votes |
public void retrieve(File f) throws IOException, InterruptedException { Attributes attrs = new Attributes(); try (DicomInputStream dis = new DicomInputStream(f)) { attrs.addSelected(dis.readDataset(-1, -1), inFilter); } attrs.addAll(keys); retrieve(attrs); }
Example #12
Source File: TestUtils.java From healthcare-dicom-dicomweb-adapter with Apache License 2.0 | 4 votes |
public static InputStream streamDICOMStripHeaders(String testFile) throws IOException { DicomInputStream in = new DicomInputStream(TestUtils.streamTestFile(testFile)); // Read and discard the meta-header in the stream (advances stream past meta header bytes). in.getFileMetaInformation(); return in; }