U PhL+@sddlmZddlZddlmZddlmZddlmZddl m Z ddl m Z m Z dd d d d d ddddddddddddddddddd d!d"d#d$d%d&d'd(d)d*d+d,d-d.d/d0d1d2g+ZGd3ddeeZerdd4lmZne d5eje d6d7d8\ZZGd9d d eZGd:ddeZGd;d d eZGdd d eZGd?ddeZGd@ddeZGdAddeZGdBddeZGdCddeZGdDddeZ GdEddeZ!GdFddeZ"GdGddeZ#GdHddeZ$GdIddeZ%GdJddeZ&GdKddeZ'GdLddeZ(GdMddeZ)GdNddeZ*GdOddeZ+GdPd d eZ,GdQd!d!eZ-GdRdSdSeZ.GdTd"d"eZ/GdUdVdVeZ0GdWd#d#eZ1GdXdYdYeZ2GdZd[d[eZ3Gd\d$d$eZ4Gd]d%d%eZ5Gd^d&d&eZ6Gd_d'd'eZ7Gd`d(d(eZ8Gdad)d)eZ9Gdbd*d*eZ:Gdcd+d+eZ;e dddedfdgGdhd,d,eZGdkd/d/eZ?Gdld0d0eZ@Gdmd1d1eZAGdnd2d2eZBGdodpdpeZCGdqdrdreZDGdsdtdteZEGdudvdveZFdS)w) annotationsN)Enum) TYPE_CHECKING) IgniteInfo) deprecated) min_versionoptional_importStrEnum NumpyPadModeGridSampleMode SplineModeInterpolateMode UpsampleMode BlendModePytorchPadMode NdimageModeGridSamplePadModeAverageMetricReduction LossReductionDiceCEReductionWeightChannelMatchingSkipModeMethod TraceKeysTraceStatusKeys CommonKeysGanKeysPostFix ForwardModeTransformBackends CompInitMode BoxModeName GridPatchSort FastMRIKeys SpaceKeysMetaKeys ColorOrderEngineStatsKeys DataStatsKeysImageStatsKeysLabelStatsKeysAlgoEnsembleKeys HoVerNetModeHoVerNetBranchLazyAttrBundlePropertyBundlePropertyConfigAlgoKeysc@s eZdZdZddZddZdS)r a Enum subclass that converts its value to a string. .. code-block:: python from monai.utils import StrEnum class Example(StrEnum): MODE_A = "A" MODE_B = "B" assert (list(Example) == ["A", "B"]) assert Example.MODE_A == "A" assert str(Example.MODE_A) == "A" assert monai.utils.look_up_option("A", Example) == "A" cCs|jSNvalueselfr9F/home/dell461/cl/sdc2/HISourceFinder-master-l/src/monai/utils/enums.py__str__WszStrEnum.__str__cCs|jSr4r5r7r9r9r:__repr__ZszStrEnum.__repr__N)__name__ __module__ __qualname____doc__r;r<r9r9r9r:r Es) EventEnumz ignite.enginerAbase)as_typec@s<eZdZdZdZdZdZdZdZdZ dZ d Z d Z d Z d Zd S)r zQ See also: https://numpy.org/doc/1.18/reference/generated/numpy.pad.html constantedge linear_rampmaximummeanmedianminimumreflect symmetricwrapemptyN)r=r>r?r@CONSTANTZEDGEZ LINEAR_RAMPZMAXIMUMMEANZMEDIANZMINIMUMREFLECT SYMMETRICWRAPEMPTYr9r9r9r:r fsc@s0eZdZdZdZdZdZdZdZdZ dZ d Z d S) rz The available options determine how the input array is extended beyond its boundaries when interpolating. See also: https://docs.scipy.org/doc/scipy/reference/generated/scipy.ndimage.map_coordinates.html rKz grid-mirrorrDz grid-constantnearestmirrorz grid-wraprMN) r=r>r?r@rQZ GRID_MIRRORrOZ GRID_CONSTANTNEARESTZMIRRORZ GRID_WRAPrSr9r9r9r:rxsc@seZdZdZdZdZdZdS)r a See also: https://pytorch.org/docs/stable/generated/torch.nn.functional.grid_sample.html interpolation mode of `torch.nn.functional.grid_sample` Note: (documentation from `torch.nn.functional.grid_sample`) `mode='bicubic'` supports only 4-D input. When `mode='bilinear'` and the input is 5-D, the interpolation mode used internally will actually be trilinear. However, when the input is 4-D, the interpolation mode will legitimately be bilinear. rUbilinearbicubicN)r=r>r?r@rWBILINEARBICUBICr9r9r9r:r s c@s(eZdZdZdZdZdZdZdZdZ dS) r z Order of spline interpolation. See also: https://docs.scipy.org/doc/scipy/reference/generated/scipy.ndimage.map_coordinates.html rN) r=r>r?r@ZEROONETWOTHREEFOURFIVEr9r9r9r:r sc@s,eZdZdZdZdZdZdZdZdZ dZ d S) r zb See also: https://pytorch.org/docs/stable/generated/torch.nn.functional.interpolate.html rUz nearest-exactlinearrXrY trilinearareaN) r=r>r?r@rWZ NEAREST_EXACTZLINEARrZr[Z TRILINEARZAREAr9r9r9r:r sc@s eZdZdZdZdZdZdZdS)rz> See also: :py:class:`monai.networks.blocks.UpSample` deconvZ deconvgroupZ nontrainable pixelshuffleN)r=r>r?r@ZDECONVZ DECONVGROUPZ NONTRAINABLEZ PIXELSHUFFLEr9r9r9r:rs c@seZdZdZdZdZdS)rzG See also: :py:class:`monai.data.utils.compute_importance_map` rDgaussianN)r=r>r?r@rOZGAUSSIANr9r9r9r:rsc@s eZdZdZdZdZdZdZdS)rzZ See also: https://pytorch.org/docs/stable/generated/torch.nn.functional.pad.html rDrK replicatecircularN)r=r>r?r@rOrQZ REPLICATEZCIRCULARr9r9r9r:rs c@seZdZdZdZdZdZdS)rzb See also: https://pytorch.org/docs/stable/generated/torch.nn.functional.grid_sample.html zerosborder reflectionN)r=r>r?r@ZZEROSZBORDERZ REFLECTIONr9r9r9r:rsc@s eZdZdZdZdZdZdZdS)rzD See also: :py:class:`monai.metrics.rocauc.compute_roc_auc` macroweightedmicrononeN)r=r>r?r@ZMACROZWEIGHTEDZMICRONONEr9r9r9r:rs c@s,eZdZdZdZdZdZdZdZdZ dZ d S) rzF See also: :py:func:`monai.metrics.utils.do_metric_reduction` rurHsumZ mean_batchZ sum_batchZ mean_channelZ sum_channelN) r=r>r?r@rvrPSUMZ MEAN_BATCHZ SUM_BATCHZ MEAN_CHANNELZ SUM_CHANNELr9r9r9r:rsc@seZdZdZdZdZdZdS)rz See also: - :py:class:`monai.losses.dice.DiceLoss` - :py:class:`monai.losses.dice.GeneralizedDiceLoss` - :py:class:`monai.losses.focal_loss.FocalLoss` - :py:class:`monai.losses.tversky.TverskyLoss` rurHrwN)r=r>r?r@rvrPrxr9r9r9r:rsc@seZdZdZdZdZdS)rzF See also: - :py:class:`monai.losses.dice.DiceCELoss` rHrwN)r=r>r?r@rPrxr9r9r9r:rsc@seZdZdZdZdZdZdS)rzE See also: :py:class:`monai.losses.dice.GeneralizedDiceLoss` squaresimpleuniformN)r=r>r?r@ZSQUARESIMPLEZUNIFORMr9r9r9r:rsc@seZdZdZdZdZdS)rz@ See also: :py:class:`monai.networks.nets.HighResBlock` padprojectN)r=r>r?r@ZPADZPROJECTr9r9r9r:rsc@seZdZdZdZdZdZdS)rzD See also: :py:class:`monai.networks.layers.SkipConnection` cataddmulN)r=r>r?r@ZCATADDMULr9r9r9r:r$sc@seZdZdZdZdZdS)rzI See also: :py:class:`monai.transforms.croppad.array.SpatialPad` rLendN)r=r>r?r@rRENDr9r9r9r:r.sc@seZdZdZdZdZdS)r zL See also: :py:class:`monai.transforms.engines.evaluator.Evaluator` trainevalN)r=r>r?r@ZTRAINEVALr9r9r9r:r 7sc@seZdZUdZdZded<dZded<dZded<d Zded <d Z ded <d Z ded<dZ ded<dZ ded<dZ ded<dZded<dS)rz2Extra metadata keys used for traceable transforms.classstr CLASS_NAMEidIDZ orig_size ORIG_SIZEZ extra_info EXTRA_INFOZ do_transforms DO_TRANSFORMZ _transforms KEY_SUFFIXrurvtracingTRACINGZstatusesSTATUSESlazyLAZYN)r=r>r?r@r__annotations__rrrrrrvrrrr9r9r9r:r@s          c@seZdZdZdZdS)rz4Enumerable status keys for the TraceKeys.STATUS flagZpending_during_applyN)r=r>r?r@ZPENDING_DURING_APPLYr9r9r9r:rOsc@s$eZdZdZdZdZdZdZdZdS)ra A set of common keys for dictionary based supervised training process. `IMAGE` is the input image data. `LABEL` is the training or evaluation label of segmentation or classification task. `PRED` is the prediction data of model output. `LOSS` is the loss value of current iteration. `INFO` is some useful information during training or evaluation, like loss value, etc. imagelabelpredlossmetadataN) r=r>r?r@IMAGELABELZPREDZLOSSMETADATAr9r9r9r:rUs  c@s$eZdZdZdZdZdZdZdZdS)rzD A set of common keys for generative adversarial networks. realsfakesZlatentsZg_lossZd_lossN) r=r>r?r@REALSFAKESZLATENTSZGLOSSZDLOSSr9r9r9r:rgs c@sheZdZdZeddddddZeddddd d Zeddddd d Zeddddd dZdS)rz Post-fixes.z str | Noner)prefixsuffixreturncCs|dkr |S|d|S)N_r9)rrr9r9r:_get_strwszPostFix._get_strN)keyrcCs t|dS)NZ meta_dictrrrr9r9r:meta{sz PostFix.metacCs t|dS)NZorig_meta_dictrrr9r9r: orig_metaszPostFix.orig_metacCst|tjddS)Nr\)rrrrrr9r9r: transformsszPostFix.transforms)N)N)N) r=r>r?r@ staticmethodrrrrr9r9r9r:rtsc@seZdZdZdZdZdZdS)r!a  Transform backends. Most of `monai.transforms` components first converts the input data into ``torch.Tensor`` or ``monai.data.MetaTensor``. Internally, some transforms are made by converting the data into ``numpy.array`` or ``cupy.array`` and use the underlying transform backend API to achieve the actual output array and converting back to ``Tensor``/``MetaTensor``. Transforms with more than one backend indicate the that they may convert the input data types to accommodate the underlying API. torchnumpycupyN)r=r>r?r@ZTORCHNUMPYCUPYr9r9r9r:r!sc@seZdZdZdZdZdZdS)r"z~ Mode names for instantiating a class or calling a callable. See also: :py:func:`monai.utils.module.instantiate` defaultcallabledebugN)r=r>r?r@DEFAULTCALLABLEDEBUGr9r9r9r:r"sc@s eZdZdZdZdZdZdZdS)JITMetadataKeysz Keys stored in the metadata file for saved Torchscript models. Some of these are generated by the routines and others are optionally provided by users. name timestampversion descriptionN)r=r>r?r@NAME TIMESTAMPVERSION DESCRIPTIONr9r9r9r:rs rc@s4eZdZdZdZdZdZdZdZdZ dZ d Z d Z d S) r#z Box mode names. ZxyxyZxyzxyzZxxyyZxxyyzzZxyxyzzZxywhZxyzwhdZccwhZcccwhdN) r=r>r?r@ZXYXYZXYZXYZZXXYYZXXYYZZZXYXYZZZXYWHZXYZWHDZCCWHZCCCWHDr9r9r9r:r#sc@s eZdZdZdZdZdZdZdS) ProbMapKeyszN The keys to be used for generating the probability maps from patches Z mask_locationZ mask_sizeZ num_patchesrN)r=r>r?r@LOCATIONSIZECOUNTrr9r9r9r:rs rc@s@eZdZdZdZdZdZeddZeddZ ed d Z d S) r$zE The sorting method for the generated patches in `GridPatch` randomminmaxcCs |dSNrrwxr9r9r:min_fnszGridPatchSort.min_fncCs|d Srrrr9r9r:max_fnszGridPatchSort.max_fncCsP|tjkrtjS|tjkr tjS|tjkr0tjStd|dddtDdS)Nz0sort_fn should be one of the following values, "z " was given:cSsg|] }|jqSr9r5).0er9r9r: sz-GridPatchSort.get_sort_fn..)r$RANDOMrMINrMAXr ValueError)Zsort_fnr9r9r: get_sort_fns     zGridPatchSort.get_sort_fnN) r=r>r?r@rrrrrrrr9r9r9r:r$s  c@seZdZdZdZdZdZdS) PatchKeyszV The keys to be used for metadata of patches extracted from any kind of image locationsizecountN)r=r>r?r@rrrr9r9r9r:rsrc@s*eZdZdZejZejZejZdZdZ dS) WSIPatchKeyszW The keys to be used for metadata of patches extracted from whole slide images levelpathN) r=r>r?r@rrrrZLEVELPATHr9r9r9r:rs rc@s0eZdZdZdZdZdZdZdZdZ dZ d Z d S) r%zJ The keys to be used for extracting data from the fastMRI dataset ZkspacemaskfilenameZreconstruction_rssZ acquisitionrnormZ patient_idN) r=r>r?r@ZKSPACEMASKZFILENAMEZRECONZ ACQUISITIONrZNORMZPIDr9r9r9r:r%sc@seZdZdZdZdZdS)r&z The coordinate system keys, for example, Nifti1 uses Right-Anterior-Superior or "RAS", DICOM (0020,0032) uses Left-Posterior-Superior or "LPS". This type does not distinguish spatial 1/2/3D. RASLPSN)r=r>r?r@rrr9r9r9r:r&sc@s$eZdZdZdZdZdZdZdZdS)r'z' Typical keys for MetaObj.meta affineZoriginal_affineZ spatial_shapespaceZoriginal_channel_dimN) r=r>r?r@AFFINEZORIGINAL_AFFINEZ SPATIAL_SHAPESPACEZORIGINAL_CHANNEL_DIMr9r9r9r:r's c@seZdZdZdZdZdS)r(z5 Enums for color order. Expand as necessary. RGBBGRN)r=r>r?r@rrr9r9r9r:r($sc@s,eZdZdZdZdZdZdZdZdZ dZ d S) r)zL Default keys for the statistics of trainer and evaluator engines. rankZcurrent_iterationZ current_epochZ total_epochsZtotal_iterationsZbest_validation_epochZbest_validation_metricN) r=r>r?r@RANKZCURRENT_ITERATIONZ CURRENT_EPOCHZ TOTAL_EPOCHSZTOTAL_ITERATIONSZBEST_VALIDATION_EPOCHZBEST_VALIDATION_METRICr9r9r9r:r)-sc@s0eZdZdZdZdZdZdZdZdZ dZ d Z d S) r*zA Defaults keys for dataset statistical analysis modules Z stats_summaryZstats_by_casesZimage_filepathZlabel_filepathZ image_statsZimage_foreground_statsZ label_statsZimage_histogramN) r=r>r?r@ZSUMMARYZBY_CASEZBY_CASE_IMAGE_PATHZBY_CASE_LABEL_PATHZ IMAGE_STATSZFG_IMAGE_STATSZ LABEL_STATSZIMAGE_HISTOGRAMr9r9r9r:r*<sc@s,eZdZdZdZdZdZdZdZdZ dZ d S) r+zG Defaults keys for dataset statistical analysis image modules shapechannelsZ cropped_shapespacingZsizemmZ intensity histogramN) r=r>r?r@SHAPEZCHANNELSZ CROPPED_SHAPESPACINGZSIZEMMZ INTENSITYZ HISTOGRAMr9r9r9r:r+Lsc@s(eZdZdZdZdZdZdZdZdZ dS) r,zG Defaults keys for dataset statistical analysis label modules labelsZforeground_percentageZimage_intensityrrZ ncomponentsN) r=r>r?r@Z LABEL_UIDZ PIXEL_PCTZ IMAGE_INTSTrZ LABEL_SHAPEZ LABEL_NCOMPr9r9r9r:r,[sz1.2z1.4zplease use `AlgoKeys` instead.)sinceremoved msg_suffixc@seZdZdZdZdZdZdS)r-z) Default keys for Mixed Ensemble identifierZ infer_algo best_metricN)r=r>r?r@rALGOSCOREr9r9r9r:r-isc@seZdZdZdZdZdS)r.z Modes for HoVerNet model: `FAST`: a faster implementation (than original) `ORIGINAL`: the original implementation FASTORIGINALN)r=r>r?r@rrr9r9r9r:r.tsc@seZdZdZdZdZdZdS)r/a Three branches of HoVerNet model, which results in three outputs: `HV` is horizontal and vertical gradient map of each nucleus (regression), `NP` is the pixel prediction of all nuclei (segmentation), and `NC` is the type of each nucleus (classification). Zhorizontal_verticalZnucleus_predictionZtype_predictionN)r=r>r?r@ZHVZNPZNCr9r9r9r:r/sc@s,eZdZdZdZdZdZdZdZdZ dZ d S) r0aG MetaTensor with pending operations requires some key attributes tracked especially when the primary array is not up-to-date due to lazy evaluation. This class specifies the set of key attributes to be tracked for each MetaTensor. See also: :py:func:`monai.transforms.lazy.utils.resample` for more details. Z lazy_shapeZ lazy_affineZlazy_padding_modeZlazy_interpolation_modeZ lazy_dtypeZlazy_align_cornersZlazy_resample_modeN) r=r>r?r@rrZ PADDING_MODEZ INTERP_MODEDTYPEZ ALIGN_CORNERSZ RESAMPLE_MODEr9r9r9r:r0sc@seZdZdZdZdZdS)r1z Bundle property fields: `DESC` is the description of the property. `REQUIRED` is flag to indicate whether the property is required or optional. rrequiredN)r=r>r?r@ZDESCZREQUIREDr9r9r9r:r1sc@seZdZdZdZdZdS)r2aU additional bundle property fields for config based bundle workflow: `ID` is the config item ID of the property. `REF_ID` is the ID of config item which is supposed to refer to this property. For properties that do not have `REF_ID`, `None` should be set. this field is only useful to check the optional property ID. rZrefer_idN)r=r>r?r@rZREF_IDr9r9r9r:r2sc@s eZdZdZdZdZdZdZdS)r3aF Default keys for templated Auto3DSeg Algo. `ID` is the identifier of the algorithm. The string has the format of __. `ALGO` is the Auto3DSeg Algo instance. `IS_TRAINED` is the status that shows if the Algo has been trained. `SCORE` is the score the Algo has achieved after training. rZ algo_instanceZ is_trainedrN)r=r>r?r@rrZ IS_TRAINEDrr9r9r9r:r3s c@s,eZdZdZdZdZdZdZdZdZ dZ d S) AdversarialKeysaI Keys used by the AdversarialTrainer. `REALS` are real images from the batch. `FAKES` are fake images generated by the generator. Are the same as PRED. `REAL_LOGITS` are logits of the discriminator for the real images. `FAKE_LOGIT` are logits of the discriminator for the fake images. `RECONSTRUCTION_LOSS` is the loss value computed by the reconstruction loss function. `GENERATOR_LOSS` is the loss value computed by the generator loss function. It is the discriminator loss for the fake images. That is backpropagated through the generator only. `DISCRIMINATOR_LOSS` is the loss value computed by the discriminator loss function. It is the discriminator loss for the real images and the fake images. That is backpropagated through the discriminator only. rZ real_logitsrZ fake_logitsZreconstruction_lossZgenerator_lossZdiscriminator_lossN) r=r>r?r@rZ REAL_LOGITSrZ FAKE_LOGITSZRECONSTRUCTION_LOSSZGENERATOR_LOSSZDISCRIMINATOR_LOSSr9r9r9r:rsrc@s<eZdZdZdZdZdZdZdZdZ dZ d Z d Z d Z d Zd S)AdversarialIterationEventszG Keys used to define events as used in the AdversarialTrainer. Zreconstruction_loss_completedZgenerator_forward_completedZ)generator_discriminator_forward_completedZgenerator_loss_completedZgenerator_backward_completedZgenerator_model_completedZ%discriminator_reals_forward_completedZ%discriminator_fakes_forward_completedZdiscriminator_loss_completedZ discriminator_backward_completedZdiscriminator_model_completedN)r=r>r?r@ZRECONSTRUCTION_LOSS_COMPLETEDZGENERATOR_FORWARD_COMPLETEDZ)GENERATOR_DISCRIMINATOR_FORWARD_COMPLETEDZGENERATOR_LOSS_COMPLETEDZGENERATOR_BACKWARD_COMPLETEDZGENERATOR_MODEL_COMPLETEDZ%DISCRIMINATOR_REALS_FORWARD_COMPLETEDZ%DISCRIMINATOR_FAKES_FORWARD_COMPLETEDZDISCRIMINATOR_LOSS_COMPLETEDZ DISCRIMINATOR_BACKWARD_COMPLETEDZDISCRIMINATOR_MODEL_COMPLETEDr9r9r9r:rsrc@seZdZdZdZdZdS) OrderingTypeZ raster_scanZs_curverN)r=r>r?Z RASTER_SCANZS_CURVErr9r9r9r:rsrc@seZdZdZdZdZdS)OrderingTransformationsZ rotate_90 transposerKN)r=r>r?Z ROTATE_90Z TRANSPOSErQr9r9r9r:rsr)G __future__rrenumrtypingr monai.configrZ monai.utilsrmonai.utils.modulerr__all__rr Z ignite.enginerAOPT_IMPORT_VERSIONrr rr r r rrrrrrrrrrrrr rrrrrr!r"rr#rr$rrr%r&r'r(r)r*r+r,r-r.r/r0r1r2r3rrrrr9r9r9r: s     /