extensions/xnat/src/utils/IO/classes/DICOMSEGWriter.js
/**
   * write - Writes the DICOM SEG.
   *
   * @param  {string} name The name/series description of the DICOM SEG.
   * @returns {Promise} A promise that resolves to a Blob containing the DICOM SEG.
   */
Writes the DICOM SEG.
@param  {string} name The name/series description of the DICOM SEG.
@returns {Promise} A promise that resolves to a Blob containing the DICOM SEG.
Writes the DICOM SEG . @param { string } name The name / series description of the DICOM SEG . @returns { Promise } A promise that resolves to a Blob containing the DICOM SEG .
async write(name, element) {
    return new Promise(resolve => {
      const stackToolState = cornerstoneTools.getToolState(element, 'stack');
      const imageIds = stackToolState.data[0].imageIds;
      let imagePromises = [];
      for (let i = 0; i < imageIds.length; i++) {
        imagePromises.push(cornerstone.loadAndCacheImage(imageIds[i]));
      }
      const { labelmaps3D } = segmentationModule.getters.labelmaps3D(element);
      Promise.all(imagePromises)
        .then(images => {
          const { date, time } = this._generateDateTime();
          const options = {
            includeSliceSpacing: true,
            rleEncode: false, 
            SeriesDescription: name,
            Manufacturer: this._seriesInfo.equipment.manufacturerName,
            ManufacturerModelName: this._seriesInfo.equipment
              .manufacturerModelName,
            SoftwareVersions: this._seriesInfo.equipment.softwareVersion,
            SeriesDate: date,
            SeriesTime: time,
            ContentDate: date,
            ContentTime: time,
          };
          const segBlob = dcmjs.adapters.Cornerstone.Segmentation.generateSegmentation(
            images,
            labelmaps3D,
            options
          );
          resolve(segBlob);
        })
        .catch(err => {
          console.log(err);
        });
    });
  }
async write ( name , element ) { return new Promise ( resolve => { const stackToolState = cornerstoneTools . getToolState ( element , 'stack' ) ; const imageIds = stackToolState . data [ 0 ] . imageIds ; let imagePromises = [ ] ; for ( let i = 0 ; i < imageIds . length ; i ++ ) { imagePromises . push ( cornerstone . loadAndCacheImage ( imageIds [ i ] ) ) ; } const { labelmaps3D } = segmentationModule . getters . labelmaps3D ( element ) ; Promise . all ( imagePromises ) . then ( images => { const { date , time } = this . _generateDateTime ( ) ; const options = { includeSliceSpacing : true , rleEncode : false , SeriesDescription : name , Manufacturer : this . _seriesInfo . equipment . manufacturerName , ManufacturerModelName : this . _seriesInfo . equipment . manufacturerModelName , SoftwareVersions : this . _seriesInfo . equipment . softwareVersion , SeriesDate : date , SeriesTime : time , ContentDate : date , ContentTime : time , } ; const segBlob = dcmjs . adapters . Cornerstone . Segmentation . generateSegmentation ( images , labelmaps3D , options ) ; resolve ( segBlob ) ; } ) . catch ( err => { console . log ( err ) ; } ) ; } ) ; }
write - Writes the DICOM SEG.
write - Writes the DICOM SEG .
// Not yet currently supported by the XNAT ROI plugin