{"name":"napari-em-assistant","display_name":"napari EM Assistant","visibility":"public","icon":"","categories":["Utilities"],"schema_version":"0.2.1","on_activate":null,"on_deactivate":null,"contributions":{"commands":[{"id":"napari-em-assistant.make_clahe_widget","title":"Enhance Local Contrast CLAHE","python_name":"napari_em_assistant.tasks.enhance_local_contrast_clahe.widget:EnhanceLocalContrastCLAHEWidget","short_title":null,"category":null,"icon":null,"enablement":null},{"id":"napari-em-assistant.make_crop_widget","title":"Crop Image","python_name":"napari_em_assistant.tasks.crop_image.widget:CropImageWidget","short_title":null,"category":null,"icon":null,"enablement":null}],"readers":null,"writers":null,"widgets":[{"command":"napari-em-assistant.make_clahe_widget","display_name":"CLAHE","autogenerate":false},{"command":"napari-em-assistant.make_crop_widget","display_name":"Crop Image","autogenerate":false}],"sample_data":null,"themes":null,"menus":{},"submenus":null,"keybindings":null,"configuration":[]},"package_metadata":{"metadata_version":"2.4","name":"napari-em-assistant","version":"0.2.3","dynamic":null,"platform":null,"supported_platform":null,"summary":"Task-based EM image processing assistant for napari","description":"# napari-em-assistant\n\nTask-based electron microscopy image processing tools for napari.\n\n`napari-em-assistant` is organized around small, explicit processing tasks that\ncan be used interactively on an active napari layer or applied to folders of EM\nimages. The first tasks are ImageJ/Fiji-style local contrast enhancement with\nCLAHE and frictionless 2D/3D image cropping.\n\n## Current Task\n\n### Enhance Local Contrast CLAHE\n\nThe CLAHE task provides a napari widget for 2D grayscale EM images and 3D\ngrayscale stacks. It follows the ImageJ/Fiji dialog shape and default values:\n\n- block size: `127`\n- histogram bins: `256`\n- maximum slope: `3.00`\n- mask: `*None*`\n- fast: checked\n\nThe widget can:\n\n- show a top acceleration bar for CPU, CUDA via CuPy, or CPU fallback\n- preview CLAHE on the active image layer\n- apply CLAHE to the active 2D image layer or 3D grayscale stack\n- create a new layer named `<source_layer_name>_CLAHE`\n- batch process TIFF folders to an output folder\n- show batch progress with load/process checks, status, and output path\n\n## Backends\n\n- `opencv_cpu`: fast CPU approximation using `cv2.createCLAHE`.\n- `imagej_reference`: Python implementation ported from Fiji's\n  `mpicbg.ij.clahe.PlugIn` 2D grayscale CLAHE path. 3D stacks are processed\n  slice-by-slice. The `fast` checkbox only affects this backend.\n- `gpu_cupy`: experimental CuPy/CUDA batch backend. If CuPy or a CUDA device is\n  not available, it falls back to `opencv_cpu`. It may be slower than\n  `opencv_cpu` for many current workloads because the implementation pays GPU\n  transfer overhead and is not yet a fully optimized CUDA CLAHE kernel.\n\nThe acceleration bar shows the active mode for the selected backend. Detailed\nCuPy/OpenCV CUDA availability is still available in the tooltip for diagnostics.\n\nOpenCV CLAHE parameters are not identical to ImageJ/Fiji CLAHE parameters.\nThe OpenCV backend is faster, but it rescales the ImageJ-style `maximum slope`\nbefore passing it as OpenCV `clipLimit` for a more ImageJ-like user experience;\n`maximum slope` values up to `1` apply no enhancement in the OpenCV backend. Use\n`imagej_reference` when Fiji-style output is the priority. Current OpenCV and\nCuPy paths should be treated as practical approximations.\n\n## Install\n\nFrom this repository:\n\n```bash\npip install -e .\n```\n\nOptional CuPy support depends on the workstation CUDA stack. A convenience extra\nis provided:\n\n```bash\npip install -e \".[gpu]\"\n```\n\nIf that wheel does not match the local CUDA runtime, install the correct CuPy\npackage manually and keep the base plugin install CPU-only.\n\n## Use In napari\n\nAfter installation, open napari and choose:\n\n```text\nPlugins > Enhance Local Contrast CLAHE\n```\n\nFor interactive use, select a 2D grayscale image layer or 3D grayscale stack and\nuse `Preview` or `Apply to Active Layer`.\n\n### Crop Image\n\nThe crop task provides a compact widget for 2D images and 3D grayscale stacks.\nIt is organized around four imaging workflows: crop from a drawn ROI, tile by\ntotal tile count, tile by pixel size, and advanced coordinate cropping. A progress bar reports\nsaved or created crop pieces as `completed / total`.\nThe widget asks for confirmation before likely mistakes, including very tiny\ncrops from a large source image/stack and operations that would save more than\n1000 crop TIFF files.\n\nFor detailed step-by-step crop workflows, see\n[src/napari_em_assistant/tasks/crop_image/README.md](src/napari_em_assistant/tasks/crop_image/README.md).\n\nFor large images, choose a save folder and use either tiling workflow:\n\n- `Tile by Total Count`: enter the total number of output tiles wanted. The\n  plugin chooses a near-even Y/X grid automatically and keeps full Z depth for\n  3D stacks. For example, `6` creates six image tiles.\n- `Tile by Pixel Size`: save tiles with the requested output dimensions. For\n  example, a `6000 x 6000 x 500` stack with `z size = 0`, `y size = 2000`, and\n  `x size = 2000` writes nine `500 x 2000 x 2000` stack tiles. `z size = 0`\n  keeps the full Z depth in every tile.\n\nFor batch use, choose an input folder containing 2D images or 3D grayscale\nstacks saved as `.tif` or `.tiff` files, choose an output folder, select a\nbackend, and run the batch. Outputs are saved as:\n\n```text\n<stem>_clahe.tif\n```\n\n## Validation\n\nThe current implementation is tested for:\n\n- widget and backend imports\n- Fiji-derived `imagej_reference` fast and exact paths\n- OpenCV CLAHE on synthetic `uint8` and `uint16` images\n- shape preservation\n- dtype preservation where possible\n- 3D stack support\n- GPU stub behavior\n- `gpu_cupy` CPU fallback behavior\n- batch result and progress reporting\n\nRun tests with:\n\n```bash\npython3 -m pytest tests/tasks/test_enhance_local_contrast_clahe.py\n```\n","description_content_type":"text/markdown","keywords":"EM image anlaysis,CLAHE","home_page":null,"download_url":null,"author":"Wulin Teo","author_email":null,"maintainer":null,"maintainer_email":null,"license":"MIT","classifier":["Framework :: napari","Intended Audience :: Science/Research","License :: OSI Approved :: MIT License","Programming Language :: Python :: 3","Programming Language :: Python :: 3.11","Topic :: Scientific/Engineering :: Image Processing"],"requires_dist":["numpy","tifffile","qtpy","napari","opencv-python-headless"],"requires_python":">=3.11","requires_external":null,"project_url":["Homepage, https://github.com/wulinteousa2-hash/napari-em-assistant","Repository, https://github.com/wulinteousa2-hash/napari-em-assistant","Issues, https://github.com/wulinteousa2-hash/napari-em-assistant/issues"],"provides_extra":null,"provides_dist":null,"obsoletes_dist":null},"npe1_shim":false}