### Run radialft with example parameters Source: https://github.com/tlambert03/pycudadecon/blob/main/docs/cli.md Example of how to run the `radialft` command-line tool with input and output files, and specific parameters for deconvolution. ```bash radialft /path/to/psf_file.tif /path/to/new_otf_file.tif --fixorigin 10 --nocleanup ``` -------------------------------- ### Using RLContext for Automatic Deconvolution Setup Source: https://github.com/tlambert03/pycudadecon/blob/main/docs/deconvolution.md This snippet demonstrates the use of the `RLContext` context manager for automatic setup and cleanup of the GPU deconvolution process. It reads data from a TIFF file and specifies the path to the OTF file. ```python data = tiffile.imread('some_file.tif') otf = 'path_to_otf.tif' with RLContext(data.shape, otf) as ctx: result = rl_decon(data, output_shape=ctx.out_shape) ``` -------------------------------- ### Install pyCUDAdecon Source: https://context7.com/tlambert03/pycudadecon/llms.txt Install pyCUDAdecon using conda. Optionally specify a CUDA version. ```bash conda install -c conda-forge pycudadecon # Optionally specify CUDA version conda install -c conda-forge pycudadecon cuda-version=12 ``` -------------------------------- ### Run cudadecon with deskew and MIP flags Source: https://github.com/tlambert03/pycudadecon/blob/main/docs/cli.md Example of running cudadecon with specific flags for deskewing and saving a maximum intensity projection. ```bash cudadecon /folder/of/images 488nm /path/to/488nm_otf.tif -z 0.3 -D 31.5 -M 0 0 1 ``` -------------------------------- ### Install PyCUDADecon with Conda Source: https://github.com/tlambert03/pycudadecon/blob/main/docs/installation.md Use this command to install the PyCUDADecon package and its pre-compiled libraries for Windows and Linux. ```bash conda install -c conda-forge pycudadecon ``` -------------------------------- ### RLContext Context Manager Source: https://github.com/tlambert03/pycudadecon/blob/main/docs/deconvolution.md The RLContext provides a convenient way to manage the setup and breakdown of GPU deconvolution resources automatically using a context manager. ```APIDOC ## RLContext ### Description A context manager that automatically handles the setup and breakdown of GPU deconvolution resources. It simplifies the process of initializing and cleaning up deconvolution contexts. ### Method (Not specified, likely a Python class constructor used with 'with' statement) ### Endpoint (Not applicable, this is a Python library class) ### Parameters - **shape** (tuple) - The shape of the raw data. - **otf_path** (str) - The file path to the Optical Transfer Function (OTF) file. - **output_shape** (tuple, optional) - The desired shape of the output deconvolution result. ### Request Example ```python import tiffile from pycudadecon import RLContext, rl_decon data = tiffile.imread('some_file.tif') otf = 'path_to_otf.tif' with RLContext(data.shape, otf) as ctx: result = rl_decon(data, output_shape=ctx.out_shape) ``` ### Response (The context manager itself does not return a value directly, but it makes deconvolution results available via the `rl_decon` function called within its scope.) ``` -------------------------------- ### Install PyCUDADecon with Specific CUDA Toolkit Version Source: https://github.com/tlambert03/pycudadecon/blob/main/docs/installation.md To specify a particular CUDA toolkit version (e.g., 11 or 12), use this installation command. Ensure your GPU driver is compatible with the chosen CUDA version. ```bash conda install -c condaforge pycudadecon cuda-version=<11 or 12> ``` -------------------------------- ### High-Level Deconvolution with decon Source: https://context7.com/tlambert03/pycudadecon/llms.txt Use the `decon` function for quick Richardson-Lucy deconvolution. It handles GPU setup automatically and accepts various input types like file paths, numpy arrays, or directories. Supports advanced parameters for image processing. ```python from pycudadecon import decon import numpy as np # Basic deconvolution with file paths result = decon('/path/to/image.tif', '/path/to/psf.tif') # Deconvolve a numpy array with a PSF file image = np.random.rand(64, 256, 256).astype(np.uint16) psf = np.random.rand(64, 64, 64).astype(np.uint16) result = decon(image, psf) # Deconvolve all matching files in a directory result = decon( '/directory/with/images', '/path/to/psf.tif', fpattern='*488nm*.tif' # Only process files matching this pattern ) # Full parameter example with deskewing for light sheet data result = decon( image, psf, dzpsf=0.1, # PSF z-step size in microns dxpsf=0.1, # PSF xy pixel size in microns dzdata=0.3, # Image z-step size in microns dxdata=0.1, # Image xy pixel size in microns wavelength=488, # Emission wavelength in nm na=1.1, # Numerical aperture nimm=1.33, # Refractive index of immersion medium background=100, # Background value to subtract (or 'auto') n_iters=15, # Number of RL iterations deskew=31.5, # Deskew angle for stage-scanning acquisition rotate=31.5, # Rotation angle around Y axis napodize=15, # Edge softening pixels nz_blend=8, # Z sections to blend to reduce axial ringing dup_rev_z=True # Duplicate reversed stack to reduce Z ringing ) # Get both deconvolved and deskewed raw data decon_result, deskewed_raw = decon( image, psf, deskew=31.5, save_deskewed=True ) ``` -------------------------------- ### rl_init - Initialize GPU for Deconvolution Source: https://context7.com/tlambert03/pycudadecon/llms.txt Low-level function to prepare the GPU with a cuFFT plan for deconvolution. Must be paired with `rl_cleanup()` when finished. Use `RLContext` for automatic cleanup. ```APIDOC ## rl_init - Initialize GPU for Deconvolution ### Description Low-level function to prepare the GPU with a cuFFT plan for deconvolution. Must be paired with `rl_cleanup()` when finished. Use `RLContext` for automatic cleanup. ### Method `rl_init` ### Parameters #### Path Parameters - **rawdata_shape** (tuple) - Required - The shape of the raw data to be processed. - **otf_shape** (tuple) - Required - The shape of the Optical Transfer Function (OTF). ### Request Example ```python from pycudadecon import rl_init, rl_decon, rl_cleanup import tifffile # Example usage (assuming you have rawdata and otf loaded) # rawdata_shape = (64, 256, 256) # otf_shape = (64, 64, 64) # rl_init(rawdata_shape, otf_shape) # ... perform deconvolution using rl_decon ... # rl_cleanup() ``` ### Response #### Success Response (200) - **None** - This function initializes the GPU context and does not return a value. #### Response Example ```json { "message": "GPU context initialized successfully." } ``` ``` -------------------------------- ### radialft command-line options Source: https://github.com/tlambert03/pycudadecon/blob/main/docs/cli.md Displays the help message for the `radialft` command-line tool, listing all available options and their descriptions. ```text $ radialft --help --input-file arg input PSF file --output-file arg output OTF file to write --na arg (=1.25) NA of detection objective --nimm arg (=1.29999995) refractive index of immersion medium --xyres arg (=0.104000002) x-y pixel size --zres arg (=0.104000002) z pixel size --wavelength arg (=530) emission wavelength in nm --fixorigin arg (=5) for all kz, extrapolate using pixels kr=1 to this pixel to get value for kr=0 --krmax arg (=0) pixels outside this limit will be zeroed (overwriting estimated value from NA and NIMM) --nocleanup elect not to do clean-up outside OTF support --background arg use user-supplied background instead of the estimated -3 [ --3Dout ] Output 3D, instead of rotationally averaged, OTF -h [ --help ] produce help message ``` -------------------------------- ### Install pycudadecon with Specific CUDA Version Source: https://github.com/tlambert03/pycudadecon/blob/main/README.md Install pycudadecon specifying a CUDA toolkit version. Ensure your GPU driver meets the minimum requirements for the chosen CUDA version. ```sh conda install -c conda-forge pycudadecon cuda-version=<11 or 12> ``` -------------------------------- ### Initialize GPU and Perform Deconvolution Source: https://context7.com/tlambert03/pycudadecon/llms.txt Initializes the GPU with image and OTF parameters, performs Richardson-Lucy deconvolution, and cleans up GPU resources. Ensure to call rl_cleanup() to release resources. ```python image = tifffile.imread('/path/to/image.tif') otf_path = '/path/to/otf.tif' try: # Initialize GPU with image shape and OTF rl_init( rawdata_shape=image.shape, # (nz, ny, nx) tuple otfpath=otf_path, dzdata=0.3, # Image z-step in microns dxdata=0.1, # Image xy pixel size dzpsf=0.1, # OTF z-step dxpsf=0.1, # OTF xy pixel size deskew=0, # Deskew angle (0 = no deskew) rotate=0, # Rotation angle (0 = no rotation) width=0, # Output width (0 = auto) skewed_decon=False # Deconvolve in skewed space ) # Perform deconvolution result = rl_decon(image, background=80, n_iters=10) finally: # Always cleanup GPU resources rl_cleanup() ``` -------------------------------- ### Initialize GPU for Deconvolution with rl_init Source: https://context7.com/tlambert03/pycudadecon/llms.txt Low-level function to prepare the GPU with a cuFFT plan for deconvolution. Must be paired with `rl_cleanup()` when finished. `RLContext` provides automatic cleanup. ```python from pycudadecon import rl_init, rl_decon, rl_cleanup import tifffile ``` -------------------------------- ### Generate Basic OTF File Source: https://context7.com/tlambert03/pycudadecon/llms.txt Create a radially averaged OTF file from a 3D PSF volume using the radialft tool. Specify the input PSF file and the desired output OTF file path. ```bash radialft /path/to/psf.tif /path/to/otf.tif ``` -------------------------------- ### Generate OTF with Full Parameters Source: https://context7.com/tlambert03/pycudadecon/llms.txt Generate a radially averaged OTF file with detailed parameter specification. This includes numerical aperture, immersion medium refractive index, resolution, wavelength, and processing options. ```bash radialft /path/to/psf.tif /path/to/otf.tif \ --na 1.1 \ --nimm 1.33 \ --xyres 0.104 \ --zres 0.1 \ --wavelength 488 \ --fixorigin 10 \ --nocleanup ``` -------------------------------- ### GPU Context Manager for Batch Processing with RLContext Source: https://context7.com/tlambert03/pycudadecon/llms.txt Use `RLContext` as a context manager for efficient batch processing of multiple images with the same shape. It initializes the GPU once, avoiding repeated setup/teardown overhead. Requires pre-generated OTF files. ```python from pycudadecon import RLContext, rl_decon import tifffile from glob import glob # Setup paths otf_path = '/path/to/pregenerated_otf.tif' image_files = glob('/path/to/images/*488*.tif') # Get the shape of input images (all must be the same shape) with tifffile.TiffFile(image_files[0]) as tf: imshape = tf.series[0].shape # Process multiple images efficiently with a single GPU context results = [] with RLContext( rawdata_shape=imshape, otfpath=otf_path, dzdata=0.3, # Image z-step in microns dxdata=0.1, # Image xy pixel size in microns dzpsf=0.1, # OTF z-step in microns dxpsf=0.1, # OTF xy pixel size in microns deskew=31.5, # Optional deskew angle rotate=31.5 # Optional rotation angle ) as ctx: for impath in image_files: image = tifffile.imread(impath) result = rl_decon( image, output_shape=ctx.out_shape, background='auto', n_iters=10, napodize=15 ) results.append(result) # Save or process result... ``` -------------------------------- ### Run Full Lattice Light Sheet Workflow Source: https://context7.com/tlambert03/pycudadecon/llms.txt Execute a complete light sheet workflow including deskew, rotation, and MIPs generation using the cudadecon command-line tool. Specify input/output paths, channel, OTF, and various processing parameters. ```bash cudadecon /folder/of/images 488nm /path/to/otf.tif \ -z 0.3 \ --drdata 0.104 \ -D 31.5 \ -R 31.5 \ -i 15 \ -b 100 \ -M 0 0 1 \ -S ``` -------------------------------- ### Display cudadecon help message Source: https://github.com/tlambert03/pycudadecon/blob/main/docs/cli.md Use the --help flag to display all available options and their descriptions for the cudadecon command. ```bash cudadecon -h ``` -------------------------------- ### Temporary OTF Generation with TemporaryOTF Source: https://github.com/tlambert03/pycudadecon/blob/main/docs/index.md Use the TemporaryOTF context manager for on-the-fly OTF generation from a 3D PSF volume. This is useful for deconvolution tasks where a temporary OTF is needed. ```python # continuing with the variables from the previous example... psf_path = "/path/to/psf_3D.tif" with TemporaryOTF(psf) as otf: with RLContext(imshape, otf.path, dz) as ctx: for impath in imlist: image = tifffile.imread(impath) result = rl_decon(image, output_shape=ctx.out_shape) # do something with result... ``` -------------------------------- ### Create Temporary OTF for Deconvolution Source: https://context7.com/tlambert03/pycudadecon/llms.txt Demonstrates creating a temporary OTF from a PSF file path or numpy array for deconvolution. The OTF is automatically cleaned up after use. It can also directly use an existing OTF file path. ```python from pycudadecon import TemporaryOTF, RLContext import tifffile # From a PSF file path psf_path = '/path/to/psf_bead_stack.tif' with TemporaryOTF( psf=psf_path, dzpsf=0.1, dxpsf=0.1, wavelength=488, na=1.1, nimm=1.33, fixorigin=10, cleanup_otf=True ) as otf: print(f"Temporary OTF at: {otf.path}") # Use the OTF for deconvolution image = tifffile.imread('/path/to/image.tif') with RLContext(image.shape, otf.path, dzdata=0.3, dxdata=0.1) as ctx: result = rl_decon(image, output_shape=ctx.out_shape) # From a numpy array PSF psf_array = tifffile.imread('/path/to/psf.tif') with TemporaryOTF(psf=psf_array, dzpsf=0.1, dxpsf=0.1, wavelength=525) as otf: with RLContext(image.shape, otf.path) as ctx: result = rl_decon(image, output_shape=ctx.out_shape) # If already an OTF file, TemporaryOTF just passes through the path with TemporaryOTF('/path/to/existing_otf.tif') as otf: # otf.path == '/path/to/existing_otf.tif' pass ``` -------------------------------- ### Temporary OTF Generation for Deconvolution Source: https://github.com/tlambert03/pycudadecon/blob/main/README.md Use the TemporaryOTF context manager for on-the-fly OTF generation from a 3D PSF volume, then use RLContext for deconvolution. This is useful for temporary OTF needs. ```python # continuing with the variables from the previous example... psf_path = "/path/to/psf_3D.tif" with TemporaryOTF(psf) as otf: with RLContext(imshape, otf.path, dz) as ctx: for impath in imlist: image = tifffile.imread(impath) result = rl_decon(image, ctx.out_shape) # do something with result... ``` -------------------------------- ### Advanced Deconvolution with RLContext and rl_decon Source: https://github.com/tlambert03/pycudadecon/blob/main/docs/index.md For finer control, create an OTF file and use the RLContext manager to set up the GPU. Process multiple images within the same context. All images processed in a context must have the same input shape. ```python from pycudadecon import RLContext, rl_decon from glob import glob import tifffile image_folder = '/path/to/some_images/' imlist = glob(image_folder + '*488*.tif') otf_path = '/path/to/pregenerated_otf.tif' with tifffile.TiffFile(imlist[0]) as tf: imshape = tf.series[0].shape with RLContext(imshape, otf_path, dz) as ctx: for impath in imlist: image = tifffile.imread(impath) result = rl_decon(image, output_shape=ctx.out_shape) # do something with result... ``` -------------------------------- ### RL Context Manager and Deconvolution Source: https://context7.com/tlambert03/pycudadecon/llms.txt Demonstrates using the RLContext for managing GPU resources and performing Richardson-Lucy deconvolution with various options. ```APIDOC ## RLContext and rl_decon ### Description The `RLContext` class manages GPU resources for deconvolution, and `rl_decon` performs the Richardson-Lucy deconvolution algorithm. The GPU must be initialized before deconvolution. ### Method `rl_decon(im, background, n_iters, output_shape, napodize, nz_blend, pad_val, dup_rev_z, save_deskewed, shift)` ### Parameters #### Request Body (for `rl_decon`) - **im** (numpy.ndarray) - Input image volume. - **background** (float or str) - Background value to subtract. Can be 'auto' to detect from the last Z plane median. - **n_iters** (int) - Number of deconvolution iterations. - **output_shape** (tuple) - Expected output shape of the deconvolved image. - **napodize** (int, optional) - Pixels to soften edges for artifact reduction. - **nz_blend** (int, optional) - Number of Z sections to blend to reduce axial ringing. - **pad_val** (float, optional) - Padding value used during deskewing. - **dup_rev_z** (bool, optional) - Duplicate reversed Z stack to reduce Z ringing. - **save_deskewed** (bool, optional) - If True, returns both deconvolved and raw deskewed image. - **shift** (int, optional) - Extra X shift for the deskewed output when `save_deskewed` is True. ### Request Example ```python from pycudadecon import RLContext, rl_decon import numpy as np image = np.random.rand(64, 256, 256).astype(np.uint16) * 1000 otf_path = '/path/to/otf.tif' with RLContext(image.shape, otf_path) as ctx: # Basic deconvolution result = rl_decon( im=image, background=80, n_iters=10, output_shape=ctx.out_shape ) # Advanced deconvolution with artifact reduction result_advanced = rl_decon( im=image, background='auto', n_iters=15, output_shape=ctx.out_shape, napodize=15, nz_blend=8, pad_val=0.0, dup_rev_z=True ) ``` ### Response #### Success Response (200) - **result** (numpy.ndarray) - The deconvolved image volume. - **deskewed_raw** (numpy.ndarray, optional) - The raw deskewed image volume, returned if `save_deskewed` is True. #### Response Example ```json { "deconvolved_image": "[numpy array data]", "deskewed_raw_image": "[numpy array data]" } ``` ``` -------------------------------- ### cudadecon command-line options Source: https://github.com/tlambert03/pycudadecon/blob/main/docs/cli.md A comprehensive list of command-line arguments for the cudadecon tool, detailing input, processing, and output options. ```text cudaDecon. Version: 0.7.0 : --input-dir arg Folder of input images --filename-pattern arg File name pattern to find input images to process --otf-file arg OTF file --drdata arg (=0.104) Image x-y pixel size (um) -z [ --dzdata ] arg (=0.25) Image z step (um) --drpsf arg (=0.104) PSF x-y pixel size (um) -Z [ --dzpsf ] arg (=0.1) PSF z step (um) -l [ --wavelength ] arg (=0.525) Emission wavelength (um) -W [ --wiener ] arg (=-1) Wiener constant (regularization factor); if this value is positive then do Wiener filter instead of R-L -b [ --background ] arg (=90) User-supplied background -e [ --napodize ] arg (=15) # of pixels to soften edge with -E [ --nzblend ] arg (=0) # of top and bottom sections to blend in to reduce axial ringing -d [ --dupRevStack ] Duplicate reversed stack prior to decon to reduce Z ringing -n [ --NA ] arg (=1.2) Numerical aperture -i [ --RL ] arg (=15) Run Richardson-Lucy, and set how many iterations -D [ --deskew ] arg (=0) Deskew angle; if not 0.0 then perform deskewing before deconv --dcbds If deskewing, do it after decon; require sample-scan PSF and non-RA 3D OTF --padval arg (=0) Value to pad image with when deskewing -w [ --width ] arg (=0) If deskewed, the output image's width -x [ --shift ] arg (=0) If deskewed, the output image's extra shift in X (positive->left -R [ --rotate ] arg (=0) Rotation angle; if not 0.0 then perform rotation around y axis after deconv -S [ --saveDeskewedRaw ] Save deskewed raw data to files -C [ --crop ] arg Crop final image size to [x1:x2, y1:y2, z1:z2]; takes 6 integers separated by space: x1 x2 y1 y2 z1 z2; -M [ --MIP ] arg Save max-intensity projection along x, y, or z axis; takes 3 binary numbers separated by space: 0 0 1 -m [ --rMIP ] arg Save max-intensity projection of raw deskewed data along x, y, or z axis; takes 3 binary numbers separated by space: 0 0 1 -u [ --uint16 ] Save result in uint16 format; should be used only if no actual decon is performed -a [ --DoNotAdjustResForFFT ] Don't change data resolution size. Otherwise data is cropped to perform faster, more memory efficient FFT: size factorable into 2,3,5,7) --Pad arg (=0) Pad the image data with mirrored values to avoid edge artifacts. Currently only enabled when rotate and deskew are zero. --LSC arg Lightsheet correction file --FlatStart Start the RL from a guess that is a flat image filled with the median image value. This may suppress noise. -p [ --bleachCorrection ] Apply bleach correction when running multiple images in a single batch --lzw Use LZW tiff compression --skip arg (=0) Skip the first 'skip' number of files. --no_overwrite Don't reprocess files that are already deconvolved (i.e. exist in the GPUdecon folder). -Q [ --DevQuery ] Show info and indices of available GPUs -h [ --help ] This help message. -v [ --version ] show version and quit ``` -------------------------------- ### TemporaryOTF Context Manager Source: https://github.com/tlambert03/pycudadecon/blob/main/docs/otf.md Creates and deletes a temporary OTF from a 3D PSF input. ```APIDOC ## TemporaryOTF ### Description A context manager for creating and deleting a temporary Optical Transfer Function (OTF) from a 3D PSF input. ### Method (Not specified, likely a context manager usage in Python) ### Endpoint (Not applicable, this is a Python context manager) ### Parameters (Parameters for `TemporaryOTF` are not detailed in the provided text. Refer to the pycudadecon library for specifics.) ### Request Example (Not applicable, this is a Python context manager) ### Response (Response details for `TemporaryOTF` are not detailed in the provided text. Refer to the pycudadecon library for specifics.) ``` -------------------------------- ### Deskew GPU Source: https://github.com/tlambert03/pycudadecon/blob/main/docs/affine.md Applies a deskew affine transformation using GPU acceleration. ```APIDOC ## deskewGPU ### Description Applies a deskew affine transformation using GPU acceleration. ### Method (Not specified in source) ### Endpoint (Not specified in source) ### Parameters (Not specified in source) ### Request Example (Not specified in source) ### Response #### Success Response (200) (Not specified in source) #### Response Example (Not specified in source) ``` -------------------------------- ### RLContext - GPU Context Manager for Batch Processing Source: https://context7.com/tlambert03/pycudadecon/llms.txt A context manager for initializing and managing the GPU context for Richardson-Lucy deconvolution, optimized for efficient batch processing of multiple images. ```APIDOC ## RLContext - GPU Context Manager for Batch Processing ### Description A context manager that initializes the GPU for Richardson-Lucy deconvolution. Use this for efficient batch processing of multiple images with the same shape, as it avoids repeated GPU setup/teardown overhead. ### Method `RLContext` ### Parameters #### Path Parameters - **rawdata_shape** (tuple) - Required - The shape of the input images (must be consistent across all images in a batch). - **otfpath** (str) - Required - Path to the pre-generated Optical Transfer Function (OTF) file. #### Query Parameters - **dzdata** (float) - Optional - Image z-step size in microns. - **dxdata** (float) - Optional - Image xy pixel size in microns. - **dzpsf** (float) - Optional - OTF z-step size in microns. - **dxpsf** (float) - Optional - OTF xy pixel size in microns. - **deskew** (float) - Optional - Deskew angle for stage-scanning acquisition. - **rotate** (float) - Optional - Rotation angle around Y axis. ### Request Example ```python from pycudadecon import RLContext, rl_decon import tifffile from glob import glob # Setup paths otf_path = '/path/to/pregenerated_otf.tif' image_files = glob('/path/to/images/*488*.tif') # Get the shape of input images (all must be the same shape) with tifffile.TiffFile(image_files[0]) as tf: imshape = tf.series[0].shape # Process multiple images efficiently with a single GPU context results = [] with RLContext( rawdata_shape=imshape, otfpath=otf_path, dzdata=0.3, dxdata=0.1, dzpsf=0.1, dxpsf=0.1, deskew=31.5, rotate=31.5 ) as ctx: for impath in image_files: image = tifffile.imread(impath) result = rl_decon( image, output_shape=ctx.out_shape, background='auto', n_iters=10, napodize=15 ) results.append(result) # Save or process result... ``` ### Response #### Success Response (200) - **ctx** (RLContext object) - The initialized GPU context manager. #### Response Example ```json { "ctx": "[RLContext object]" } ``` ``` -------------------------------- ### radialft Command-Line Tool Source: https://github.com/tlambert03/pycudadecon/blob/main/docs/cli.md The radialft command converts a 3D PSF volume into a radially-averaged 2D complex OTF file, which can be used by cudaDecon. It also supports generating a 3D OTF file if the --3Dout option is specified. ```APIDOC ## radialft ### Description Generates a radially-averaged OTF file from a 3D PSF volume. ### Method Command-line execution ### Endpoint `radialft` ### Parameters #### Command-line Arguments - **input_psf_volume**: Path to the 3D PSF volume file. - **output_otf_file**: Path for the output OTF file. - **--3Dout**: If specified, outputs a 3D OTF file instead of a 2D radially-averaged OTF. ### Request Example ```bash radialft /path/to/psf_volume.tif /path/to/output_otf.tif radialft /path/to/psf_volume.tif /path/to/output_3d_otf.tif --3Dout ``` ### Response N/A (Command-line tool output) ### Error Handling - Errors may occur if the input PSF volume is not found or is in an invalid format. - Errors may occur if the output path is not writable. ``` -------------------------------- ### Show Available GPU Devices Source: https://context7.com/tlambert03/pycudadecon/llms.txt Query and display the available GPU devices recognized by the cudadecon tool. This is useful for verifying GPU availability and selection. ```bash cudadecon -Q ``` -------------------------------- ### Affine GPU Source: https://github.com/tlambert03/pycudadecon/blob/main/docs/affine.md Applies a general affine transformation using GPU acceleration. ```APIDOC ## affineGPU ### Description Applies a general affine transformation using GPU acceleration. ### Method (Not specified in source) ### Endpoint (Not specified in source) ### Parameters (Not specified in source) ### Request Example (Not specified in source) ### Response #### Success Response (200) (Not specified in source) #### Response Example (Not specified in source) ``` -------------------------------- ### GPU-Accelerated Deskewing of Stage-Scanned Volumes Source: https://context7.com/tlambert03/pycudadecon/llms.txt Performs GPU-accelerated deskewing for stage-scanned light sheet volumes. Adjust parameters like angle, width, shift, and padding value for optimal results. Requires image data and acquisition parameters. ```python from pycudadecon import deskewGPU import tifffile # Load a stage-scanned light sheet image image = tifffile.imread('/path/to/stage_scanned_image.tif') # Basic deskewing for lattice light sheet (31.5 degree angle) deskewed = deskewGPU( im=image, dxdata=0.1, # XY pixel size in microns dzdata=0.3, # Stage step size in microns (NOT final z-step) angle=31.5 # Deskew angle (sheet angle relative to stage motion) ) # Advanced deskewing with cropping and padding deskewed_cropped = deskewGPU( im=image, dxdata=0.1, dzdata=0.3, angle=31.5, width=512, # Crop output to this width (0 = auto) shift=10, pad_val=100 # Padding value (None = use median of last Z plane) ) # Save the result tifffile.imwrite('/path/to/deskewed_output.tif', deskewed) ``` -------------------------------- ### TemporaryOTF Context Manager Source: https://context7.com/tlambert03/pycudadecon/llms.txt A context manager that automatically generates a temporary OTF from a PSF (array or file) and cleans up afterward. It normalizes PSF input to always provide an OTF file path. ```python from pycudadecon import TemporaryOTF, RLContext, rl_decon import tifffile import numpy as np ``` -------------------------------- ### cudadecon - Batch Deconvolution Tool Source: https://context7.com/tlambert03/pycudadecon/llms.txt Command-line tool for batch deconvolution of image folders. ```APIDOC ## cudadecon - Batch Deconvolution Tool ### Description Command-line tool for batch deconvolution of image folders. ### Method `cudadecon` (command-line executable) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```bash # Basic deconvolution cudadecon /folder/of/images 488nm /path/to/488nm_otf.tif -z 0.3 ``` ### Response #### Success Response (200) - **Deconvolved images** - Processed images saved to the specified output location. #### Response Example ``` # Output is typically saved files, not a direct console response. ``` ``` -------------------------------- ### GPU Resource Management Source: https://context7.com/tlambert03/pycudadecon/llms.txt Functions for initializing and cleaning up GPU resources for deconvolution. ```APIDOC ## GPU Initialization and Cleanup ### Description `rl_init()` initializes the GPU with image and OTF parameters, and `rl_cleanup()` releases these resources. It's crucial to call `rl_cleanup()` to prevent memory leaks, especially when not using `RLContext`. ### Method `rl_init(rawdata_shape, otfpath, dzdata, dxdata, dzpsf, dxpsf, deskew, rotate, width, skewed_decon)` `rl_cleanup()` ### Parameters (for `rl_init`) #### Path Parameters - **rawdata_shape** (tuple) - Shape of the raw input image (nz, ny, nx). - **otfpath** (str) - Path to the OTF file. - **dzdata** (float) - Image z-step in microns. - **dxdata** (float) - Image xy pixel size in microns. - **dzpsf** (float) - OTF z-step in microns. - **dxpsf** (float) - OTF xy pixel size in microns. - **deskew** (float) - Deskew angle in degrees (0 = no deskew). - **rotate** (float) - Rotation angle in degrees (0 = no rotation). - **width** (int) - Output width (0 = auto). - **skewed_decon** (bool) - If True, deconvolve in skewed space. ### Request Example (Manual Management) ```python from pycudadecon import rl_init, rl_decon, rl_cleanup # Assume image and otf_path are defined # image = tifffile.imread('/path/to/image.tif') # otf_path = '/path/to/otf.tif' rl_init( rawdata_shape=image.shape, otfpath=otf_path, dzdata=0.3, dxdata=0.1, dzpsf=0.1, dxpsf=0.1, deskew=0, rotate=0, width=0, skewed_decon=False ) try: result = rl_decon(image, background=80, n_iters=10) finally: rl_cleanup() ``` ### Response #### Success Response (200) - **rl_init**: Initializes GPU resources. - **rl_cleanup**: Releases GPU resources. ``` -------------------------------- ### Generate 3D OTF (Non-Radially Averaged) Source: https://context7.com/tlambert03/pycudadecon/llms.txt Generate a non-radially averaged 3D OTF file from a 3D PSF volume. This option preserves the full 3D information of the point spread function. ```bash radialft /path/to/psf.tif /path/to/3d_otf.tif --3Dout ``` -------------------------------- ### affineGPU - General 3D Affine Transformation Source: https://context7.com/tlambert03/pycudadecon/llms.txt Performs arbitrary 3D affine transformations using a 4x4 transformation matrix on the GPU. ```APIDOC ## affineGPU - General 3D Affine Transformation ### Description Performs arbitrary 3D affine transformations using a 4x4 transformation matrix on the GPU. Supports translation, rotation, scaling, and shearing operations. ### Method `affineGPU` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```python from pycudadecon import affineGPU import numpy as np import tifffile image = tifffile.imread('/path/to/image.tif') nz, ny, nx = image.shape # Simple translation (shift by 10 pixels in each dimension) T_translate = np.array([ [1, 0, 0, 10], # x translation [0, 1, 0, 10], # y translation [0, 0, 1, 10], # z translation [0, 0, 0, 1] ], dtype=np.float32) translated = affineGPU(image, T_translate) # Rotation around Y axis by 30 degrees theta = np.deg2rad(30) T_rotate_y = np.array([ [np.cos(theta), 0, np.sin(theta), 0], [0, 1, 0, 0], [-np.sin(theta), 0, np.cos(theta), 0], [0, 0, 0, 1] ], dtype=np.float32) rotated = affineGPU(image, T_rotate_y) # Combined transformation: center, scale, rotate, translate back # 1. Translate center to origin T1 = np.array([ [1, 0, 0, nx/2], [0, 1, 0, ny/2], [0, 0, 1, nz/2], [0, 0, 0, 1] ], dtype=np.float32) # 2. Scale Z axis S = np.array([ [1, 0, 0, 0], [0, 1, 0, 0], [0, 0, 2, 0], # 2x Z scaling [0, 0, 0, 1] ], dtype=np.float32) # 3. Translate back T2 = np.array([ [1, 0, 0, -nx/2], [0, 1, 0, -ny/2], [0, 0, 1, -nz/2], [0, 0, 0, 1] ], dtype=np.float32) # Combine: T = T1 @ S @ T2 T_combined = T1 @ S @ T2 scaled = affineGPU(image, T_combined) # With voxel size for world coordinate transformation result = affineGPU( image, T_rotate_y, dzyx=(0.3, 0.1, 0.1) # Voxel size (dz, dy, dx) in microns ) ``` ### Response #### Success Response (200) - **transformed_image** (numpy.ndarray) - The transformed 3D image volume. #### Response Example ``` # No direct response example, but the output is a numpy array representing the transformed image. ``` ``` -------------------------------- ### Batch Deconvolution Command Line Tool Source: https://context7.com/tlambert03/pycudadecon/llms.txt Utilizes the `cudadecon` command-line tool for batch deconvolution of image folders. Specify input folder, wavelength, OTF file, and Z-step size. ```bash # Basic deconvolution cudadecon /folder/of/images 488nm /path/to/488nm_otf.tif -z 0.3 ``` -------------------------------- ### deskewGPU - Deskew Stage-Scanned Volumes Source: https://context7.com/tlambert03/pycudadecon/llms.txt Performs GPU-accelerated deskewing of 3D volumes acquired in stage-scanning mode. Corrects for shearing in light sheet microscopy data. ```APIDOC ## deskewGPU - Deskew Stage-Scanned Volumes ### Description Performs GPU-accelerated deskewing of 3D volumes acquired in stage-scanning mode on light sheet microscopes. This corrects for the shearing that occurs when the sample is scanned at an angle to the detection axis. ### Method `deskewGPU` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```python from pycudadecon import deskewGPU import tifffile # Load a stage-scanned light sheet image image = tifffile.imread('/path/to/stage_scanned_image.tif') # Basic deskewing for lattice light sheet (31.5 degree angle) deskewed = deskewGPU( im=image, dxdata=0.1, # XY pixel size in microns dzdata=0.3, # Stage step size in microns (NOT final z-step) angle=31.5 # Deskew angle (sheet angle relative to stage motion) ) # Advanced deskewing with cropping and padding deskewed_cropped = deskewGPU( im=image, dxdata=0.1, dzdata=0.3, angle=31.5, width=512, # Crop output to this width (0 = auto) shift=10, # Shift image center by this amount pad_val=100 # Padding value (None = use median of last Z plane) ) # Save the result tifffile.imwrite('/path/to/deskewed_output.tif', deskewed) ``` ### Response #### Success Response (200) - **deskewed** (numpy.ndarray) - The deskewed 3D image volume. #### Response Example ``` # No direct response example, but the output is a numpy array representing the deskewed image. ``` ``` -------------------------------- ### make_otf Function Source: https://github.com/tlambert03/pycudadecon/blob/main/docs/otf.md Writes the OTF to a file for later use. ```APIDOC ## make_otf ### Description Converts a 3D point spread function (PSF) volume into a radially averaged 2D complex Optical Transfer Function (OTF) and writes it to a file. ### Method (Not specified, likely a function call in Python) ### Endpoint (Not applicable, this is a Python function) ### Parameters (Parameters for `make_otf` are not detailed in the provided text. Refer to the pycudadecon library for specifics.) ### Request Example (Not applicable, this is a Python function) ### Response (Response details for `make_otf` are not detailed in the provided text. Refer to the pycudadecon library for specifics.) ``` -------------------------------- ### Generate radially-averaged OTF file Source: https://github.com/tlambert03/pycudadecon/blob/main/docs/cli.md The radialft command converts a 3D PSF volume into a 2D complex OTF file suitable for use with cudaDecon. The --3Dout flag can be used to generate a 3D OTF file instead. ```bash radialft ```