跳到主要内容

PolySeg 被外置为独立包

PolySeg 已经从 cornerstoneTools 包中移出, 现在是一个独立包,名为 @cornerstonejs/polymorphic-segmentation。

用法

它不再包含在 cornerstoneTools 包里了。如果你需要启用多态转换, 就得自行安装它,并用它来初始化 cornerstoneTools

import * as polyseg from '@cornerstonejs/polymorphic-segmentation';
import { init } from '@cornerstonejs/tools';

init({
addons: {
polyseg,
},
});
备注

做这个改动是因为我们并没有把 polyseg-wasm 依赖随 cornerstone tools 一起发布。 打包工具对其中包含的静态资源有过一些抱怨。现在,不想用它的人不受影响, 而想用它的人需要自己安装并初始化 cornerstoneTools

导出内容

我们此前并没有从 tools 目录暴露任何相关函数。如果你需要某个东西, 请从 @cornerstonejs/polymorphic-segmentation 引入。 它导出以下内容:

import {
canComputeRequestedRepresentation,
// 计算
computeContourData,
computeLabelmapData,
computeSurfaceData,
// 更新
updateSurfaceData,
// 初始化
init,
} from '@cornerstonejs/polymorphic-segmentation';

computeAndAddContourRepresentation、computeAndAddLabelmapRepresentation、computeAndAddSurfaceRepresentation

这几个函数已从 tools 目录中移除。如果你恰好需要它们(可能性不大), 就得自己组装:

import { utilities } from '@cornerstonejs/tools';
import { computeLabelmapData } from '@cornerstonejs/polymorphic-segmentation';

const { computeAndAddRepresentation } = utilities.segmentation;

// 标签图
const labelmapData = await computeAndAddRepresentation(
segmentationId,
Representations.Labelmap,
() => computeLabelmapData(segmentationId, { viewport }),
() => null
);

// 曲面
import {
computeSurfaceData,
updateSurfaceData,
} from '@cornerstonejs/polymorphic-segmentation';

const SurfaceData = await computeAndAddRepresentation(
segmentationId,
Representations.Surface,
() => computeSurfaceData(segmentationId, { viewport }),
() => updateSurfaceData(segmentationId, { viewport })
);

// 轮廓同理
import { computeContourData } from '@cornerstonejs/polymorphic-segmentation';

const contourData = await computeAndAddRepresentation(
segmentationId,
Representations.Contour,
() => computeContourData(segmentationId, { viewport }),
() => undefined
);