项目使用中需要解析下载过来的Dicom文件,然后根据固定的层级结构给文件分目录。以下是代码:
/**
* <p>
* Title: GetDicomTag
* </p>
*
* <p>
* Description:解析DICOM文件获取属性值
* </p>
*
* @author yangzhen
* @date 2018年4月2日
*/
public class GetDicomTag { public static String getDicomTag(File file, int TagParam) {
InputStream inputStream = null;
DicomInputStream dicomInputStream = null;
String result = "";
try {
inputStream = FileUtils.openInputStream(file);
dicomInputStream = new DicomInputStream(inputStream);
DicomObject dicomObject = dicomInputStream.readDicomObject(); if (dicomObject != null) {
result = dicomObject.getString(TagParam);
return result;
}
} catch (Exception ex) {
ex.printStackTrace();
} finally {
try {
if (dicomInputStream != null) {
dicomInputStream.close();
}
if (inputStream != null) {
inputStream.close();
}
} catch (IOException ex) {
// logger
}
}
return result;
}
根据Dicom的Tag属性获取想要的值,Tag文件在这里下载