lsfm-destripe


Namelsfm-destripe JSON
Version 0.1.0 PyPI version JSON
download
home_pagehttps://github.com/peng-lab/lsfm_destripe
SummaryA PyTorch implementation of LSFM DeStripe method
upload_time2024-12-11 18:42:56
maintainerNone
docs_urlNone
authorJianxu Chen
requires_python>=3.9
licenseMIT license
keywords lsfm_destripe
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # LSFM DeStripe PyTorch

[![Build Status](https://github.com/peng-lab/lsfm_destripe/workflows/Build%20Main/badge.svg)](https://github.com/peng-lab/lsfm_destripe/actions)
[![Documentation](https://github.com/peng-lab/lsfm_destripe/workflows/Documentation/badge.svg)](https://peng-lab.github.io/lsfm_destripe/)
[![Code Coverage](https://codecov.io/gh/peng-lab/lsfm_destripe/branch/main/graph/badge.svg)](https://codecov.io/gh/peng-lab/lsfm_destripe)

A PyTorch implementation of LSFM DeStripe method

---

## Quick Start
### Use as Python API
(1) Provide a filename, run slice by slice (suitable for extremely large file)
suppose we have a to-be-processed volume saved in `data_path` with vertical stripe in it
```python
from lsfm_destripe import DeStripe

exe = DeStripe()  ###to run with default parameters for training
out = exe.train(
    X1=data_path,
    is_vertical=True,
    angle_offset=[0],
    mask=mask_path,
)
```
where the volume in `mask_path` is to specifically indicate structures that are to be reserved after processing, left out can run prue DeStripe without constraint, `is_vertical` is to define whether the stirpes, or say the direction of light sheet propagation is along vertical or horizona. In practice, the stripe maight not be strictly vertical/horizontal, thus the angle offset in degree can be defined in `angle_offset`. Moreover, for multi-directional LSFM, for example Ultramicroscope II, Lavision Biotec. whose outputs exhibit stripes in 3 directions, -10 degrees, 0 degress, and 10 degrees, DeStripe can also remove all the stripes at the same time by runing:
```python
out = exe.train(
    X1=data_path,
    is_vertical=True,
    angle_offset=[-10, 0, 10],
    mask=mask_path,
)
```
Alternatively, DeStripe can be initialized with user-defined train parameters, a full list of input arguments in `__init__` is here:
```
loss_eps: float = 10
qr: float = 0.5
resample_ratio: int = 3
GF_kernel_size_train: int = 29
GF_kernel_size_inference: int = 29
hessian_kernel_sigma: float = 1
sampling_in_MSEloss: int = 2
isotropic_hessian: bool = True
lambda_tv: float = 1
lambda_hessian: float = 1
inc: int = 16
n_epochs: int = 300
wedge_degree: float = 29
n_neighbors: int = 16
fast_GF: bool = False
require_global_correction: bool = True
fusion_GF_kernel_size: int = 49
fusion_Gaussian_kernel_size: int = 49
device: str = None
```

(2) Provide a array, i.e., the image to be processed, and necessary parameters (more suitable for small data or for use in napari)
suppose we have a to-be-processed volume `img_arr` that has been read in as a np.ndarray or dask.array.core.Array and has vertical stripes in it
```python
from lsfm_destripe import DeStripe

###run with default training params
out = DeStripe.train_on_full_arr(
    X=img_arr,
    is_vertical=True,
    angle_offset=[0],
    mask=mask_arr,
    device="cuda",
)
```
where `img_arr` has a size of $S \times 1 \times M \times N$, `mask_arr` has  a size of $S \times M \times N$ with element 1 and 0 giving reserve or not respectively, `device` by default is "cpu".
Also, customized training can be done by wrapping the training params that you'd like to change as a Dict.:
```python
from lsfm_destripe import DeStripe

out = DeStripe.train_on_full_arr(
    X=img_arr,
    is_vertical=True,
    angle_offset=[0],
    mask=mask_arr,
    device="cuda",
    train_params = {"resample_ratio": 3},
)
```
### Run from command line for batch processing
suppose we have a to-be-processed volume saved in /path/to/my/image.tiff and it has vertical stripes, and we'd like to save the result from DeStripe as /path/to/save/result.tif
```bash
destripe --X1_path /path/to/my/image.tiff \
         --is_vertical True \
         --angle_offset 0 \
         --save_path /path/to/save/result.tif
```
in addition, all the training parameters can be changed in command line:
```bash
destripe --X1_path /path/to/my/image.tiff \
         --is_vertical True \
         --angle_offset 0,-10,10 \
         --save_path /path/to/save/result.tif
```
a full list of changeable args:
```
usage: run_destripe --X1_path
                    --save_path
                    --is_vertical
                    --angle_offset
                    [--loss_eps 10]
                    [--qr 0.5]
                    [--resample_ratio 3]
                    [--GF_kernel_size_train 29]
                    [--GF_kernel_size_inference 29]
                    [--hessian_kernel_sigma 1]
                    [--sampling_in_MSEloss 2]
                    [--isotropic_hessian "True"]
                    [--lambda_tv 1]
                    [--lambda_hessian 1]
                    [--inc 16]
                    [--n_epochs 300]
                    [--wedge_degree 29]
                    [--n_neighbors 16]
                    [--fast_GF "False"]
                    [--require_global_correction "True"]
                    [--fusion_GF_kernel_size 49]
                    [--fusion_Gaussian_kernel_size 49]
                    [--X2_path None]
                    [--mask_path None]
                    [--boundary None]
                    [--save_path_top_or_left_view None]
                    [--save_path_bottom_or_right_view None]
```
## Installation

**Stable Release:** `pip install lsfm_destripe`<br>
**Development Head:** `pip install git+https://github.com/peng-lab/lsfm_destripe.git`

## Documentation

For full package documentation please visit [peng-lab.github.io/lsfm_destripe](https://peng-lab.github.io/lsfm_destripe).

## Development

See [CONTRIBUTING.md](CONTRIBUTING.md) for information related to developing the code.



**MIT license**




            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/peng-lab/lsfm_destripe",
    "name": "lsfm-destripe",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.9",
    "maintainer_email": null,
    "keywords": "lsfm_destripe",
    "author": "Jianxu Chen",
    "author_email": "jianxu.chen@isas.de",
    "download_url": "https://files.pythonhosted.org/packages/f8/95/991229e769ce3696ce7c83b1a2e41a2f6db652aee9c54ae2a397cb753992/lsfm_destripe-0.1.0.tar.gz",
    "platform": null,
    "description": "# LSFM DeStripe PyTorch\n\n[![Build Status](https://github.com/peng-lab/lsfm_destripe/workflows/Build%20Main/badge.svg)](https://github.com/peng-lab/lsfm_destripe/actions)\n[![Documentation](https://github.com/peng-lab/lsfm_destripe/workflows/Documentation/badge.svg)](https://peng-lab.github.io/lsfm_destripe/)\n[![Code Coverage](https://codecov.io/gh/peng-lab/lsfm_destripe/branch/main/graph/badge.svg)](https://codecov.io/gh/peng-lab/lsfm_destripe)\n\nA PyTorch implementation of LSFM DeStripe method\n\n---\n\n## Quick Start\n### Use as Python API\n(1) Provide a filename, run slice by slice (suitable for extremely large file)\nsuppose we have a to-be-processed volume saved in `data_path` with vertical stripe in it\n```python\nfrom lsfm_destripe import DeStripe\n\nexe = DeStripe()  ###to run with default parameters for training\nout = exe.train(\n    X1=data_path,\n    is_vertical=True,\n    angle_offset=[0],\n    mask=mask_path,\n)\n```\nwhere the volume in `mask_path` is to specifically indicate structures that are to be reserved after processing, left out can run prue DeStripe without constraint, `is_vertical` is to define whether the stirpes, or say the direction of light sheet propagation is along vertical or horizona. In practice, the stripe maight not be strictly vertical/horizontal, thus the angle offset in degree can be defined in `angle_offset`. Moreover, for multi-directional LSFM, for example Ultramicroscope II, Lavision Biotec. whose outputs exhibit stripes in 3 directions, -10 degrees, 0 degress, and 10 degrees, DeStripe can also remove all the stripes at the same time by runing:\n```python\nout = exe.train(\n    X1=data_path,\n    is_vertical=True,\n    angle_offset=[-10, 0, 10],\n    mask=mask_path,\n)\n```\nAlternatively, DeStripe can be initialized with user-defined train parameters, a full list of input arguments in `__init__` is here:\n```\nloss_eps: float = 10\nqr: float = 0.5\nresample_ratio: int = 3\nGF_kernel_size_train: int = 29\nGF_kernel_size_inference: int = 29\nhessian_kernel_sigma: float = 1\nsampling_in_MSEloss: int = 2\nisotropic_hessian: bool = True\nlambda_tv: float = 1\nlambda_hessian: float = 1\ninc: int = 16\nn_epochs: int = 300\nwedge_degree: float = 29\nn_neighbors: int = 16\nfast_GF: bool = False\nrequire_global_correction: bool = True\nfusion_GF_kernel_size: int = 49\nfusion_Gaussian_kernel_size: int = 49\ndevice: str = None\n```\n\n(2) Provide a array, i.e., the image to be processed, and necessary parameters (more suitable for small data or for use in napari)\nsuppose we have a to-be-processed volume `img_arr` that has been read in as a np.ndarray or dask.array.core.Array and has vertical stripes in it\n```python\nfrom lsfm_destripe import DeStripe\n\n###run with default training params\nout = DeStripe.train_on_full_arr(\n    X=img_arr,\n    is_vertical=True,\n    angle_offset=[0],\n    mask=mask_arr,\n    device=\"cuda\",\n)\n```\nwhere `img_arr` has a size of $S \\times 1 \\times M \\times N$, `mask_arr` has  a size of $S \\times M \\times N$ with element 1 and 0 giving reserve or not respectively, `device` by default is \"cpu\".\nAlso, customized training can be done by wrapping the training params that you'd like to change as a Dict.:\n```python\nfrom lsfm_destripe import DeStripe\n\nout = DeStripe.train_on_full_arr(\n    X=img_arr,\n    is_vertical=True,\n    angle_offset=[0],\n    mask=mask_arr,\n    device=\"cuda\",\n    train_params = {\"resample_ratio\": 3},\n)\n```\n### Run from command line for batch processing\nsuppose we have a to-be-processed volume saved in /path/to/my/image.tiff and it has vertical stripes, and we'd like to save the result from DeStripe as /path/to/save/result.tif\n```bash\ndestripe --X1_path /path/to/my/image.tiff \\\n         --is_vertical True \\\n         --angle_offset 0 \\\n         --save_path /path/to/save/result.tif\n```\nin addition, all the training parameters can be changed in command line:\n```bash\ndestripe --X1_path /path/to/my/image.tiff \\\n         --is_vertical True \\\n         --angle_offset 0,-10,10 \\\n         --save_path /path/to/save/result.tif\n```\na full list of changeable args:\n```\nusage: run_destripe --X1_path\n                    --save_path\n                    --is_vertical\n                    --angle_offset\n                    [--loss_eps 10]\n                    [--qr 0.5]\n                    [--resample_ratio 3]\n                    [--GF_kernel_size_train 29]\n                    [--GF_kernel_size_inference 29]\n                    [--hessian_kernel_sigma 1]\n                    [--sampling_in_MSEloss 2]\n                    [--isotropic_hessian \"True\"]\n                    [--lambda_tv 1]\n                    [--lambda_hessian 1]\n                    [--inc 16]\n                    [--n_epochs 300]\n                    [--wedge_degree 29]\n                    [--n_neighbors 16]\n                    [--fast_GF \"False\"]\n                    [--require_global_correction \"True\"]\n                    [--fusion_GF_kernel_size 49]\n                    [--fusion_Gaussian_kernel_size 49]\n                    [--X2_path None]\n                    [--mask_path None]\n                    [--boundary None]\n                    [--save_path_top_or_left_view None]\n                    [--save_path_bottom_or_right_view None]\n```\n## Installation\n\n**Stable Release:** `pip install lsfm_destripe`<br>\n**Development Head:** `pip install git+https://github.com/peng-lab/lsfm_destripe.git`\n\n## Documentation\n\nFor full package documentation please visit [peng-lab.github.io/lsfm_destripe](https://peng-lab.github.io/lsfm_destripe).\n\n## Development\n\nSee [CONTRIBUTING.md](CONTRIBUTING.md) for information related to developing the code.\n\n\n\n**MIT license**\n\n\n\n",
    "bugtrack_url": null,
    "license": "MIT license",
    "summary": "A PyTorch implementation of LSFM DeStripe method",
    "version": "0.1.0",
    "project_urls": {
        "Homepage": "https://github.com/peng-lab/lsfm_destripe"
    },
    "split_keywords": [
        "lsfm_destripe"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "3886421dbd5cb54c20f3e356f5cbba3d937e2f6cf4caf583787048442924e04f",
                "md5": "9efc9989e35e8a3a75be3fc5fc080e36",
                "sha256": "935f5b3a18da942268d4e29af8c732e6f3766edde3166fc83f09054b0eb19a95"
            },
            "downloads": -1,
            "filename": "lsfm_destripe-0.1.0-py2.py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "9efc9989e35e8a3a75be3fc5fc080e36",
            "packagetype": "bdist_wheel",
            "python_version": "py2.py3",
            "requires_python": ">=3.9",
            "size": 21268,
            "upload_time": "2024-12-11T18:42:53",
            "upload_time_iso_8601": "2024-12-11T18:42:53.881947Z",
            "url": "https://files.pythonhosted.org/packages/38/86/421dbd5cb54c20f3e356f5cbba3d937e2f6cf4caf583787048442924e04f/lsfm_destripe-0.1.0-py2.py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "f895991229e769ce3696ce7c83b1a2e41a2f6db652aee9c54ae2a397cb753992",
                "md5": "1661085a0ea4b44ea313f23c15715a4b",
                "sha256": "1737dd54d2dce89e1e06405e3e45176c139dab91d3104cbf246bdf6b4f881c4d"
            },
            "downloads": -1,
            "filename": "lsfm_destripe-0.1.0.tar.gz",
            "has_sig": false,
            "md5_digest": "1661085a0ea4b44ea313f23c15715a4b",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.9",
            "size": 25227,
            "upload_time": "2024-12-11T18:42:56",
            "upload_time_iso_8601": "2024-12-11T18:42:56.361687Z",
            "url": "https://files.pythonhosted.org/packages/f8/95/991229e769ce3696ce7c83b1a2e41a2f6db652aee9c54ae2a397cb753992/lsfm_destripe-0.1.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-12-11 18:42:56",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "peng-lab",
    "github_project": "lsfm_destripe",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "tox": true,
    "lcname": "lsfm-destripe"
}
        
Elapsed time: 1.51260s