extensions/xnat/src/components/XNATSegmentationExportMenu/XNATSegmentationExportMenu.js
/**
   * componentDidMount - On mount, fetch a list of available projects from XNAT.
   *
   * @returns {null}
   */
On mount, fetch a list of available projects from XNAT.
@returns {null}
On mount fetch a list of available projects from XNAT . @returns { null }
componentDidMount() {
    const { firstImageId } = this.props;
    const element = getElementForFirstImageId(firstImageId);
    const { labelmaps3D, activeLabelmapIndex } =
      segmentationModule.getters.labelmaps3D(element);
    const labelmap3D = labelmaps3D[activeLabelmapIndex];
    if (!firstImageId || !labelmap3D) {
      return;
    }
    removeEmptyLabelmaps2D(labelmap3D);
    const importMetadata = segmentationModule.setters.importMetadata(
      firstImageId
    );
    const metadata = labelmap3D.metadata;
    if (!metadata) {
      return;
    }
    const segList = [];
    for (let i = 0; i < metadata.length; i++) {
      if (metadata[i]) {
        const hasData =
          labelmap3D.labelmaps2D.some(labelmap2D => {
            return labelmap2D.segmentsOnLabelmap.includes(i);
        });
        if (hasData) {
          segList.push({
            index: i,
            metadata: metadata[i],
          });
        }
      }
    }
    let defaultName = '';
    if (segList && segList.length === 1) {
      defaultName = segList[0].metadata.SegmentLabel;
    }
    this._roiCollectionName = defaultName;
    this.setState({ segList, importMetadata });
  }
componentDidMount ( ) { const { firstImageId } = this . props ; const element = getElementForFirstImageId ( firstImageId ) ; const { labelmaps3D , activeLabelmapIndex } = segmentationModule . getters . labelmaps3D ( element ) ; const labelmap3D = labelmaps3D [ activeLabelmapIndex ] ; if ( ! firstImageId || ! labelmap3D ) { return ; } removeEmptyLabelmaps2D ( labelmap3D ) ; const importMetadata = segmentationModule . setters . importMetadata ( firstImageId ) ; const metadata = labelmap3D . metadata ; if ( ! metadata ) { return ; } const segList = [ ] ; for ( let i = 0 ; i < metadata . length ; i ++ ) { if ( metadata [ i ] ) { const hasData = labelmap3D . labelmaps2D . some ( labelmap2D => { return labelmap2D . segmentsOnLabelmap . includes ( i ) ; } ) ; if ( hasData ) { segList . push ( { index : i , metadata : metadata [ i ] , } ) ; } } } let defaultName = '' ; if ( segList && segList . length === 1 ) { defaultName = segList [ 0 ] . metadata . SegmentLabel ; } this . _roiCollectionName = defaultName ; this . setState ( { segList , importMetadata } ) ; }
componentDidMount - On mount, fetch a list of available projects from XNAT.
componentDidMount - On mount fetch a list of available projects from XNAT .
// Check if the segment has labelmap data