@@ -6437,7 +6437,7 @@ class ConditionalSetProperty(StructuralFeature): # DEPRECATED
64376437 ----------
64386438 feature: Feature
64396439 The child feature whose properties will be modified conditionally.
6440- condition: PropertyLike[str or bool] or None
6440+ condition: PropertyLike[str or bool] or None, optional
64416441 Either a boolean value (`True`, `False`) or the name of a boolean
64426442 property in the feature’s property dictionary. If the condition
64436443 evaluates to `True`, the specified properties are applied.
@@ -6447,7 +6447,7 @@ class ConditionalSetProperty(StructuralFeature): # DEPRECATED
64476447
64486448 Methods
64496449 -------
6450- `get(image: Any , condition: str or bool , **kwargs: Any ) -> Any`
6450+ `get(inputs , condition, **kwargs) -> Any`
64516451 Resolves the child feature, conditionally applying the specified
64526452 properties.
64536453
@@ -6456,42 +6456,50 @@ class ConditionalSetProperty(StructuralFeature): # DEPRECATED
64566456 >>> import deeptrack as dt
64576457
64586458 Define an image:
6459+
64596460 >>> import numpy as np
64606461 >>>
64616462 >>> image = np.ones((512, 512))
64626463
64636464 Define a `Gaussian` noise feature:
6465+
64646466 >>> gaussian_noise = dt.Gaussian(sigma=0)
64656467
64666468 --- Using a boolean condition ---
64676469 Apply `sigma=5` only if `condition=True`:
6470+
64686471 >>> conditional_feature = dt.ConditionalSetProperty(
64696472 ... gaussian_noise, sigma=5,
64706473 ... )
64716474
64726475 Resolve with condition met:
6476+
64736477 >>> noisy_image = conditional_feature(image, condition=True)
64746478 >>> round(noisy_image.std(), 1)
64756479 5.0
64766480
64776481 Resolve without condition:
6482+
64786483 >>> conditional_feature.update() # Essential to reset the property
64796484 >>> clean_image = conditional_feature(image, condition=False)
64806485 >>> round(clean_image.std(), 1)
64816486 0.0
64826487
64836488 --- Using a string-based condition ---
64846489 Define condition as a string:
6490+
64856491 >>> conditional_feature = dt.ConditionalSetProperty(
64866492 ... gaussian_noise, sigma=5, condition="is_noisy"
64876493 ... )
64886494
64896495 Resolve with condition met:
6496+
64906497 >>> noisy_image = conditional_feature(image, is_noisy=True)
64916498 >>> round(noisy_image.std(), 1)
64926499 5.0
64936500
64946501 Resolve without condition:
6502+
64956503 >>> conditional_feature.update()
64966504 >>> clean_image = conditional_feature(image, is_noisy=False)
64976505 >>> round(clean_image.std(), 1)
@@ -6511,7 +6519,7 @@ def __init__(
65116519 ----------
65126520 feature: Feature
65136521 The child feature to conditionally modify.
6514- condition: PropertyLike[str or bool] or None
6522+ condition: PropertyLike[str or bool] or None, optional
65156523 A boolean value or the name of a boolean property in the feature's
65166524 property dictionary. If the condition evaluates to `True`, the
65176525 specified properties are applied.
@@ -6536,16 +6544,16 @@ def __init__(
65366544
65376545 def get (
65386546 self : ConditionalSetProperty ,
6539- image : Any ,
6547+ inputs : Any ,
65406548 condition : str | bool ,
65416549 ** kwargs : Any ,
65426550 ) -> Any :
65436551 """Resolve the child, conditionally applying specified properties.
65446552
65456553 Parameters
65466554 ----------
6547- image : Any
6548- The input data or image to process.
6555+ inputs : Any
6556+ The input data to process.
65496557 condition: str or bool
65506558 A boolean value or the name of a boolean property in the feature's
65516559 property dictionary. If the condition evaluates to `True`, the
@@ -6570,7 +6578,7 @@ def get(
65706578 if _condition :
65716579 propagate_data_to_dependencies (self .feature , ** kwargs )
65726580
6573- return self .feature (image )
6581+ return self .feature (inputs )
65746582
65756583
65766584class ConditionalSetFeature (StructuralFeature ): # DEPRECATED
@@ -6623,23 +6631,27 @@ class ConditionalSetFeature(StructuralFeature): # DEPRECATED
66236631 >>> import deeptrack as dt
66246632
66256633 Define an image:
6634+
66266635 >>> import numpy as np
66276636 >>>
66286637 >>> image = np.ones((512, 512))
66296638
66306639 Define two `Gaussian` noise features:
6640+
66316641 >>> true_feature = dt.Gaussian(sigma=0)
66326642 >>> false_feature = dt.Gaussian(sigma=5)
66336643
66346644 --- Using a boolean condition ---
66356645 Combine the features into a conditional set feature.
66366646 If not provided explicitely, the condition is assumed to be True:
6647+
66376648 >>> conditional_feature = dt.ConditionalSetFeature(
66386649 ... on_true=true_feature,
66396650 ... on_false=false_feature,
66406651 ... )
66416652
66426653 Resolve based on the condition. If not specified, default is True:
6654+
66436655 >>> clean_image = conditional_feature(image)
66446656 >>> round(clean_image.std(), 1)
66456657 0.0
@@ -6654,13 +6666,15 @@ class ConditionalSetFeature(StructuralFeature): # DEPRECATED
66546666
66556667 --- Using a string-based condition ---
66566668 Define condition as a string:
6669+
66576670 >>> conditional_feature = dt.ConditionalSetFeature(
66586671 ... on_true=true_feature,
66596672 ... on_false=false_feature,
66606673 ... condition = "is_noisy",
66616674 ... )
66626675
66636676 Resolve based on the conditions:
6677+
66646678 >>> noisy_image = conditional_feature(image, is_noisy=False)
66656679 >>> round(noisy_image.std(), 1)
66666680 5.0
@@ -6716,7 +6730,7 @@ def __init__(
67166730
67176731 def get (
67186732 self : ConditionalSetFeature ,
6719- image : Any ,
6733+ inputs : Any ,
67206734 * ,
67216735 condition : str | bool ,
67226736 ** kwargs : Any ,
@@ -6725,8 +6739,8 @@ def get(
67256739
67266740 Parameters
67276741 ----------
6728- image : Any
6729- The input image to process.
6742+ inputs : Any
6743+ The inputs to process.
67306744 condition: str or bool
67316745 The name of the conditional property or a boolean value. If a
67326746 string is provided, it is looked up in `kwargs` to get the actual
@@ -6737,9 +6751,9 @@ def get(
67376751 Returns
67386752 -------
67396753 Any
6740- The processed image after resolving the appropriate feature. If
6754+ The processed data after resolving the appropriate feature. If
67416755 neither `on_true` nor `on_false` is provided for the corresponding
6742- condition, the input image is returned unchanged.
6756+ condition, the input is returned unchanged.
67436757
67446758 """
67456759
@@ -6750,10 +6764,10 @@ def get(
67506764
67516765 # Resolve the appropriate feature.
67526766 if _condition and self .on_true :
6753- return self .on_true (image )
6767+ return self .on_true (inputs )
67546768 if not _condition and self .on_false :
6755- return self .on_false (image )
6756- return image
6769+ return self .on_false (inputs )
6770+ return inputs
67576771
67586772
67596773class Lambda (Feature ):
0 commit comments