Source: segment.js

  1. const _attrs = Symbol('attrs')
  2. /**
  3. * A segment.
  4. *
  5. * Describes an item of the Segment Sequence of a DICOM Segmentation instance.
  6. *
  7. * @class
  8. * @memberof segment
  9. */
  10. class Segment {
  11. /**
  12. * @param {Object} options - Options for construction of Segment
  13. * @param {string} options.uid - Unique tracking identifier
  14. * @param {number} options.number - Segment Number (one-based index value)
  15. * @param {string} options.label - Segment Label
  16. * @param {string} options.algorithmName - Segment Algorithm Name
  17. * @param {Object} options.algorithmType - Segment Algorithm Type
  18. * @param {Object} options.propertyCategory - Segmented Property Category Code
  19. * @param {Object} options.propertyType - Segmented Property Type Code
  20. * @param {string} options.studyInstanceUID - Study Instance UID of DICOM
  21. * Segmentation instances
  22. * @param {string} options.seriesInstanceUID - Series Instance UID of DICOM
  23. * Segmentation instances
  24. * @param {string[]} options.sopInstanceUIDs - SOP Instance UIDs of DICOM
  25. * Segmentation instances
  26. * @param {string|undefined} options.paletteColorLookupTableUID - Palette
  27. * Color Lookup Table UID
  28. */
  29. constructor ({
  30. uid,
  31. number,
  32. label,
  33. propertyCategory,
  34. propertyType,
  35. algorithmType,
  36. algorithmName,
  37. studyInstanceUID,
  38. seriesInstanceUID,
  39. sopInstanceUIDs,
  40. paletteColorLookupTableUID
  41. }) {
  42. this[_attrs] = {}
  43. if (uid === undefined) {
  44. throw new Error('Unique Tracking Identifier is required.')
  45. } else {
  46. this[_attrs].uid = uid
  47. }
  48. if (number === undefined) {
  49. throw new Error('Segment Number is required.')
  50. }
  51. this[_attrs].number = number
  52. if (label === undefined) {
  53. throw new Error('Segment Label is required.')
  54. }
  55. this[_attrs].label = label
  56. if (propertyCategory === undefined) {
  57. throw new Error('Segmented Property Category Code is required.')
  58. }
  59. this[_attrs].propertyCategory = propertyCategory
  60. if (propertyType === undefined) {
  61. throw new Error('Segmented Property Type Code is required.')
  62. }
  63. this[_attrs].propertyType = propertyType
  64. if (algorithmName === undefined) {
  65. throw new Error('Segment Algorithm Name is required.')
  66. }
  67. this[_attrs].algorithmType = algorithmType
  68. if (algorithmType === undefined) {
  69. throw new Error('Segment Algorithm Type is required.')
  70. }
  71. this[_attrs].algorithmName = algorithmName
  72. if (studyInstanceUID === undefined) {
  73. throw new Error('Study Instance UID is required.')
  74. }
  75. this[_attrs].studyInstanceUID = studyInstanceUID
  76. if (seriesInstanceUID === undefined) {
  77. throw new Error('Series Instance UID is required.')
  78. }
  79. this[_attrs].seriesInstanceUID = seriesInstanceUID
  80. if (sopInstanceUIDs === undefined) {
  81. throw new Error('SOP Instance UIDs are required.')
  82. }
  83. this[_attrs].sopInstanceUIDs = sopInstanceUIDs
  84. this[_attrs].paletteColorLookupTableUID = paletteColorLookupTableUID
  85. Object.freeze(this)
  86. }
  87. /**
  88. * Unique Tracking Identifier
  89. *
  90. * @type string
  91. */
  92. get uid () {
  93. return this[_attrs].uid
  94. }
  95. /**
  96. * Segment Number.
  97. *
  98. * @type number
  99. */
  100. get number () {
  101. return this[_attrs].number
  102. }
  103. /**
  104. * Segment Label
  105. *
  106. * @type string
  107. */
  108. get label () {
  109. return this[_attrs].label
  110. }
  111. /**
  112. * Segment Algorithm Name
  113. *
  114. * @type string
  115. */
  116. get algorithmName () {
  117. return this[_attrs].algorithmName
  118. }
  119. /**
  120. * Segment Algorithm Type
  121. *
  122. * @type object
  123. */
  124. get algorithmType () {
  125. return this[_attrs].algorithmType
  126. }
  127. /**
  128. * Segmented Property Category Code
  129. *
  130. * @type object
  131. */
  132. get propertyCategory () {
  133. return this[_attrs].propertyCategory
  134. }
  135. /**
  136. * Segmented Property Type Code
  137. *
  138. * @type object
  139. */
  140. get propertyType () {
  141. return this[_attrs].propertyType
  142. }
  143. /**
  144. * Study Instance UID of DICOM Segmentation instances.
  145. *
  146. * @type string
  147. */
  148. get studyInstanceUID () {
  149. return this[_attrs].studyInstanceUID
  150. }
  151. /**
  152. * Series Instance UID of DICOM Segmentation instances.
  153. *
  154. * @type string
  155. */
  156. get seriesInstanceUID () {
  157. return this[_attrs].seriesInstanceUID
  158. }
  159. /**
  160. * SOP Instance UIDs of DICOM Segmentation instances.
  161. *
  162. * @type string[]
  163. */
  164. get sopInstanceUIDs () {
  165. return this[_attrs].sopInstanceUIDs
  166. }
  167. /**
  168. * Palette Color Lookup Table UID.
  169. *
  170. * @type string
  171. */
  172. get paletteColorLookupTableUID () {
  173. return this[_attrs].paletteColorLookupTableUID
  174. }
  175. }
  176. export { Segment }