tlambert03 / pycudadecon

Python wrapper for cudaDecon - GPU accelerated 3D deconvolution for microscopy
http://www.talleylambert.com/pycudadecon/
MIT License
59 stars 12 forks source link

feat: add arguments for 3D OTF generation #57

Closed zichenzachwang closed 1 month ago

zichenzachwang commented 2 months ago

Allow 3D OTF generation after changes have been added to radial_interface.cpp in cudadecon

tlambert03 commented 1 month ago

hey @zichenzachwang, I need your help in resolving conflicts (in the future, please create a personal branch for PRs, rather than using your main branch).

please change makeOTF to:

if lib.version and lib.version < (0, 7):
    @otf_lib.function
    def makeOTF(
        ifiles: bytes,
        ofiles: bytes,
        lambdanm: int = 520,
        dz: float = 0.102,
        interpkr: int = 10,
        bUserBackground: bool = False,
        background: float = 90,
        NA: float = 1.25,
        NIMM: float = 1.3,
        dr: float = 0.102,
        krmax: int = 0,
        bDoCleanup: bool = False,
    ) -> None:
        """Make OTF file(s) from `ifiles`, write to `ofiles`."""

else:

    @otf_lib.function
    def makeOTF(
        ifiles: bytes,
        ofiles: bytes,
        lambdanm: int = 520,
        dz: float = 0.102,
        interpkr: int = 10,
        bUserBackground: bool = False,
        background: float = 90,
        NA: float = 1.25,
        NIMM: float = 1.3,
        dr: float = 0.102,
        krmax: int = 0,
        bDoCleanup: bool = False,
        b3Dout: bool = False,
    ) -> None:
        """Make OTF file(s) from `ifiles`, write to `ofiles`."""

and then resolve conflicts on the other docstrings

zichenzachwang commented 1 month ago

hey @zichenzachwang, I need your help in resolving conflicts (in the future, please create a personal branch for PRs, rather than using your main branch).

please change makeOTF to:

if lib.version and lib.version < (0, 7):
    @otf_lib.function
    def makeOTF(
        ifiles: bytes,
        ofiles: bytes,
        lambdanm: int = 520,
        dz: float = 0.102,
        interpkr: int = 10,
        bUserBackground: bool = False,
        background: float = 90,
        NA: float = 1.25,
        NIMM: float = 1.3,
        dr: float = 0.102,
        krmax: int = 0,
        bDoCleanup: bool = False,
    ) -> None:
        """Make OTF file(s) from `ifiles`, write to `ofiles`."""

else:

    @otf_lib.function
    def makeOTF(
        ifiles: bytes,
        ofiles: bytes,
        lambdanm: int = 520,
        dz: float = 0.102,
        interpkr: int = 10,
        bUserBackground: bool = False,
        background: float = 90,
        NA: float = 1.25,
        NIMM: float = 1.3,
        dr: float = 0.102,
        krmax: int = 0,
        bDoCleanup: bool = False,
        b3Dout: bool = False,
    ) -> None:
        """Make OTF file(s) from `ifiles`, write to `ofiles`."""

and then resolve conflicts on the other docstrings

Hi Talley,

Thanks for mentioning that. I created a personal branch. Changes have been added. I also added to otf.py:

with CappedPSF(psf, max_otf_size) as _psf:
        args = [
            str.encode(_psf.path),
            str.encode(outpath),
            wavelength,
            dzpsf,
            fixorigin,
            bUserBackground,
            background,
            na,
            nimm,
            dxpsf,
            krmax,
            cleanup_otf,
        ]

        if not lib.lib.version or lib.lib.version >= (0, 7):
            args += [skewed_decon]

        lib.makeOTF(*args)  # type: ignore

There is just one last issue with typo check. It tries to correct b3Dout argument name but I used it to be consistent with cudadecon.

tlambert03 commented 1 month ago

Thanks @zichenzachwang

For the typo issue, add the string to the list of extend-ignore-identifiers-re at the bottom of pyproject.toml

zichenzachwang commented 1 month ago

Got it. Ready to merge!