diff --git a/src/utils/parseDicom.js b/src/utils/parseDicom.js index c8861bf9..4d7f7c0f 100644 --- a/src/utils/parseDicom.js +++ b/src/utils/parseDicom.js @@ -68,6 +68,8 @@ let dicom = { }; // 需要设置默认值 let defaultKey = ['Rows', 'Columns', 'SliceLocation', 'NumberOfFrames']; +let uintKey = ['Rows', 'Columns']; +let intStringKey = ['SliceLocation', 'NumberOfFrames']; // 需要格式解析 let pormatParseKey = ['PatientName', 'SeriesDescription', 'StudyDescription']; // 解析dicom文件 @@ -81,28 +83,19 @@ export const parseDicom = (file, name = false) => { if (name && Array.isArray(name)) { name.forEach((item) => { if (dicom[item]) { - res[item] = data.string(dicom[item]) || data.uint16(dicom[item]) || data.intString(dicom[item]) || ''; - } - if (item === 'SliceLocation') { - res[item] = data.intString(dicom[item]) + res[item] = data.string(dicom[item]) || ''; } }); } else if (name) { if (dicom[name]) { - res[name] = data.string(dicom[name]) || data.uint16(dicom[name]) || data.intString(dicom[name]) || ''; - if (name === 'SliceLocation') { - res[name] = data.intString(dicom[name]) - } + res[name] = data.string(dicom[name]) || ''; } else { console.log("name is inexistence"); resolve(false) } } else { Object.keys(dicom).forEach((key) => { - res[key] = data.string(dicom[key]) || data.uint16(dicom[key]) || data.intString(dicom[key]) || ''; - if (key === 'SliceLocation') { - res[key] = data.intString(dicom[key]) - } + res[key] = data.string(dicom[key]) || ''; }); } pormatParseKey.forEach(key => { @@ -119,6 +112,12 @@ export const parseDicom = (file, name = false) => { ); } }) + uintKey.forEach(key => { + res[key] = data.uint16(dicom[key]) + }) + intStringKey.forEach(key => { + res[key] = data.intString(dicom[key]) + }) defaultKey.forEach(key => { if (!res[key] && res.hasOwnProperty(key)) { res[key] = 0;