Skip to content

Commit

Permalink
Fix(cornerstone): the circle adapter to prevent writing undefined (#266)
Browse files Browse the repository at this point in the history
* fix(dcmjs):The area and diameter were undefined.

The area and diameter written to the DICOM SR had
the value "undefined" because neither item was being
computed.  Also, the diameter used the area as the
actual value (which happened to be undefined).  This
change reads the values from the source adapter and
then provides them to the TID.300 adapter in the correct
places.

* Removed an unnecessary console log

* fix(dcmjs):Add a comment about the 0 dummy values
  • Loading branch information
wayfarer3130 committed May 16, 2022
1 parent e5e6c30 commit cef28a9
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
11 changes: 8 additions & 3 deletions packages/adapters/src/adapters/Cornerstone/CircleRoi.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ class CircleRoi {
NUMGroup,
SCOORDGroup
} = MeasurementReport.getSetupMeasurementData(MeasurementGroup);
console.log("Get cornerstone data from", MeasurementGroup);

const { GraphicData } = SCOORDGroup;

Expand All @@ -29,7 +28,10 @@ class CircleRoi {
toolType: CircleRoi.toolType,
active: false,
cachedStats: {
area: NUMGroup.MeasuredValueSequence.NumericValue
area: NUMGroup.MeasuredValueSequence.NumericValue,
// Dummy values to be updated by cornerstone
radius: 0,
perimeter: 0
},
handles: {
end: {
Expand Down Expand Up @@ -67,8 +69,9 @@ class CircleRoi {
static getTID300RepresentationArguments(tool) {
const { cachedStats, handles, finding, findingSites } = tool;
const { start: center, end } = handles;
const { area } = cachedStats;
const { area, radius } = cachedStats;

const perimeter = 2 * Math.PI * radius;
const points = [];

points.push(center);
Expand All @@ -78,6 +81,8 @@ class CircleRoi {

return {
area,
perimeter,
radius,
points,
trackingIdentifierTextValue,
finding,
Expand Down
7 changes: 4 additions & 3 deletions packages/adapters/src/utilities/TID300/Circle.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,15 @@ export default class Circle extends TID300Measurement {
const {
points,
ReferencedSOPSequence,
use3DSpatialCoordinates = false
use3DSpatialCoordinates = false,
perimeter,
area
} = this.props;

// Combine all lengths to save the perimeter
// @ToDO The permiter has to be implemented
// const reducer = (accumulator, currentValue) => accumulator + currentValue;
// const perimeter = lengths.reduce(reducer);
const perimeter = {};
const GraphicData = expandPoints(points);

// TODO: Add Mean and STDev value of (modality?) pixels
Expand Down Expand Up @@ -84,7 +85,7 @@ export default class Circle extends TID300Measurement {
CodingSchemeVersion: "1.4",
CodeMeaning: "SquareMilliMeter"
},
NumericValue: perimeter
NumericValue: area
},
ContentSequence: {
RelationshipType: "INFERRED FROM",
Expand Down

0 comments on commit cef28a9

Please sign in to comment.