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

Method getVoxelDepth

ij/src/main/java/ij/util/DicomTools.java:97–116  ·  view source on GitHub ↗

Calculates the voxel depth of the specified DICOM stack based on the distance between the first and last slices.

(ImageStack stack)

Source from the content-addressed store, hash-verified

95 /** Calculates the voxel depth of the specified DICOM stack based
96 on the distance between the first and last slices. */
97 public static double getVoxelDepth(ImageStack stack) {
98 if (stack.isVirtual()) stack.getProcessor(1);
99 String pos0 = getTag(stack.getSliceLabel(1), "0020,0032");
100 String posn = null;
101 double voxelDepth = -1.0;
102 if (pos0!=null) {
103 String[] xyz = pos0.split("\\\\");
104 if (xyz.length!=3) return voxelDepth;
105 double z0 = Double.parseDouble(xyz[2]);
106 if (stack.isVirtual()) stack.getProcessor(stack.size());
107 posn = getTag(stack.getSliceLabel(stack.size()), "0020,0032");
108 if (posn==null) return voxelDepth;
109 xyz = posn.split("\\\\");
110 if (xyz.length!=3) return voxelDepth;
111 double zn = Double.parseDouble(xyz[2]);
112 voxelDepth = Math.abs((zn - z0) / (stack.size() - 1));
113 }
114 if (IJ.debugMode) IJ.log("DicomTools.getVoxelDepth: "+voxelDepth+" "+pos0+" "+posn);
115 return voxelDepth;
116 }
117
118 /** Returns the value (as a string) of the specified DICOM tag id (in the form "0018,0050")
119 of the specified image or stack slice. Returns null if the tag id is not found. */

Callers 1

runMethod · 0.95

Calls 9

getTagMethod · 0.95
logMethod · 0.95
isVirtualMethod · 0.45
getProcessorMethod · 0.45
getSliceLabelMethod · 0.45
splitMethod · 0.45
parseDoubleMethod · 0.45
sizeMethod · 0.45
absMethod · 0.45

Tested by

no test coverage detected