o  iM@sddlmZddlZddlmZddlmZddlmZm Z gdZ Gddde eZ Gd d d e Z Gd d d e ZGd dde ZGddde ZGddde ZGddde ZGddde ZGddde ZGddde ZGddde ZGddde ZGdd d e ZGd!d"d"e ZGd#d$d$e ZGd%d&d&e ZGd'd(d(e ZGd)d*d*e ZGd+d,d,e ZGd-d.d.e ZGd/d0d0e Z Gd1d2d2e Z!Gd3d4d4e Z"Gd5d6d6e Z#Gd7d8d8e Z$Gd9d:d:e Z%Gd;d<dd>e Z'Gd?d@d@e Z(GdAdBdBe Z)GdCdDdDe Z*GdEdFdFe Z+GdGdHdHe Z,GdIdJdJe Z-GdKdLdLe Z.GdMdNdNe Z/GdOdPdPe Z0GdQdRdRe Z1GdSdTdTe Z2GdUdVdVe Z3GdWdXdXe Z4GdYdZdZe Z5Gd[d\d\e Z6Gd]d^d^e Z7Gd_d`d`e Z8Gdadbdbe Z9Gdcdddde Z:Gdedfdfe Z;Gdgdhdhe Zerddml?m@Z@n e dne>jAedodpdq\Z@ZBGdrdsdse@ZCdS)t) annotationsN)Enum) TYPE_CHECKING) min_versionoptional_import),StrEnum NumpyPadModeGridSampleMode SplineModeInterpolateMode UpsampleModeDownsampleMode BlendModePytorchPadMode NdimageModeGridSamplePadModeAverageMetricReduction LossReductionDiceCEReductionWeightChannelMatchingSkipModeMethod TraceKeysTraceStatusKeys CommonKeysGanKeysPostFix ForwardModeTransformBackends CompInitMode BoxModeName GridPatchSort FastMRIKeys SpaceKeysMetaKeys ColorOrderEngineStatsKeys DataStatsKeysImageStatsKeysLabelStatsKeys HoVerNetModeHoVerNetBranchLazyAttrBundlePropertyBundlePropertyConfigAlgoKeys IgniteInfoc@s eZdZdZddZddZdS)ra 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" cC|jSNvalueselfr9S/home/dell461/cl/sdc2/last_ska_mid/HISourceFinder-master-l/src/monai/utils/enums.py__str__VzStrEnum.__str__cCr3r4r5r7r9r9r:__repr__Yr<zStrEnum.__repr__N)__name__ __module__ __qualname____doc__r;r=r9r9r9r:rDs rc@<eZdZdZdZdZdZdZdZdZ dZ d Z d Z d Z d Zd S)rzQ See also: https://numpy.org/doc/1.18/reference/generated/numpy.pad.html constantedge linear_rampmaximummeanmedianminimumreflect symmetricwrapemptyN)r>r?r@rACONSTANTZEDGEZ LINEAR_RAMPZMAXIMUMMEANZMEDIANZMINIMUMREFLECT SYMMETRICWRAPZEMPTYr9r9r9r:r]rc@0eZdZdZdZdZdZdZdZdZ 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 rJz grid-mirrorrCz grid-constantnearestmirrorz grid-wraprLN) r>r?r@rArPZ GRID_MIRRORrNZ GRID_CONSTANTNEARESTZMIRRORZ GRID_WRAPrRr9r9r9r:rorc@eZdZdZdZdZdZdS)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@rArWBILINEARBICUBICr9r9r9r:r s  r c@(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@rAZEROZONEZTWOZTHREEZFOURZFIVEr9r9r9r:r sr c@,eZdZdZdZdZdZdZdZdZ dZ d S) r zb See also: https://pytorch.org/docs/stable/generated/torch.nn.functional.interpolate.html rUz nearest-exactlinearrZr[ trilinearareaN) r>r?r@rArWZ NEAREST_EXACTZLINEARr\r]Z TRILINEARZAREAr9r9r9r:r r c@ eZdZdZdZdZdZdZdS)r > See also: :py:class:`monai.networks.blocks.UpSample` deconvZ deconvgroupZ nontrainable pixelshuffleN)r>r?r@rAZDECONVZ DECONVGROUPZ NONTRAINABLEZ PIXELSHUFFLEr9r9r9r:r r c@$eZdZdZdZdZdZdZdZdS)r rkconvZ convgroupZpixelunshuffleZmaxpoolZavgpoolN) r>r?r@rAZCONVZ CONVGROUPZPIXELUNSHUFFLEZMAXPOOLZAVGPOOLr9r9r9r:r sr c@eZdZdZdZdZdS)rzG See also: :py:class:`monai.data.utils.compute_importance_map` rCgaussianN)r>r?r@rArNZGAUSSIANr9r9r9r:rrc@rj)rzZ See also: https://pytorch.org/docs/stable/generated/torch.nn.functional.pad.html rCrJ replicatecircularN)r>r?r@rArNrPZ REPLICATEZCIRCULARr9r9r9r:rrnrc@rY)rzb See also: https://pytorch.org/docs/stable/generated/torch.nn.functional.grid_sample.html zerosborder reflectionN)r>r?r@rAZZEROSZBORDERZ REFLECTIONr9r9r9r:r rc@rj)rz See also: :py:class:`monai.metrics.rocauc.compute_roc_auc` or :py:class:`monai.metrics.average_precision.compute_average_precision` ZmacroweightedmicrononeN)r>r?r@rAZMACROZWEIGHTEDZMICRONONEr9r9r9r:r rc@re) rzF See also: :py:func:`monai.metrics.utils.do_metric_reduction` r|rGsumZ mean_batchZ sum_batchZ mean_channelZ sum_channelN) r>r?r@rAr}rOSUMZ MEAN_BATCHZ SUM_BATCHZ MEAN_CHANNELZ SUM_CHANNELr9r9r9r:rrirc@rY)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` r|rGrN)r>r?r@rAr}rOrr9r9r9r:r rc@rq)rzF See also: - :py:class:`monai.losses.dice.DiceCELoss` rGrN)r>r?r@rArOrr9r9r9r:r rc@rY)rzE See also: :py:class:`monai.losses.dice.GeneralizedDiceLoss` squaresimpleuniformN)r>r?r@rASQUARESIMPLEZUNIFORMr9r9r9r:rryrc@rq)rz@ See also: :py:class:`monai.networks.nets.HighResBlock` padZprojectN)r>r?r@rAZPADZPROJECTr9r9r9r:rrsrc@rY)rzD See also: :py:class:`monai.networks.layers.SkipConnection` cataddmulN)r>r?r@rAZCATADDMULr9r9r9r:r(ryrc@rq)rzI See also: :py:class:`monai.transforms.croppad.array.SpatialPad` rKendN)r>r?r@rArQENDr9r9r9r:r2rsrc@rq)rzL See also: :py:class:`monai.transforms.engines.evaluator.Evaluator` trainevalN)r>r?r@rAZTRAINEVALr9r9r9r:r;rsrc@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_SUFFIXr|r}tracingTRACINGZstatusesSTATUSESlazyLAZYN)r>r?r@rAr__annotations__rrrrrr}rrrr9r9r9r:rDs          rc@eZdZdZdZdS)rz4Enumerable status keys for the TraceKeys.STATUS flagZpending_during_applyN)r>r?r@rAZPENDING_DURING_APPLYr9r9r9r:rSsrc@ro)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. `METADATA` is some useful information during training or evaluation, like loss value, etc. imagelabelpredlossmetadataN) r>r?r@rAIMAGELABELZPREDZLOSSMETADATAr9r9r9r:rYs rc@ro)rzD A set of common keys for generative adversarial networks. realsfakesZlatentsZg_lossZd_lossN) r>r?r@rAREALSFAKESZLATENTSZGLOSSZDLOSSr9r9r9r:rksrc@sNeZdZdZedddZeddd d Zeddd dZeddddZd S)rz Post-fixes.prefix str | NonesuffixrreturncCs|dur|S|d|S)N_r9)rrr9r9r:_get_str{szPostFix._get_strNkeycC t|dS)NZ meta_dictrrrr9r9r:meta z PostFix.metacCr)NZorig_meta_dictrrr9r9r: orig_metarzPostFix.orig_metacCst|tjddS)Nr_)rrrrrr9r9r: transformsszPostFix.transforms)rrrrrrr4)rrrr) r>r?r@rA staticmethodrrrrr9r9r9r:rxs rc@rY)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@rAZTORCHZNUMPYZCUPYr9r9r9r:r rr c@rY)r!z~ Mode names for instantiating a class or calling a callable. See also: :py:func:`monai.utils.module.instantiate` defaultcallabledebugN)r>r?r@rADEFAULTCALLABLEDEBUGr9r9r9r:r!s r!c@rj)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@rANAME TIMESTAMPVERSION DESCRIPTIONr9r9r9r:rr~rc@s4eZdZdZdZdZdZdZdZdZ dZ d Z d Z d S) r"z Box mode names. ZxyxyZxyzxyzZxxyyZxxyyzzZxyxyzzZxywhZxyzwhdZccwhZcccwhdN) r>r?r@rAZXYXYZXYZXYZZXXYYZXXYYZZZXYXYZZZXYWHZXYZWHDZCCWHZCCCWHDr9r9r9r:r"sr"c@rj) ProbMapKeyszN The keys to be used for generating the probability maps from patches Z mask_location mask_sizeZ num_patchesrN)r>r?r@rALOCATIONSIZECOUNTrr9r9r9r:rrnrc@s@eZdZdZdZdZdZeddZeddZ ed d Z d S) r#zE The sorting method for the generated patches in `GridPatch` randomminmaxcCs |dSNrrxr9r9r:min_fnrzGridPatchSort.min_fncCs|d Srrrr9r9r:max_fnszGridPatchSort.max_fncCsL|tjkrtjS|tjkrtjS|tjkrtjStd|dddtD)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@rArrrrrrrr9r9r9r:r#s  r#c@rY) PatchKeyszV The keys to be used for metadata of patches extracted from any kind of image locationsizecountN)r>r?r@rArrrr9r9r9r:rryrc@s*eZdZdZejZejZejZdZdZ dS) WSIPatchKeyszW The keys to be used for metadata of patches extracted from whole slide images levelpathN) r>r?r@rArrrrZLEVELPATHr9r9r9r:rsrc@rT) r$zJ The keys to be used for extracting data from the fastMRI dataset ZkspacemaskfilenameZreconstruction_rssZ acquisitionrnormZ patient_idN) r>r?r@rAZKSPACEMASKZFILENAMEZRECONZ ACQUISITIONrZNORMZPIDr9r9r9r:r$sr$c@rq)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@rArrr9r9r9r:r%rr%c@r^) r&z' Typical keys for MetaObj.meta affineZoriginal_affineZ spatial_shapespaceZoriginal_channel_dimZsaved_toN) r>r?r@rAAFFINEZORIGINAL_AFFINEZ SPATIAL_SHAPESPACEZORIGINAL_CHANNEL_DIMZSAVED_TOr9r9r9r:r&sr&c@rq)r'z5 Enums for color order. Expand as necessary. RGBBGRN)r>r?r@rArrr9r9r9r:r')rsr'c@re) 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@rARANKZCURRENT_ITERATIONZ CURRENT_EPOCHZ TOTAL_EPOCHSZTOTAL_ITERATIONSZBEST_VALIDATION_EPOCHZBEST_VALIDATION_METRICr9r9r9r:r(2r(c@rT) 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@rAZSUMMARYZBY_CASEZBY_CASE_IMAGE_PATHZBY_CASE_LABEL_PATHZ IMAGE_STATSZFG_IMAGE_STATSZ LABEL_STATSZIMAGE_HISTOGRAMr9r9r9r:r)ArXr)c@re) r*zG Defaults keys for dataset statistical analysis image modules shapechannelsZ cropped_shapespacingZsizemmZ intensity histogramN) r>r?r@rASHAPEZCHANNELSZ CROPPED_SHAPESPACINGZSIZEMMZ INTENSITYZ HISTOGRAMr9r9r9r:r*Qrr*c@r^) r+zG Defaults keys for dataset statistical analysis label modules labelsZforeground_percentageZimage_intensityrrZ ncomponentsN) r>r?r@rAZ LABEL_UIDZ PIXEL_PCTZ IMAGE_INTSTrZ LABEL_SHAPEZ LABEL_NCOMPr9r9r9r:r+`sr+c@rq)r,z Modes for HoVerNet model: `FAST`: a faster implementation (than original) `ORIGINAL`: the original implementation FASTORIGINALN)r>r?r@rArrr9r9r9r:r,nr,c@rY)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@rAZHVZNPZNCr9r9r9r:r-ys r-c@re) r.aG 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@rArrZ PADDING_MODEZ INTERP_MODEDTYPEZ ALIGN_CORNERSZ RESAMPLE_MODEr9r9r9r:r.sr.c@rq)r/z 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@rAZDESCZREQUIREDr9r9r9r:r/rr/c@rq)r0aU 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@rArZREF_IDr9r9r9r:r0sr0c@rj)r1aF 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. identifierZ algo_instanceZ is_trainedZ best_metricN)r>r?r@rArZALGOZ IS_TRAINEDZSCOREr9r9r9r:r1s r1c@re) 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@rArZ REAL_LOGITSrZ FAKE_LOGITSZRECONSTRUCTION_LOSSZGENERATOR_LOSSZDISCRIMINATOR_LOSSr9r9r9r:r sr c@rq) OrderingTypeZ raster_scanZs_curverN)r>r?r@Z RASTER_SCANZS_CURVErr9r9r9r:r r c@rq)OrderingTransformationsZ rotate_90 transposerJN)r>r?r@Z ROTATE_90Z TRANSPOSErPr9r9r9r:r r r c@r)r2z< Config information of the PyTorch ignite package. z0.4.11N)r>r?r@rAOPT_IMPORT_VERSIONr9r9r9r:r2sr2) EventEnumz ignite.enginerbase)as_typec@rB)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@rAZRECONSTRUCTION_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:rrSr)D __future__rrenumrtypingrmonai.utils.modulerr__all__rrrrr r r r r rrrrrrrrrrrrrrrrrr r!rr"rr#rrr$r%r&r'r(r)r*r+r,r-r.r/r0r1r r r r2Z ignite.enginerrrrr9r9r9r:s~   0