修改DICOM图像像素间距的计算方法
parent
4b406f96fc
commit
4c652a91fc
|
@ -0,0 +1,104 @@
|
||||||
|
import * as cornerstoneWADOImageLoader from 'cornerstone-wado-image-loader'
|
||||||
|
function parseImageId(imageId) {
|
||||||
|
// build a url by parsing out the url scheme and frame index from the imageId
|
||||||
|
const firstColonIndex = imageId.indexOf(':');
|
||||||
|
|
||||||
|
let url = imageId.substring(firstColonIndex + 1);
|
||||||
|
const frameIndex = url.indexOf('frame=');
|
||||||
|
|
||||||
|
let frame;
|
||||||
|
|
||||||
|
if (frameIndex !== -1) {
|
||||||
|
const frameStr = url.substr(frameIndex + 6);
|
||||||
|
|
||||||
|
frame = parseInt(frameStr, 10);
|
||||||
|
url = url.substr(0, frameIndex - 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
scheme: imageId.substr(0, firstColonIndex),
|
||||||
|
url,
|
||||||
|
frame,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
function getNumberValues(dataSet, tag, minimumLength) {
|
||||||
|
const values = [];
|
||||||
|
const valueAsString = dataSet.string(tag);
|
||||||
|
|
||||||
|
if (!valueAsString) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const split = valueAsString.split('\\');
|
||||||
|
|
||||||
|
if (minimumLength && split.length < minimumLength) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
for (let i = 0; i < split.length; i++) {
|
||||||
|
values.push(parseFloat(split[i]));
|
||||||
|
}
|
||||||
|
|
||||||
|
return values;
|
||||||
|
}
|
||||||
|
function metaDataProvider(type, imageId) {
|
||||||
|
const parsedImageId = parseImageId(imageId);
|
||||||
|
const dataSet = cornerstoneWADOImageLoader.wadouri.dataSetCacheManager.get(parsedImageId.url);
|
||||||
|
|
||||||
|
if (!dataSet) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (type === 'imagePlaneModule') {
|
||||||
|
const imageOrientationPatient = getNumberValues(dataSet, 'x00200037', 6);
|
||||||
|
const imagePositionPatient = getNumberValues(dataSet, 'x00200032', 3);
|
||||||
|
const pixelSpacing = getNumberValues(dataSet, 'x00280030', 2);
|
||||||
|
const imagePixelSpacing = getNumberValues(dataSet, 'x00181164', 2);
|
||||||
|
const estimatedRadiographicMagnificationFactor = getNumberValues(dataSet, 'x00181114', 2);
|
||||||
|
let columnPixelSpacing = null;
|
||||||
|
|
||||||
|
let rowPixelSpacing = null;
|
||||||
|
|
||||||
|
if (pixelSpacing) {
|
||||||
|
rowPixelSpacing = pixelSpacing[0];
|
||||||
|
columnPixelSpacing = pixelSpacing[1];
|
||||||
|
} else if (imagePixelSpacing && estimatedRadiographicMagnificationFactor) {
|
||||||
|
rowPixelSpacing = imagePixelSpacing[0] / estimatedRadiographicMagnificationFactor[0];
|
||||||
|
columnPixelSpacing = imagePixelSpacing[1] / estimatedRadiographicMagnificationFactor[1];
|
||||||
|
} else if (imagePixelSpacing && !estimatedRadiographicMagnificationFactor) {
|
||||||
|
rowPixelSpacing = imagePixelSpacing[0];
|
||||||
|
columnPixelSpacing = imagePixelSpacing[1];
|
||||||
|
}
|
||||||
|
console.log(rowPixelSpacing, columnPixelSpacing)
|
||||||
|
|
||||||
|
let rowCosines = null;
|
||||||
|
|
||||||
|
let columnCosines = null;
|
||||||
|
|
||||||
|
if (imageOrientationPatient) {
|
||||||
|
rowCosines = [
|
||||||
|
parseFloat(imageOrientationPatient[0]),
|
||||||
|
parseFloat(imageOrientationPatient[1]),
|
||||||
|
parseFloat(imageOrientationPatient[2]),
|
||||||
|
];
|
||||||
|
columnCosines = [
|
||||||
|
parseFloat(imageOrientationPatient[3]),
|
||||||
|
parseFloat(imageOrientationPatient[4]),
|
||||||
|
parseFloat(imageOrientationPatient[5]),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
frameOfReferenceUID: dataSet.string('x00200052'),
|
||||||
|
rows: dataSet.uint16('x00280010'),
|
||||||
|
columns: dataSet.uint16('x00280011'),
|
||||||
|
imageOrientationPatient,
|
||||||
|
rowCosines,
|
||||||
|
columnCosines,
|
||||||
|
imagePositionPatient,
|
||||||
|
sliceThickness: dataSet.floatString('x00180050'),
|
||||||
|
sliceLocation: dataSet.floatString('x00201041'),
|
||||||
|
pixelSpacing,
|
||||||
|
rowPixelSpacing,
|
||||||
|
columnPixelSpacing,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
export default metaDataProvider;
|
|
@ -67,6 +67,8 @@ import * as cornerstoneWADOImageLoader from 'cornerstone-wado-image-loader'
|
||||||
// import dicomStore from '@/utils/dicom-store'
|
// import dicomStore from '@/utils/dicom-store'
|
||||||
import dicomViewer from '@/components/Dicom/DicomViewer'
|
import dicomViewer from '@/components/Dicom/DicomViewer'
|
||||||
import dicomPreview from '@/components/Dicom/DicomPreview'
|
import dicomPreview from '@/components/Dicom/DicomPreview'
|
||||||
|
import metaDataProvider from '@/utils/metaDataProvider'
|
||||||
|
cornerstone.metaData.addProvider(metaDataProvider, { priority: 10 });
|
||||||
var config = {
|
var config = {
|
||||||
maxWebWorkers: 4,
|
maxWebWorkers: 4,
|
||||||
startWebWorkersOnDemand: true,
|
startWebWorkersOnDemand: true,
|
||||||
|
|
|
@ -143,6 +143,8 @@ import { getInstanceList, getPatientSeriesList, setSeriesStatus } from '@/api/tr
|
||||||
import requestPoolManager from '@/utils/request-pool'
|
import requestPoolManager from '@/utils/request-pool'
|
||||||
import store from '@/store'
|
import store from '@/store'
|
||||||
import { changeURLStatic } from '@/utils/history.js'
|
import { changeURLStatic } from '@/utils/history.js'
|
||||||
|
import metaDataProvider from '@/utils/metaDataProvider'
|
||||||
|
cornerstone.metaData.addProvider(metaDataProvider, { priority: 10 });
|
||||||
var config = {
|
var config = {
|
||||||
maxWebWorkers: 4,
|
maxWebWorkers: 4,
|
||||||
startWebWorkersOnDemand: true,
|
startWebWorkersOnDemand: true,
|
||||||
|
|
|
@ -265,6 +265,8 @@ import { getTaskUploadedDicomStudyList } from '@/api/reading'
|
||||||
import requestPoolManager from '@/utils/request-pool'
|
import requestPoolManager from '@/utils/request-pool'
|
||||||
import store from '@/store'
|
import store from '@/store'
|
||||||
import { changeURLStatic } from '@/utils/history.js'
|
import { changeURLStatic } from '@/utils/history.js'
|
||||||
|
import metaDataProvider from '@/utils/metaDataProvider'
|
||||||
|
cornerstone.metaData.addProvider(metaDataProvider, { priority: 10 });
|
||||||
// import * as cornerstoneTools from 'cornerstone-tools'
|
// import * as cornerstoneTools from 'cornerstone-tools'
|
||||||
var config = {
|
var config = {
|
||||||
maxWebWorkers: 4,
|
maxWebWorkers: 4,
|
||||||
|
|
|
@ -76,6 +76,8 @@ import { mapGetters } from 'vuex'
|
||||||
import * as dicomParser from 'dicom-parser'
|
import * as dicomParser from 'dicom-parser'
|
||||||
import * as cornerstone from 'cornerstone-core'
|
import * as cornerstone from 'cornerstone-core'
|
||||||
import * as cornerstoneWADOImageLoader from 'cornerstone-wado-image-loader'
|
import * as cornerstoneWADOImageLoader from 'cornerstone-wado-image-loader'
|
||||||
|
import metaDataProvider from '@/utils/metaDataProvider'
|
||||||
|
cornerstone.metaData.addProvider(metaDataProvider, { priority: 10 });
|
||||||
var config = {
|
var config = {
|
||||||
maxWebWorkers: 4,
|
maxWebWorkers: 4,
|
||||||
startWebWorkersOnDemand: true,
|
startWebWorkersOnDemand: true,
|
||||||
|
|
|
@ -77,6 +77,8 @@ import { mapGetters } from "vuex";
|
||||||
import * as dicomParser from 'dicom-parser'
|
import * as dicomParser from 'dicom-parser'
|
||||||
import * as cornerstone from 'cornerstone-core'
|
import * as cornerstone from 'cornerstone-core'
|
||||||
import * as cornerstoneWADOImageLoader from 'cornerstone-wado-image-loader'
|
import * as cornerstoneWADOImageLoader from 'cornerstone-wado-image-loader'
|
||||||
|
import metaDataProvider from '@/utils/metaDataProvider'
|
||||||
|
cornerstone.metaData.addProvider(metaDataProvider, { priority: 10 });
|
||||||
var config = {
|
var config = {
|
||||||
maxWebWorkers: 4,
|
maxWebWorkers: 4,
|
||||||
startWebWorkersOnDemand: true,
|
startWebWorkersOnDemand: true,
|
||||||
|
|
Loading…
Reference in New Issue