dcmjs-org / dcmjs

Javascript implementation of DICOM manipulation
https://dcmjs.netlify.com/
MIT License
292 stars 111 forks source link

Cannot read properties of undefined (reading 'forEach') #272

Closed igor-sysoev closed 2 years ago

igor-sysoev commented 2 years ago

Hello! I am trying to create a Measurement Report with a Freehand tool in it using dcmjs cornerstone adapter (0.17.3, part of OHIF viewer), however I am getting this issue:

​ TypeError: Cannot read properties of undefined (reading 'forEach')
    at expandPoints (dcmjs.es.js:7397:1)
    at Polyline.contentItem (dcmjs.es.js:7432:1)
    at dcmjs.es.js:6898:1
    at Array.forEach (<anonymous>)
    at TID1501MeasurementGroup.contentItem (dcmjs.es.js:6897:1)
    at dcmjs.es.js:6834:1
    at Array.forEach (<anonymous>)
    at TID1500MeasurementReport.addTID1501MeasurementGroups (dcmjs.es.js:6833:1)
    at TID1500MeasurementReport.contentItem (dcmjs.es.js:6818:1)
    at Function.generateReport (dcmjs.es.js:7057:1)

As I've noticed, the issue seems to be due to lack of implementation of getTID300RepresentationArguments method in this file https://github.com/dcmjs-org/dcmjs/blob/0e1e2921e953bde8f4707b025f584a6c558ffedd/src/adapters/Cornerstone/Freehand.js

Thanks!

pieper commented 2 years ago

Hi - Most of the adaptor work is focused on cornerstone 3D now so I don't expect we'll see much work on the older code. If you can find a workaround that would be great. @sedghi or @JamesAPetts might be able to comment.

JamesAPetts commented 2 years ago

@pieper is correct that most people are focused on Cornerstone3D going forwards, however, you are welcome to check how the other adapters work and write a PR to complete freehand ROI adaptation for Cornerstone Legacy. There is the PlanarFreehandROI adapter in the Cornerstone3D adapters which should be pretty similar conceptually as a starting point.

igor-sysoev commented 2 years ago

Freehand adapter was introduced in 0.19.0, although it was commented out for some reason. I restored it in my fork if anyone has a similiar problem https://github.com/supasus/dcmjs-polyline-fix.