MCPcopy Create free account
hub / github.com/AstroImageJ/astroimagej / getFileInfo

Method getFileInfo

ij/src/main/java/ij/plugin/DICOM.java:530–764  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

528 }
529
530 FileInfo getFileInfo() throws IOException {
531 long skipCount;
532 FileInfo fi = new FileInfo();
533 int bitsAllocated = 16;
534 fi.fileFormat = fi.RAW;
535 fi.fileName = fileName;
536 if (directory.indexOf("://")>0) { // is URL
537 URL u = new URL(directory+fileName);
538 inputStream = new BufferedInputStream(u.openStream());
539 fi.inputStream = inputStream;
540 } else if (inputStream!=null)
541 fi.inputStream = inputStream;
542 else
543 fi.directory = directory;
544 fi.width = 0;
545 fi.height = 0;
546 fi.offset = 0;
547 fi.intelByteOrder = true;
548 fi.fileType = FileInfo.GRAY16_UNSIGNED;
549 fi.fileFormat = FileInfo.DICOM;
550 int samplesPerPixel = 1;
551 int planarConfiguration = 0;
552 String photoInterpretation = "";
553
554 if (inputStream!=null) {
555 // Use large buffer to allow URL stream to be reset after reading header
556 f = inputStream;
557 f.mark(400000);
558 } else
559 f = new BufferedInputStream(new FileInputStream(directory + fileName));
560 if (IJ.debugMode) {
561 IJ.log("");
562 IJ.log("DicomDecoder: decoding "+fileName);
563 }
564
565 int[] bytes = new int[ID_OFFSET];
566 for (int i=0; i<ID_OFFSET; i++)
567 bytes[i] = getByte();
568
569 if (!getString(4).equals(DICM)) {
570 if (!((bytes[0]==8||bytes[0]==2) && bytes[1]==0 && bytes[3]==0))
571 throw new IOException("This is not a DICOM or ACR/NEMA file");
572 if (inputStream==null) f.close();
573 if (inputStream!=null)
574 f.reset();
575 else
576 f = new BufferedInputStream(new FileInputStream(directory + fileName));
577 location = 0;
578 if (IJ.debugMode) IJ.log(DICM + " not found at offset "+ID_OFFSET+"; reseting to offset 0");
579 } else {
580 dicmFound = true;
581 if (IJ.debugMode) IJ.log(DICM + " found at offset " + ID_OFFSET);
582 }
583
584 boolean decodingTags = true;
585 boolean signed = false;
586
587 while (decodingTags) {

Callers 1

runMethod · 0.95

Calls 15

logMethod · 0.95
getByteMethod · 0.95
getStringMethod · 0.95
getNextTagMethod · 0.95
addInfoMethod · 0.95
s2dMethod · 0.95
getShortMethod · 0.95
getSpatialScaleMethod · 0.95
getLutMethod · 0.95
substringMethod · 0.80
startsWithMethod · 0.80
markMethod · 0.65

Tested by

no test coverage detected