class_docstr: Implements forming ISeg unary term from the following paper:
  
  Wang, Guotai, et al. "Interactive medical image segmentation using deep learning with image-specific fine tuning."
  IEEE transactions on medical imaging 37.7 (2018): 1562-1573. (preprint: https://arxiv.org/pdf/1710.04043.pdf)
  
  ISeg unary term is constructed using Equation 7 on page 4 of the above mentioned paper.
  This unary term along with a pairwise term (e.g. input image volume) form Equation 5 in the paper,
  which defines an energy to be minimised. Equation 5 can be optimised using an appropriate
  optimisation method (e.g. CRF, GraphCut etc), which is implemented here as an additional transform.
  
  Usage Example::
  
      Compose(
          [
              # unary term maker
              MakeISegUnaryd(
                  image="image",
                  logits="logits",
                  scribbles="label",
                  unary="unary",
                  scribbles_bg_label=2,
                  scribbles_fg_label=3,
              ),
              # optimiser
              ApplyCRFOptimisationd(unary="unary", pairwise="image", post_proc_label="pred"),
          ]
      )
class_docstr_tok: ["Implements","forming","ISeg","unary","term","from","the","following","paper",":","Wang",",","Guotai",",","et","al",".","``","Interactive","medical","image","segmentation","using","deep","learning","with","image-specific","fine","tuning",".","''","IEEE","transactions","on","medical","imaging","37.7","(","2018",")",":","1562-1573",".","(","preprint",":","https",":","\/\/arxiv.org\/pdf\/1710.04043.pdf",")","ISeg","unary","term","is","constructed","using","Equation","7","on","page","4","of","the","above","mentioned","paper",".","This","unary","term","along","with","a","pairwise","term","(","e.g",".","input","image","volume",")","form","Equation","5","in","the","paper",",","which","defines","an","energy","to","be","minimised",".","Equation","5","can","be","optimised","using","an","appropriate","optimisation","method","(","e.g",".","CRF",",","GraphCut","etc",")",",","which","is","implemented","here","as","an","additional","transform",".","Usage","Example",":",":","Compose","(","[","#","unary","term","maker","MakeISegUnaryd","(","image=","''","image","''",",","logits=","''","logits","''",",","scribbles=","''","label","''",",","unary=","''","unary","''",",","scribbles_bg_label=2",",","scribbles_fg_label=3",",",")",",","#","optimiser","ApplyCRFOptimisationd","(","unary=","''","unary","''",",","pairwise=","''","image","''",",","post_proc_label=","''","pred","''",")",",","]",")"]
code: def __init__(
      self,
      image: str,
      logits: str,
      scribbles: str,
      meta_key_postfix: str = "meta_dict",
      unary: str = "unary",
      scribbles_bg_label: int = 2,
      scribbles_fg_label: int = 3,
  ) -> None:
      super().__init__(meta_key_postfix)
      self.image = image
      self.logits = logits
      self.scribbles = scribbles
      self.unary = unary
      self.scribbles_bg_label = scribbles_bg_label
      self.scribbles_fg_label = scribbles_fg_label
  
imports: import logging
  from copy import deepcopy
  from typing import Optional
  import numpy
  import torch
  from monai.data import MetaTensor
  from monai.networks.blocks import CRF
  from monai.transforms import Transform
  from scipy.special import softmax
  from .utils import make_iseg_unary, make_likelihood_image_gmm, make_likelihood_image_histogram, maxflow
label_desc: Use image node_id 1 to create a new MakeISegUnaryd object from inherited base classes: InteractiveSegmentationTransform with example: obj = MakeISegUnaryd(image, logits, scribbles, meta_key_postfix, unary, scribbles_bg_label, scribbles_fg_label)