extensions/xnat/src/components/XNATSegmentationImportMenu/XNATSegmentationImportMenu.js
/**
   * async _getAndImportFile - Imports the file from the REST url and loads it into
   *                     cornerstoneTools toolData.
   *
   * @param  {string} uri             The REST URI of the file.
   * @param  {object} segmentation    An object describing the roiCollection to
   *                                  import.
   * @param  {object} scan            The scan to import onto.
   * @returns {null}
   */
async _getAndImportFile - Imports the file from the REST url and loads it into
cornerstoneTools toolData.

@param  {string} uri             The REST URI of the file.
@param  {object} segmentation    An object describing the roiCollection to
import.
@param  {object} scan            The scan to import onto.
@returns {null}
async _getAndImportFile - Imports the file from the REST url and loads it into cornerstoneTools toolData . @param { string } uri The REST URI of the file . @param { object } segmentation An object describing the roiCollection to import . @param { object } scan The scan to import onto . @returns { null }
async _getAndImportFile(uri, segmentation, scan) {
    uri = uri.slice(1);
    const seriesInstanceUid = scan.referencedSeriesInstanceUid;
    const maskImporter = new MaskImporter(
      seriesInstanceUid,
      this.updateProgress
    );
    const firstImageId = _getFirstImageIdFromSeriesInstanceUid(
      seriesInstanceUid
    );
    switch (segmentation.collectionType) {
      case 'SEG':
        this._updateImportingText(segmentation.name);
        segmentationModule.setters.importMetadata(firstImageId, {
          label: segmentation.label,
          type: 'SEG',
          name: segmentation.name,
          modified: false,
        });
        const segArrayBuffer = await fetchArrayBuffer(uri).promise;
        await maskImporter.importDICOMSEG(segArrayBuffer);
        this.props.onImportComplete();
        break;
      case 'NIFTI':
        this._updateImportingText(segmentation.name);
        segmentationModule.setters.importMetadata(firstImageId, {
          label: segmentation.label,
          type: 'NIFTI',
          name: segmentation.name,
          modified: false,
        });
        const niftiArrayBuffer = await fetchArrayBuffer(uri).promise;
        maskImporter.importNIFTI(niftiArrayBuffer);
        this.props.onImportComplete();
        break;
      default:
        console.error(
          `MaskImportListDialog._getAndImportFile not configured for filetype: ${fileType}.`
        );
    }
  }
async _getAndImportFile ( uri , segmentation , scan ) { uri = uri . slice ( 1 ) ; const seriesInstanceUid = scan . referencedSeriesInstanceUid ; const maskImporter = new MaskImporter ( seriesInstanceUid , this . updateProgress ) ; const firstImageId = _getFirstImageIdFromSeriesInstanceUid ( seriesInstanceUid ) ; switch ( segmentation . collectionType ) { case 'SEG' : this . _updateImportingText ( segmentation . name ) ; segmentationModule . setters . importMetadata ( firstImageId , { label : segmentation . label , type : 'SEG' , name : segmentation . name , modified : false , } ) ; const segArrayBuffer = await fetchArrayBuffer ( uri ) . promise ; await maskImporter . importDICOMSEG ( segArrayBuffer ) ; this . props . onImportComplete ( ) ; break ; case 'NIFTI' : this . _updateImportingText ( segmentation . name ) ; segmentationModule . setters . importMetadata ( firstImageId , { label : segmentation . label , type : 'NIFTI' , name : segmentation . name , modified : false , } ) ; const niftiArrayBuffer = await fetchArrayBuffer ( uri ) . promise ; maskImporter . importNIFTI ( niftiArrayBuffer ) ; this . props . onImportComplete ( ) ; break ; default : console . error ( ` ${ fileType } ` ) ; } }
async _getAndImportFile - Imports the file from the REST url and loads it into
                     cornerstoneTools toolData.
async _getAndImportFile - Imports the file from the REST url and loads it into cornerstoneTools toolData .
// The URIs fetched have an additional /, so remove it. // Store that we've imported a collection for this series. // Store that we've imported a collection for this series.