### Initialize Microscope and Get Image Shape Source: https://deeptrackai.github.io/DeepTrack2/2.0.1/api/deeptrack.optics.Microscope.html Demonstrates initializing a Microscope with a PointParticle sample and Brightfield objective, then retrieving the image shape. This is useful for basic simulation setup. ```python import deeptrack as dt ``` ```python scatterer = dt.PointParticle() optics = dt.Brightfield() microscope = dt.Microscope(sample=scatterer, objective=optics) image = microscope.get(None) print(image.shape) ``` -------------------------------- ### Get Modified Pupil Function with Gaussian Apodization Source: https://deeptrackai.github.io/DeepTrack2/2.0.1/api/deeptrack.aberrations.GaussianApodization.html This example shows how to use the `get` method of the `GaussianApodization` class to modify a pupil function. It visualizes the magnitude and phase of the resulting pupil, demonstrating the effect of the apodization. ```python import deeptrack as dt import numpy as np import matplotlib.pyplot as plt ``` ```python pupil = np.ones((128, 128)) rho = np.linspace(0, 1, 128).reshape(-1, 1) @ np.ones((1, 128)) x = np.linspace(-1, 1, 128) y = np.linspace(-1, 1, 128) X, Y = np.meshgrid(x, y) rho = np.sqrt(X**2 + Y**2) pupil[rho > 1] = 0 apodizer = dt.GaussianApodization(sigma=0.5, offset=(25, -3)) modified_pupil = apodizer.get( pupil, offset=(5, -3), sigma=0.5, rho=rho ) fig, axes = plt.subplots(1, 2, figsize=(12, 6)) axes[0].imshow(np.abs(modified_pupil), cmap="gray") axes[0].set_title("Modified Pupil Magnitude") axes[1].imshow(np.angle(modified_pupil), cmap="hsv") axes[1].set_title("Modified Pupil Phase") plt.show() modified_pupil.shape ``` -------------------------------- ### Apply IlluminationGradient to an image Source: https://deeptrackai.github.io/DeepTrack2/2.0.1/api/deeptrack.optics.IlluminationGradient.html Shows how to apply the initialized IlluminationGradient to a sample image. This involves getting the properties of the feature and passing them to the get method. The shape of the modified image is then printed. ```python >>> import deeptrack as dt ``` ```python >>> image=np.ones((100, 100)) >>> gradient_feature = dt.IlluminationGradient(gradient=(0.3, 0.1)) >>> properties_dict = gradient_feature.properties() >>> modified_image = gradient_feature.get(image, **properties_dict) >>> print(modified_image.shape) (100, 100) ``` -------------------------------- ### Initialize Microscope and Get Image with Upscale Source: https://deeptrackai.github.io/DeepTrack2/2.0.1/api/deeptrack.optics.Microscope.html Shows how to initialize a Microscope and simulate an image with an 'upscale' parameter. This is useful for generating higher-resolution images. ```python import deeptrack as dt ``` ```python scatterer = dt.PointParticle() optics = dt.Brightfield() microscope = dt.Microscope(sample=scatterer, objective=optics) image = microscope.get(None, upscale=(2, 2, 2)) print(image.shape) ``` -------------------------------- ### get Method Source: https://deeptrackai.github.io/DeepTrack2/2.0.1/api/deeptrack.features.OneOfDict.html The get method resolves the selected feature based on the provided key and applies it to the input image. If no key is specified during initialization, it defaults to randomly selecting a feature from the collection. ```APIDOC ## get _get(_image : Any_, _key : Any_, __ID : tuple[int, ...] = ()_, _** kwargs: dict[str, Any]_) → Any# Resolve the selected feature and apply it to the input. ### Parameters image: Any The input image or data to be processed. key: Any The key of the feature to apply from the dictionary. _ID: tuple[int, ...], optional A unique identifier for caching and parallel execution. **kwargs: dict of str to Any Additional parameters passed to the selected feature. ### Returns Any The output of the selected feature applied to the input. ``` -------------------------------- ### Example Usage Source: https://deeptrackai.github.io/DeepTrack2/2.0.1/api/deeptrack.features.OneOfDict.html Demonstrates how to define a OneOfDict feature with a collection of other features and how to apply it to an input image, both randomly and with a specific key. ```APIDOC ## Examples ```python >>> import deeptrack as dt >>> import numpy as np ``` Define a dictionary of features: >>> features_dict = { ... “add”: dt.Add(value=10), ... “multiply”: dt.Multiply(value=2), ... } >>> one_of_dict_feature = dt.OneOfDict(features_dict) Apply a randomly selected feature: >>> input_image = np.array([1, 2, 3]) >>> output_image = one_of_dict_feature(input_image) >>> print(output_image) Use a specific key to apply a predefined feature: >>> controlled_feature = dt.OneOfDict(features_dict, key=”add”) >>> output_image = controlled_feature(input_image) >>> print(output_image) # Adds 10 to each element. ``` -------------------------------- ### Sum Operation Example Source: https://deeptrackai.github.io/DeepTrack2/2.0.1/src/statistics.html Demonstrates how to use the Sum operation with 'distributed' set to True and False. ```APIDOC ## Sum Operation Example ### Description Demonstrates how to use the Sum operation with 'distributed' set to True and False. ### Usage ```python >>> import numpy as np >>> from deeptrack import statistics >>> input_values = [np.ones((2,)), np.zeros((2,))] >>> # Distributed set to True >>> sum_operation_distributed = statistics.Sum(axis=0, distributed=True) >>> sum_result_distributed = sum_operation_distributed(input_values) >>> print(sum_result_distributed) # Output: [2, 0] >>> # Distributed set to False >>> sum_operation_not_distributed = statistics.Sum(axis=0, distributed=False) >>> sum_result_not_distributed = sum_operation_not_distributed(input_values) >>> print(sum_result_not_distributed) # Output: [1, 1] ``` ``` -------------------------------- ### OneOf Example Usage Source: https://deeptrackai.github.io/DeepTrack2/2.0.1/api/deeptrack.features.OneOf.html Demonstrates how to create and use the OneOf feature, including random selection and selection by key. ```APIDOC >>> import deeptrack as dt >>> import numpy as np # Define multiple features: >>> feature_1 = dt.Add(value=10) >>> feature_2 = dt.Multiply(value=2) # Create a OneOf feature that randomly selects a transformation: >>> one_of_feature = dt.OneOf([feature_1, feature_2]) # Apply it to an input image: >>> input_image = np.array([1, 2, 3]) >>> output_image = one_of_feature(input_image) >>> print(output_image) # The output depends on the randomly selected feature. # Use a key to apply a specific feature: >>> controlled_feature = dt.OneOf([feature_1, feature_2], key=0) >>> output_image = controlled_feature(input_image) >>> print(output_image) # Adds 10 to each element. ``` -------------------------------- ### Define and Resolve Upscaled Pipeline Source: https://deeptrackai.github.io/DeepTrack2/2.0.1/api/deeptrack.features.Upscale.html This example demonstrates how to create an upscaled pipeline with a factor of 4, resolve both the original and upscaled pipelines, and visualize the results. It also shows that the output shapes are the same due to downscaling. ```python import deeptrack as dt import matplotlib.pyplot as plt # Define an optical pipeline and a spherical particle optics = dt.Fluorescence() particle = dt.Sphere() simple_pipeline = optics(particle) # Create an upscaled pipeline with a factor of 4 upscaled_pipeline = dt.Upscale(optics(particle), factor=4) # Resolve the pipelines image = simple_pipeline() upscaled_image = upscaled_pipeline() # Visualize the images plt.subplot(1, 2, 1) plt.imshow(image, cmap="gray") plt.title("Original Image") plt.subplot(1, 2, 2) plt.imshow(upscaled_image, cmap="gray") plt.title("Simulated at Higher Resolution") plt.show() # Compare the shapes (both are the same due to downscaling) print(image.shape) print(upscaled_image.shape) ``` -------------------------------- ### Mean Operation Example Source: https://deeptrackai.github.io/DeepTrack2/2.0.1/src/statistics.html Demonstrates how to use the Mean operation with 'distributed' set to True. ```APIDOC ## Mean Operation Example ### Description Demonstrates how to use the Mean operation with 'distributed' set to True. ### Usage ```python >>> import numpy as np >>> from deeptrack import statistics >>> input_values = [np.ones((2,)), np.zeros((2,))] >>> mean_operation = statistics.Mean(axis=0, distributed=True) >>> mean_result = mean_operation(input_values) >>> print(mean_result) # Output: [1, 0] ``` ``` -------------------------------- ### Define and Use a Lambda Feature Source: https://deeptrackai.github.io/DeepTrack2/2.0.1/api/deeptrack.features.Lambda.html This example demonstrates how to define a factory function that returns a scaling function and then use it to create and apply a Lambda feature for image scaling. ```python >>> import deeptrack as dt >>> import numpy as np Define a factory function that returns a scaling function: >>> def scale_function_factory(scale=2): ... def scale_function(image): ... return image * scale ... return scale_function Create a Lambda feature that scales images by a factor of 5: >>> lambda_feature = dt.Lambda(function=scale_function_factory, scale=5) Apply the feature to an image: >>> input_image = np.ones((5, 5)) >>> output_image = lambda_feature(input_image) >>> print(output_image) [[5. 5. 5. 5. 5.] > [5. 5. 5. 5. 5.] > [5. 5. 5. 5. 5.] > [5. 5. 5. 5. 5.] > [5. 5. 5. 5. 5.]] ``` -------------------------------- ### Initialize Fluorescence Optics and Simulate Imaging Source: https://deeptrackai.github.io/DeepTrack2/2.0.1/api/deeptrack.optics.Fluorescence.html Initializes a Fluorescence optics object with specified parameters and simulates imaging a given volume. The `get` method is used to generate the image, and the output shape is printed. ```python import deeptrack as dt import numpy as np ``` ```python optics = dt.Fluorescence( NA=1.4, wavelength=0.52e-6, magnification=60, ) volume = dt.Image(np.ones((128, 128, 10), dtype=complex)) limits = np.array([[0, 128], [0, 128], [0, 10]]) properties = optics.properties() filtered_properties = { k: v for k, v in properties.items() if k in {"padding", "output_region", "NA", "wavelength", "refractive_index_medium"} } image = optics.get(volume, limits, **filtered_properties) print(image.shape) ``` -------------------------------- ### get Source: https://deeptrackai.github.io/DeepTrack2/2.0.1/api/deeptrack.features.Upscale.html Simulates the pipeline at a higher resolution and returns the result at the original resolution. This method is the core of the Upscale feature's functionality. ```APIDOC ## Method: get ### Description Simulate the pipeline at a higher resolution and return result. ### Parameters - **image** (np.ndarray) - The input image to process. - **factor** (int or tuple[int, int, int]) - The factor by which to upscale the simulation. If a single integer is provided, it is applied uniformly across all axes. If a tuple of three integers is provided, each axis is scaled individually. - **kwargs** (dict of str to Any) - Additional keyword arguments passed to the feature. ### Returns - **np.ndarray** - The processed image at the original resolution. ### Raises - **ValueError** - If the input factor is not a valid integer or tuple of integers. ``` -------------------------------- ### Create Subtract Pipeline Source: https://deeptrackai.github.io/DeepTrack2/2.0.1/api/deeptrack.features.Subtract.html Demonstrates creating a pipeline using the Subtract feature with a predefined value. The pipeline can be resolved to get the final output. ```python import deeptrack as dt pipeline = dt.Value([1, 2, 3]) >> dt.Subtract(value=2) pipeline.resolve() ``` -------------------------------- ### IlluminationGradient.get Source: https://deeptrackai.github.io/DeepTrack2/2.0.1/_sources/api/deeptrack.optics.IlluminationGradient.rst.txt The `get` method is used to retrieve information or perform an action related to the IlluminationGradient. Specific parameters and return values depend on the internal implementation. ```APIDOC ## IlluminationGradient.get ### Description Retrieves information or performs an action related to the IlluminationGradient. ### Method `get` ### Parameters This method does not explicitly document parameters in the provided source. ### Request Example ```python illumination_gradient.get() ``` ### Response This method does not explicitly document response details in the provided source. ``` -------------------------------- ### get Method Source: https://deeptrackai.github.io/DeepTrack2/2.0.1/api/deeptrack.optics.Fluorescence.html Simulates the imaging process using a fluorescence microscope by convolving the illuminated volume with a pupil function. ```APIDOC ## get Method Simulates the imaging process using a fluorescence microscope. ### Description This method convolves the 3D illuminated volume with a pupil function to generate a 2D image projection. ### Parameters - **illuminated_volume** (array_like[complex]): The illuminated 3D volume to be imaged. - **limits** (array_like[int, int]): Boundaries of the illuminated volume in each dimension. - **kwargs** (Dict[str, Any]): Additional properties for the imaging process, such as: - ‘padding’: Padding to apply to the sample. - ‘output_region’: Specific region to extract from the image. ### Returns - **Image**: A 2D image object representing the fluorescence projection. ### Notes - Empty slices in the volume are skipped for performance optimization. - The pupil function incorporates defocus effects based on z-slice. ``` -------------------------------- ### Squeeze Usage Example Source: https://deeptrackai.github.io/DeepTrack2/2.0.1/api/deeptrack.features.Squeeze.html Demonstrates how to use the Squeeze feature with NumPy arrays, showing the effect of squeezing specific axes versus all singleton dimensions. ```APIDOC ## Examples ``` >>> import numpy as np >>> from deeptrack.features import Squeeze ``` Create an input array with extra dimensions: >>> input_image = np.array([[[[1], [2], [3]]]]) >>> print(input_image.shape) (1, 1, 3, 1) Create a Squeeze feature: >>> squeeze_feature = Squeeze(axis=0) >>> output_image = squeeze_feature(input_image) >>> print(output_image.shape) (1, 3, 1) Without specifying an axis: >>> squeeze_feature = Squeeze() >>> output_image = squeeze_feature(input_image) >>> print(output_image.shape) (3,) ``` -------------------------------- ### Initialize and Use SequentialProperty Source: https://deeptrackai.github.io/DeepTrack2/2.0.1/api/deeptrack.properties.SequentialProperty.html Demonstrates initializing a SequentialProperty, setting its length, defining a current value function, and iterating through steps to store and print values. ```python import deeptrack as dt import numpy as np ``` ```python seq_prop = dt.SequentialProperty() seq_prop.sequence_length.store(5) seq_prop.current = lambda _ID=(): seq_prop.sequence_step() + 1 for step in range(seq_prop.sequence_length()): seq_prop.sequence_step.store(step) current_value = seq_prop.current() seq_prop.store(current_value) print(seq_prop.data[()].current_value()) ``` -------------------------------- ### CropTight.get() Source: https://deeptrackai.github.io/DeepTrack2/2.0.1/api/deeptrack.augmentations.CropTight.html The `get` method performs the CropTight augmentation. It removes indices from the start and end of a 3D array where all values are below the specified epsilon threshold. ```APIDOC ## CropTight.get() ### Description Abstract method which performs the CropTight augmentation. CropTight removes indices from the start and end of the array, where all values are below eps. ### Method `get` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Parameters - **_image** (Image | np.ndarray) - The input image or numpy array to augment. - **_eps** (PropertyLike[float]) - The threshold for considering a pixel to be empty. Defaults to 1e-10. - **_kwargs** - Additional keyword arguments. ### Request Example ```python # Example usage (assuming image and CropTight instance are defined) crop_tight_instance.get(image=my_image, eps=1e-5) ``` ### Response #### Success Response (Image) - **Image** - The augmented image with empty space cropped. ``` -------------------------------- ### Instantiate and Use Rescale Source: https://deeptrackai.github.io/DeepTrack2/2.0.1/api/deeptrack.holography.Rescale.html Demonstrates how to instantiate the Rescale class with a scaling factor and apply it to a random optical field. ```python import deeptrack as dt import numpy as np field = np.random.rand(128, 128, 2) rescaled_field = dt.holography.Rescale(0.5)(field) ``` -------------------------------- ### Define and Configure Pipeline Source: https://deeptrackai.github.io/DeepTrack2/2.0.1/api/deeptrack.features.SampleToMasks.html Sets up a simulation pipeline including optics, particles, and a SampleToMasks feature for mask generation. This example demonstrates defining particle count, optics, individual particles, and then combining them into simulation and mask generation pipelines. ```python # Define number of particles n_particles = 12 # Define optics and particles optics = dt.Fluorescence(output_region=(0, 0, 64, 64)) particle = dt.PointParticle( position=lambda: np.random.uniform(5, 55, size=2) ) particles = particle ^ n_particles # Define pipelines sim_im_pip = optics(particles) sim_mask_pip = particles >> dt.SampleToMasks( lambda: lambda particles: particles > 0, output_region=optics.output_region, merge_method="or" ) pipeline = sim_im_pip & sim_mask_pip pipeline.store_properties() ``` -------------------------------- ### Power Class Initialization and Usage Source: https://deeptrackai.github.io/DeepTrack2/2.0.1/api/deeptrack.features.Power.html Demonstrates how to initialize and use the Power feature, including its direct instantiation and integration into pipelines. It also shows equivalent syntax using operator overloading. ```APIDOC ## Class: Power ### Description Raises the input to a power. This feature performs element-wise power (**) of the input. ### Parameters - **value** (float | Callable[[...], float], optional): The value to take the power of the input. Defaults to 0. - **kwargs** (dict[str, Any]): Additional keyword arguments passed to the parent constructor. ### Examples ```python >>> import deeptrack as dt # Using Power in a pipeline >>> pipeline = dt.Value([1, 2, 3]) >> dt.Power(value=3) >>> pipeline.resolve() [1, 8, 27] # Equivalent syntax using operator overloading >>> pipeline = dt.Value([1, 2, 3]) ** 3 # Explicit instantiation and application >>> input_value = dt.Value([1, 2, 3]) >>> pow_feature = dt.Power(value=3) >>> pipeline = pow_feature(input_value) ``` ``` -------------------------------- ### ObliqueAstigmatism Example Source: https://deeptrackai.github.io/DeepTrack2/2.0.1/api/deeptrack.aberrations.ObliqueAstigmatism.html Example of applying an ObliqueAstigmatism Zernike phase aberration to a simulated fluorescence image. ```APIDOC Example: Apply an ObliqueAstigmatism Zernike phase aberration (n=2, m=-2) to a simulated fluorescence image: ```python >>> import deeptrack as dt >>> particle = dt.PointParticle(z=4 * dt.units.micrometer) >>> oblique_astigmatism_aberration = dt.ObliqueAstigmatism(coefficient=0.2) >>> aberrated_optics = dt.Fluorescence( >>> pupil=oblique_astigmatism_aberration, >>> ) >>> aberrated_particle = aberrated_optics(particle) >>> aberrated_particle.plot(cmap="gray") ``` ``` -------------------------------- ### Create and Use a Source Source: https://deeptrackai.github.io/DeepTrack2/2.0.1/api/deeptrack.sources.base.Source.html Instantiate a Source with multiple data arrays and create features from its attributes. Demonstrates how to access and combine features from the source. ```python source = Source(a=[1, 2], b=[3, 4]) feature_a = dt.Value(source.a) feature_b = dt.Value(source.b) sum_feature = feature_a + feature_b sum_feature(source[0]) # returns 4 sum_feature(source[1]) # returns 6 ``` -------------------------------- ### Call a list of callbacks with Source Source: https://deeptrackai.github.io/DeepTrack2/2.0.1/src/sources.base.html Demonstrates how to define a Source with data and attach a callback function that is executed when an item is accessed and called. The callback receives the SourceItem. ```python >>> from deeptrack.sources import Source ``` ```python >>> source = Source(a=[1, 2], b=[3, 4]) >>> @source.on_activate >>> def callback(item): >>> print(item) >>> source[0]() ``` ```python >>> SourceItem({'a': 1, 'b': 3}). ``` -------------------------------- ### Create and Image a Stratified Mie Sphere Source: https://deeptrackai.github.io/DeepTrack2/2.0.1/src/scatterers.html Demonstrates creating a MieStratifiedSphere with specified radii and refractive indices, then imaging it using a Brightfield optics setup. The output is an array of complex numbers, and the absolute value is plotted. ```python import numpy as np ``` ```python from deeptrack.optics import Brightfield from deeptrack.scatterers import MieStratifiedSphere from deeptrack.elementwise import Abs ``` ```python optics = Brightfield( NA=0.7, wavelength=680e-9, resolution=1e-6, magnification=5, output_region=(0, 0, 64, 64), return_field=True, upscale=4, ) ``` ```python scatterer = MieStratifiedSphere( radius=np.array([0.5e-6, 3e-6]), refractive_index=[1.45 + 0.1j, 1.52], position_unit="pixel", position=(128, 128), aperature_angle=0.1, ) ``` ```python imaged_scatterer = optics(scatterer) # Creates an array of complex numbers. abs_imaged_scatterer = Abs(imaged_scatterer) abs_imaged_scatterer.plot() ``` -------------------------------- ### Create and Image an Ellipse Scatterer Source: https://deeptrackai.github.io/DeepTrack2/2.0.1/src/scatterers.html Demonstrates creating an Ellipse scatterer with specified intensity, position, radius, and rotation, then imaging it using a Fluorescence optics setup. ```python import numpy as np ``` ```python from deeptrack.optics import Fluorescence from deeptrack.scatterers import Ellipse ``` ```python optics = Fluorescence( NA=0.7, wavelength=680e-9, resolution=1e-6, magnification=10, output_region=(0, 0, 64, 64), ) ``` ```python scatterer = Ellipse( intensity=100, position_unit="pixel", position=(32, 32), radius=(1e-6, 0.5e-6), rotation=np.pi / 4, upsample=4, ) ``` ```python imaged_scatterer = optics(scatterer) imaged_scatterer.plot(cmap="gray") ``` -------------------------------- ### get Source: https://deeptrackai.github.io/DeepTrack2/2.0.1/api/deeptrack.features.Feature.html Transform an image [abstract method]. ```APIDOC ## get ### Description Transform an image [abstract method]. ### Method get ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **image** - The input image to transform. - **kwargs** (Any) - Additional keyword arguments. ``` -------------------------------- ### Image Initialization and Basic Usage Source: https://deeptrackai.github.io/DeepTrack2/2.0.1/api/deeptrack.image.Image.html Demonstrates how to create an Image instance from a NumPy array and access its basic attributes and methods. ```APIDOC ## Image Initialization and Basic Usage ### Description Create an Image instance from a NumPy array and access its attributes and methods. ### Method Signature `Image(array)` ### Parameters - **array** (numpy.ndarray): The input NumPy array representing the image. ### Examples ```python >>> import numpy as np >>> from deeptrack.image import Image >>> img = Image(np.array([[1, 2], [3, 4]])) >>> print(img) Image(array([[1, 2], [3, 4]])) >>> print(img.shape) (2, 2) >>> print(img.sum()) 10 ``` ``` -------------------------------- ### Merge.get Source: https://deeptrackai.github.io/DeepTrack2/2.0.1/_sources/api/deeptrack.features.Merge.rst.txt The get method of the Merge class. ```APIDOC ## Merge.get ### Description This method is part of the Merge class. ### Method get ### Parameters This method does not appear to have any documented parameters in the provided source. ### Request Example ```python # Example usage of the get method would go here if documented ``` ### Response This method's return value and response structure are not explicitly documented in the provided source. ``` -------------------------------- ### ConditionalSetFeature Usage Examples Source: https://deeptrackai.github.io/DeepTrack2/2.0.1/api/deeptrack.features.ConditionalSetFeature.html Demonstrates how to use ConditionalSetFeature with both boolean and string-based conditions. It shows how to define features, combine them using ConditionalSetFeature, and resolve them with different conditions. ```python >>> import deeptrack as dt >>> import numpy as np ``` ```python >>> true_feature = dt.Gaussian(sigma=0) >>> false_feature = dt.Gaussian(sigma=5) ``` ```python >>> conditional_feature = dt.ConditionalSetFeature( ... on_true=true_feature, ... on_false=false_feature, ... ) ``` ```python >>> image = np.ones((512, 512)) ``` ```python >>> clean_image = conditional_feature(image) # If not specified, default is True >>> print(clean_image.std()) # Should be 0 0.0 ``` ```python >>> noisy_image = conditional_feature(image, condition=False) >>> print(noisy_image.std()) # Should be ~5 4.987707046984823 ``` ```python >>> clean_image = conditional_feature(image, condition=True) >>> print(clean_image.std()) # Should be 0 0.0 ``` ```python >>> conditional_feature = dt.ConditionalSetFeature( ... on_true=true_feature, ... on_false=false_feature, ... condition = "is_noisy", ... ) ``` ```python >>> noisy_image = conditional_feature(image, is_noisy=False) >>> print(noisy_image.std()) # Should be ~5 5.006310381139811 ``` ```python >>> clean_image = conditional_feature(image, is_noisy=True) >>> print(clean_image.std()) # Should be 0 0.0 ``` -------------------------------- ### Lambda.get Source: https://deeptrackai.github.io/DeepTrack2/2.0.1/_sources/api/deeptrack.features.Lambda.rst.txt The get method of the Lambda class. ```APIDOC ## Lambda.get ### Description This method is part of the Lambda class. ### Method get ### Parameters This method does not have any explicitly documented parameters in the source. ### Request Example ```python # Example usage of Lambda.get (specifics depend on class implementation) lambda_instance.get() ``` ### Response This method's return type and structure are not explicitly documented in the source. ``` -------------------------------- ### Creating a Microscope Instance with Optics Source: https://deeptrackai.github.io/DeepTrack2/2.0.1/api/deeptrack.optics.Optics.html Demonstrates how to create a Microscope instance by first defining a scatterer and an Optics object, then calling the optics object with the scatterer. This is useful for setting up a simulation environment. ```python >>> import deeptrack as dt ``` ```python >>> scatterer = dt.PointParticle() >>> optics = dt.Optics() >>> microscope = optics(scatterer) >>> print(isinstance(microscope, dt.Microscope)) True ``` -------------------------------- ### Reuse.get Source: https://deeptrackai.github.io/DeepTrack2/2.0.1/_sources/api/deeptrack.augmentations.Reuse.rst.txt The get method of the Reuse augmentation. ```APIDOC ## Reuse.get ### Description This method is part of the Reuse augmentation class. ### Method get ### Parameters This method does not appear to have any parameters documented in the provided source. ### Request Example ```python # Example usage would depend on the context of the Reuse class ``` ### Response This method's return value is not explicitly documented in the provided source. ``` -------------------------------- ### action Source: https://deeptrackai.github.io/DeepTrack2/2.0.1/api/deeptrack.backend.core.DeepTrackNode.html Gets or sets the computation function for the node. ```APIDOC ## action ### Description Gets or sets the computation function (action) for the DeepTrackNode. This function is responsible for computing the node's value. ### Method `property` ### Usage ```python # Get the action current_action = node.action # Set a new action def new_computation(data): return data * 2 node.action = new_computation ``` ``` -------------------------------- ### Create a Fluorescence Instance Source: https://deeptrackai.github.io/DeepTrack2/2.0.1/api/deeptrack.optics.Fluorescence.html Instantiate the Fluorescence class with specific optical parameters like NA, wavelength, and magnification. This sets up the simulation for fluorescence imaging. ```python import deeptrack as dt optics = dt.Fluorescence( NA=1.4, wavelength=0.52e-6, magnification=60, ) print(optics.NA()) ``` -------------------------------- ### FourierTransformTransformation.get Source: https://deeptrackai.github.io/DeepTrack2/2.0.1/_sources/api/deeptrack.holography.FourierTransformTransformation.rst.txt The `get` method is available for the FourierTransformTransformation class. ```APIDOC ## FourierTransformTransformation.get ### Description This method is part of the FourierTransformTransformation class. ### Method get ### Parameters This method does not have any explicitly documented parameters in the source. ### Request Example ```json { "example": "No request example available" } ``` ### Response #### Success Response (200) - **field1** (type) - Description ### Response Example ```json { "example": "No response example available" } ``` ``` -------------------------------- ### Initialize and Use Brightfield Optics Source: https://deeptrackai.github.io/DeepTrack2/2.0.1/api/deeptrack.optics.Brightfield.html Demonstrates how to initialize the Brightfield optics object with specific parameters and then use the `get` method to simulate imaging a volume. It shows how to extract relevant properties for the imaging process and prints the shape of the resulting image. ```python import deeptrack as dt import numpy as np ``` ```python optics = dt.Brightfield( NA=1.4, wavelength=0.52e-6, magnification=60, ) volume = dt.Image(np.ones((128, 128, 10), dtype=complex)) limits = np.array([[0, 128], [0, 128], [0, 10]]) fields = np.array([np.ones((162, 162), dtype=complex)]) properties = optics.properties() filtered_properties = { k: v for k, v in properties.items() if k in {'padding', 'output_region', 'NA', 'wavelength', 'refractive_index_medium'} } image = optics.get(volume, limits, fields, **filtered_properties) print(image.shape) ``` -------------------------------- ### Squeeze.get Source: https://deeptrackai.github.io/DeepTrack2/2.0.1/_sources/api/deeptrack.features.Squeeze.rst.txt The `get` method is available for the Squeeze class. ```APIDOC ## Squeeze.get ### Description This method is part of the Squeeze class. ### Method get ### Parameters This method does not have any explicitly documented parameters in the source. ### Request Example ```python # Example usage would go here if available in the source ``` ### Response This method does not have an explicitly documented response in the source. ``` -------------------------------- ### Fluorescence Class Initialization Source: https://deeptrackai.github.io/DeepTrack2/2.0.1/api/deeptrack.optics.Fluorescence.html Demonstrates how to create an instance of the Fluorescence class with specified optical parameters. ```APIDOC ## Fluorescence Class Optical device for fluorescent imaging. ### Parameters - **NA** (float | Callable[[...], float]): Numerical aperture of the optical system. Defaults to 0.7. - **wavelength** (float | Callable[[...], float]): Emission wavelength of the fluorescent light (in meters). Defaults to 6.6e-07. - **magnification** (float | Callable[[...], float]): Magnification of the optical system. Defaults to 10. - **resolution** (array_like[float (, float, float)] | Callable[[...], float | Tuple[float, ...] | List[float] | ndarray]): Pixel spacing in the camera. Optionally includes the z-direction. Defaults to 1e-06. - **refractive_index_medium** (float | Callable[[...], float]): Refractive index of the imaging medium. Defaults to 1.33. - **padding** (Tuple[int, ...] | List[int] | ndarray | Callable[[...], Tuple[int, ...] | List[int] | ndarray]): Padding applied to the sample volume to reduce edge effects. Defaults to (10, 10, 10, 10). - **output_region** (Tuple[int, ...] | List[int] | ndarray | Callable[[...], Tuple[int, ...] | List[int] | ndarray]): Region of the output image to extract (x, y, width, height). If None, returns the full image. - **pupil** (Feature | None): A feature set defining the pupil function at focus. The input is the unaberrated pupil. - **illumination** (Feature | None): A feature set defining the illumination source. - **upscale** (int): Scaling factor for the resolution of the optical system. Defaults to 1. - **kwargs**: Additional keyword arguments. ### Example Usage ```python import deeptrack as dt optics = dt.Fluorescence( NA=1.4, wavelength=0.52e-6, magnification=60, ) print(optics.NA()) ``` ``` -------------------------------- ### Branch.get Method Source: https://deeptrackai.github.io/DeepTrack2/2.0.1/_sources/api/deeptrack.features.Branch.rst.txt Documentation for the `get` method of the Branch class. ```APIDOC ## Branch.get ### Description This method is part of the Branch class. ### Method get ### Parameters This method does not appear to have any documented parameters in the provided source. ### Request Example ```python # Example usage of the get method # branch_instance.get(...) ``` ### Response This method's return value is not explicitly documented in the provided source. ``` -------------------------------- ### Optics Class Initialization Source: https://deeptrackai.github.io/DeepTrack2/2.0.1/api/deeptrack.optics.Optics.html Demonstrates how to initialize the Optics class with custom parameters. ```APIDOC ## Class: Optics ### Description Abstract base optics class. Provides structure and methods common for most optical devices. Subclasses implement specific optical systems by defining imaging properties and behaviors. The Optics class is used to define the core imaging properties of an optical system, such as resolution, magnification, numerical aperture (NA), and wavelength. ### Parameters * **NA** (float, optional): Numerical aperture (NA) of the limiting aperture, by default 0.7. * **wavelength** (float, optional): Wavelength of the scattered light in meters, by default 0.66e-6. * **magnification** (float, optional): Magnification of the optical system, by default 10. * **resolution** (float or array_like[float], optional): Distance between pixels in the camera (meters). A third value can define the resolution in the z-direction, by default 1e-6. * **refractive_index_medium** (float, optional): Refractive index of the medium, by default 1.33. * **padding** (array_like[int, int, int, int], optional): Padding applied to the sample volume to avoid edge effects, by default (10, 10, 10, 10). * **output_region** (array_like[int, int, int, int], optional): Region of the image to output (x, y, width, height). If None, the entire image is returned, by default (0, 0, 128, 128). * **pupil** (Feature, optional): Feature-set resolving the pupil function at focus. By default, no pupil is applied. * **illumination** (Feature, optional): Feature-set resolving the illumination source. By default, no specific illumination is applied. * **upscale** (int, optional): Scaling factor for the resolution of the optical system, by default 1. * **kwargs**: Dict[str, Any]: Additional parameters passed to the base Feature class. ### Example ```python import deeptrack as dt optics = dt.Optics(NA=0.8, wavelength=0.55e-6, magnification=20) print(optics.NA()) ``` ``` -------------------------------- ### PropertyDict Initialization and Usage Source: https://deeptrackai.github.io/DeepTrack2/2.0.1/api/deeptrack.properties.PropertyDict.html Demonstrates how to initialize a PropertyDict with constant, dependent, and random properties, and how to access their values. ```APIDOC ## Class: PropertyDict ### Description A specialized dictionary where values are instances of Property. It provides additional utility functions to update, sample, reset, and retrieve properties. This is particularly useful for managing feature-specific properties in a structured manner. ### Parameters * **kwargs** (Dict[str, Any]) - Key-value pairs used to initialize the dictionary, where values are either directly used to create Property instances or are dependent on other Property values. ### Methods * **__init__(**kwargs: Dict[str, Any]**)** - Initializes the PropertyDict, resolving Property dependencies. * **__getitem__(key: str) -> Any** - Retrieves a value from the dictionary using a key. ### Example Initialize a PropertyDict with different types of properties: ```python import deeptrack as dt import numpy as np prop_dict = dt.PropertyDict( constant=42, dependent=lambda constant: constant + 10, random=lambda: np.random.rand(), ) ``` Access the properties: ```python print(prop_dict["constant"]()) # Returns 42 print(prop_dict["dependent"]()) # Returns 52 print(prop_dict["random"]()) ``` ``` -------------------------------- ### NormalizeMinMax.get Source: https://deeptrackai.github.io/DeepTrack2/2.0.1/_sources/api/deeptrack.math.NormalizeMinMax.rst.txt The `get` method is used to apply the min-max normalization to the data. ```APIDOC ## NormalizeMinMax.get ### Description Applies min-max normalization to the data. ### Method get ### Parameters This method does not explicitly list parameters in the source documentation. ### Request Example ```python # Example usage (assuming instance of NormalizeMinMax is created) # normalize_min_max = NormalizeMinMax() # normalized_data = normalize_min_max.get(data) ``` ### Response Returns the normalized data. ``` -------------------------------- ### Unsqueeze.get Source: https://deeptrackai.github.io/DeepTrack2/2.0.1/_sources/api/deeptrack.features.Unsqueeze.rst.txt The get method is used to retrieve the result of the Unsqueeze operation. ```APIDOC ## Unsqueeze.get ### Description Retrieves the result of the Unsqueeze operation. ### Method get ### Parameters This method does not explicitly list parameters in the documentation. ### Returns The result of the Unsqueeze operation, typically a tensor with an added dimension. ``` -------------------------------- ### ExpandDims.get Source: https://deeptrackai.github.io/DeepTrack2/2.0.1/_sources/api/deeptrack.features.ExpandDims.rst.txt The get method of ExpandDims is used to retrieve the expanded dimensions. ```APIDOC ## ExpandDims.get ### Description Retrieves the expanded dimensions of the ExpandDims object. ### Method get ### Parameters This method does not take any explicit parameters. ### Returns - The expanded dimensions of the object. ``` -------------------------------- ### Initialize and Use DummyFeature Source: https://deeptrackai.github.io/DeepTrack2/2.0.1/api/deeptrack.features.DummyFeature.html Demonstrates how to create a DummyFeature, pass an image through it, and verify that the output is identical to the input. This feature is useful for testing or when properties need to be associated with a feature without data transformation. ```python import deeptrack as dt import numpy as np dummy_image = np.ones((60, 80)) dummy_feature = dt.DummyFeature(value=42) output_image = dummy_feature(dummy_image) print(np.array_equal(dummy_image, output_image)) ``` -------------------------------- ### AsType.get Source: https://deeptrackai.github.io/DeepTrack2/2.0.1/_sources/api/deeptrack.features.AsType.rst.txt The get method is used to retrieve the value of the AsType object. ```APIDOC ## AsType.get ### Description Retrieves the value of the AsType object. ### Method ```python AsType.get() ``` ### Returns The value of the AsType object. ``` -------------------------------- ### Create Pipeline with Stack Source: https://deeptrackai.github.io/DeepTrack2/2.0.1/api/deeptrack.features.Stack.html Demonstrates creating a pipeline using the Stack feature to combine a Value feature with a list. ```python pipeline = dt.Value([1, 2, 3]) >> dt.Stack(value=[4, 5]) print(pipeline.resolve()) ``` -------------------------------- ### get_active_scale() Source: https://deeptrackai.github.io/DeepTrack2/2.0.1/api/deeptrack.backend.units.get_active_scale.html Gets the active scale difference between optical units and simulation units. ```APIDOC ## get_active_scale() ### Description Gets the active scale difference between optical units and simulation units. ### Method `deeptrack.backend.units.get_active_scale()` ### Parameters This function does not take any parameters. ### Response This function returns the active scale difference. The exact type and format of the return value are not specified in the source. ### Response Example (No example provided in the source) ``` -------------------------------- ### Pad.get() Method Source: https://deeptrackai.github.io/DeepTrack2/2.0.1/api/deeptrack.augmentations.Pad.html The get method performs the actual padding operation on an image. ```APIDOC ## Method: Pad.get() ### Description Abstract method which performs the Pad augmentation. ### Parameters * **image** (Image | np.ndarray) - The input image to be padded. * **px** (PropertyLike[int]) - The amount of padding to apply. This should be a tuple or list of integers specifying padding for each axis. * **kwargs** - Additional keyword arguments. ### Returns * **Image** - The padded image. ``` -------------------------------- ### Create and Use a Property Dictionary Source: https://deeptrackai.github.io/DeepTrack2/2.0.1/src/properties.html Illustrates the creation of a dictionary of properties, including constant, dependent, and random properties, and how to access their values. ```python import numpy as np prop_dict = dt.PropertyDict( constant=42, dependent=lambda constant: constant + 10, random=lambda dependent: np.random.rand() + dependent, ) print(prop_dict["constant"]()) # Returns 42 print(prop_dict["dependent"]()) # Returns 52 print(prop_dict["random"]()) ``` -------------------------------- ### ComplexGaussian.get Source: https://deeptrackai.github.io/DeepTrack2/2.0.1/_sources/api/deeptrack.noises.ComplexGaussian.rst.txt The `get` method is part of the ComplexGaussian class, used for noise generation. ```APIDOC ## ComplexGaussian.get ### Description This method is part of the ComplexGaussian class and is used for noise generation. ### Method get ### Parameters This method does not explicitly list parameters in the provided documentation. ### Returns This method's return value is not explicitly documented in the provided source. ``` -------------------------------- ### FloorDivide Initialization and Usage Source: https://deeptrackai.github.io/DeepTrack2/2.0.1/api/deeptrack.features.FloorDivide.html Demonstrates how to initialize and use the FloorDivide feature, including its equivalent operator overloading. ```APIDOC ## Class: deeptrack.features.FloorDivide ### Description Performs element-wise floor division (//) of the input with a specified value. Floor division produces an integer result when both operands are integers, but truncates towards negative infinity when operands are floating-point numbers. ### Parameters * **value** (float | Callable[[...], float], optional): The value to floor-divide the input. Defaults to 0. * **kwargs**: Any additional keyword arguments passed to the parent constructor. ### Examples ```python >>> import deeptrack as dt # Using FloorDivide feature directly >>> pipeline = dt.Value([-3, 3, 6]) >> dt.FloorDivide(value=5) >>> pipeline.resolve() [0.2 0.4 0.6] # Equivalent usage with operator overloading >>> pipeline = dt.Value([-3, 3, 6]) // 5 # Note: The order of operands matters for floor division >>> pipeline = 5 // dt.Value([-3, 3, 6]) # Different result. # Explicitly creating and applying the feature >>> input_value = dt.Value([-3, 3, 6]) >>> floordiv_feature = dt.FloorDivide(value=5) >>> pipeline = floordiv_feature(input_value) ``` ``` -------------------------------- ### ISCAT Class Initialization Source: https://deeptrackai.github.io/DeepTrack2/2.0.1/api/deeptrack.optics.ISCAT.html Demonstrates how to initialize an ISCAT object with essential optical parameters. ```APIDOC ## ISCAT Class ### Description Images coherently illuminated samples using Interferometric Scattering (ISCAT) microscopy. This class models ISCAT by creating a discretized volume where each pixel represents the effective refractive index of the sample. Light is propagated through the sample iteratively, first in the Fourier space and then corrected in the real space for refractive index. ### Parameters - **illumination_angle** (float, optional): Angle of illumination relative to the optical axis, in radians. Default is π radians. - **amp_factor** (float, optional): Amplitude factor of the illuminating field relative to the reference field. Default is 1. - **NA** (float): Numerical aperture (NA) of the limiting aperture. - **wavelength** (float): Wavelength of the scattered light, in meters. - **magnification** (float): Magnification factor of the optical system. - **resolution** (array_like of float): Pixel spacing in the camera. Optionally includes a third value for z-direction resolution. - **refractive_index_medium** (float): Refractive index of the medium surrounding the sample. - **padding** (array_like of int): Padding for the sample volume to minimize edge effects. Format: (left, right, top, bottom). - **output_region** (array_like of int): Region of the image to output as (x, y, width, height). If None (default), the entire image is returned. - **pupil** (Feature): Feature-set defining the pupil function at focus. The feature-set takes an unaberrated pupil as input. ### Example ```python import deeptrack as dt iscat = dt.ISCAT(NA=1.4, wavelength=0.532e-6, magnification=60) print(iscat.illumination_angle()) ``` ``` -------------------------------- ### Permute.get Source: https://deeptrackai.github.io/DeepTrack2/2.0.1/_sources/api/deeptrack.features.Permute.rst.txt The get method of the Permute class is used to retrieve permuted features. ```APIDOC ## Permute.get ### Description Retrieves permuted features. ### Method get ### Parameters This method does not explicitly document any parameters. ### Request Example ```python permute_instance.get() ``` ### Response This method does not explicitly document its response structure. ``` -------------------------------- ### Handle Sequential Properties Source: https://deeptrackai.github.io/DeepTrack2/2.0.1/src/properties.html Demonstrates how to create and use a SequentialProperty, setting its sequence length and storing values across steps. ```python seq_prop = dt.SequentialProperty() seq_prop.sequence_length.store(5) seq_prop.current = lambda _ID=(): seq_prop.sequence_step() + 1 for step in range(seq_prop.sequence_length()): seq_prop.sequence_step.store(step) seq_prop.store(seq_prop.current()) print(seq_prop.data[()].current_value()) ``` -------------------------------- ### DummyFeature.get Source: https://deeptrackai.github.io/DeepTrack2/2.0.1/_sources/api/deeptrack.features.DummyFeature.rst.txt The get method of DummyFeature. Its specific functionality is not detailed in the provided source. ```APIDOC ## DummyFeature.get ### Description This method is part of the DummyFeature class. Its purpose and parameters are not explicitly detailed in the provided documentation. ### Method get ### Parameters (No parameters are explicitly documented for this method in the source.) ### Request Example (No request example is available in the source.) ### Response (No response details are available in the source.) ``` -------------------------------- ### Creating and Using BindUpdate Source: https://deeptrackai.github.io/DeepTrack2/2.0.1/api/deeptrack.features.BindUpdate.html Demonstrates how to create a Gaussian feature and then use BindUpdate to dynamically modify its behavior with specific arguments. The example shows how to resolve the bound feature with an input image and prints the mean and standard deviation of the output. ```python import deeptrack as dt import numpy as np # Start by creating a Gaussian feature: gaussian_noise = dt.Gaussian() # Dynamically modify the behavior of the feature using BindUpdate: bound_feature = dt.BindUpdate(gaussian_noise, mu = 5, sigma=3) input_image = np.zeros((512, 512)) output_image = bound_feature.resolve(input_image) print(np.mean(output_image), np.std(output_image)) ```