-
Notifications
You must be signed in to change notification settings - Fork 4
Added Pipeline for LSM and PSOCT Data #83
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
calvinchai
wants to merge
137
commits into
main
Choose a base branch
from
lsm-features
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from 128 commits
Commits
Show all changes
137 commits
Select commit
Hold shift + click to select a range
b748e77
feat: add pipeline for converting single tiff file
calvinchai 27f0d72
fix: hot fix for Emine
calvinchai cbf5572
wip: oct stitching
calvinchai 2b892a7
wip: oct stitching
calvinchai e992222
wip: oct stitching
calvinchai 4afb6ea
wip: oct stitching
calvinchai 28a4fec
wip: psoct stitching
calvinchai 9e757c9
refactor: simplify MosaicInfo creation by extracting dimensions and c…
calvinchai 646f62c
feat: add mask loading and application to mosaic2d function, with cro…
calvinchai ae1856f
refactor: streamline image loading and enhance mosaic2d function with…
calvinchai cc1c26b
enhance: integrate progress bar for tile processing and streamline re…
calvinchai b10f06e
feat: add mosaic2d and mosaic3d to module
calvinchai ecc0d66
feat: enhance mosaic3d function with unit handling and improved NIfTI…
calvinchai 6491067
feat: implement mosaic2d and mosaic3d modules for 2D and 3D mosaic cr…
calvinchai c8f0aae
refactor: update module exports to include renamed mosaic and mosaic_…
calvinchai d290267
Enhance SpoolSetInterpreter: Add raw_assembled_spool_shape attribute …
calvinchai 4a11c0c
feat: Add stripe module for converting stripe spool files to Zarr format
calvinchai 8fd30f7
Merge branch 'lsm-single-volume' into lsm-spool-stripe
calvinchai bb5d312
fix: center_affine call in NIfTI header processing
calvinchai 807fc0a
fix: specify shape and dtype parameters in create_array method
calvinchai a7d9b9b
fix: center_affine call in NIfTI header processing
calvinchai d16578f
fix: specify shape and dtype parameters in create_array method
calvinchai 94bd1b1
refactor: rename mosaic3d function to mosaic_complex for clarity
calvinchai 58e5e0b
Add Docker support with Dockerfile, .dockerignore, and GitHub Actions…
calvinchai 8c7c547
Refactor Dockerfile for Poetry installation and entrypoint
calvinchai 0c376ba
add poetry lock file
calvinchai 33de032
Implement multi-stage Docker build with Poetry
calvinchai 79e209c
Add source label to Dockerfile
calvinchai c7b670d
Update Dockerfile syntax for build stages
calvinchai d835d1d
fix: line error when apply git
calvinchai 21278a4
fix: spell error
calvinchai ca0fc5d
refactor: update parameter names and improve documentation in lsm str…
calvinchai 1612cc7
refactor: optimize array concatenation in SpoolSetInterpreter
calvinchai b532118
Add Docker support with Dockerfile, .dockerignore, and GitHub Actions…
calvinchai 1a2ca9f
Refactor Dockerfile for Poetry installation and entrypoint
calvinchai bc17826
add poetry lock file
calvinchai 8ca5ddc
Implement multi-stage Docker build with Poetry
calvinchai 3102533
Add source label to Dockerfile
calvinchai a543252
Update Dockerfile syntax for build stages
calvinchai f2d72b1
refactor: enhance focus plane handling and normalize weight calculati…
calvinchai a9547b0
feat: add focus plane support in mosaic2d function
calvinchai 4810673
feat: add voxel size parameter to mosaic2d function
calvinchai 9098230
fix: update window function to use nan-aware statistics in ZarrGroup
calvinchai 78eddf1
feat: enhance mask handling in mosaic processing
calvinchai b4de82e
refactor: streamline image loading and mask handling in mosaic proces…
calvinchai 87d20fe
Enhance SpoolSetInterpreter: Add raw_assembled_spool_shape attribute …
calvinchai fe95b2f
feat: Add stripe module for converting stripe spool files to Zarr format
calvinchai 33cf064
feat: add pipeline for converting single tiff file
calvinchai 197e341
fix: hot fix for Emine
calvinchai 1bdd5f2
Add Docker support with Dockerfile, .dockerignore, and GitHub Actions…
calvinchai 73a9665
Refactor Dockerfile for Poetry installation and entrypoint
calvinchai 805525a
add poetry lock file
calvinchai 2ef1723
Implement multi-stage Docker build with Poetry
calvinchai 2939118
Add source label to Dockerfile
calvinchai 9793886
Update Dockerfile syntax for build stages
calvinchai 1e0573d
fix: line error when apply git
calvinchai 264fd04
fix: spell error
calvinchai 55c5cf1
refactor: update parameter names and improve documentation in lsm str…
calvinchai fbf5d71
refactor: optimize array concatenation in SpoolSetInterpreter
calvinchai 984b790
Merge remote-tracking branch 'origin/lsm-features' into lsm-features
calvinchai 0c0e49e
fix: typo
calvinchai 178cf9d
fix: correct syntax for Dockerfile source label
calvinchai d6b1d8c
wip: oct stitching
calvinchai 28cb9c0
wip: oct stitching
calvinchai 2b42e99
wip: oct stitching
calvinchai 65e2299
wip: oct stitching
calvinchai c222a1d
wip: psoct stitching
calvinchai f435d6d
refactor: simplify MosaicInfo creation by extracting dimensions and c…
calvinchai d90c705
feat: add mask loading and application to mosaic2d function, with cro…
calvinchai d6d920c
refactor: streamline image loading and enhance mosaic2d function with…
calvinchai 08c8c02
enhance: integrate progress bar for tile processing and streamline re…
calvinchai f53b6aa
feat: add mosaic2d and mosaic3d to module
calvinchai ada14dc
feat: enhance mosaic3d function with unit handling and improved NIfTI…
calvinchai cc57a44
feat: implement mosaic2d and mosaic3d modules for 2D and 3D mosaic cr…
calvinchai 2db1c6a
refactor: update module exports to include renamed mosaic and mosaic_…
calvinchai b124917
refactor: rename mosaic3d function to mosaic_complex for clarity
calvinchai d9eb881
Add Docker support with Dockerfile, .dockerignore, and GitHub Actions…
calvinchai 09bcff5
Refactor Dockerfile for Poetry installation and entrypoint
calvinchai 791317d
add poetry lock file
calvinchai 63b7137
Implement multi-stage Docker build with Poetry
calvinchai 184ce0a
Add source label to Dockerfile
calvinchai c8dc167
Update Dockerfile syntax for build stages
calvinchai 8a978c6
refactor: enhance focus plane handling and normalize weight calculati…
calvinchai b57146d
feat: add focus plane support in mosaic2d function
calvinchai b5c284f
feat: add voxel size parameter to mosaic2d function
calvinchai 1c4ea53
feat: enhance mask handling in mosaic processing
calvinchai b602b87
refactor: streamline image loading and mask handling in mosaic proces…
calvinchai a436ae0
Merge remote-tracking branch 'origin/oct-stitch' into oct-stitch
calvinchai bdcf6da
fix: add ndim property to H5ArrayWrapper and MatArrayWrapper classes
calvinchai 6bce3f5
fix: add clipping functionality to focus plane in mosaic2d function
calvinchai 8e523d6
update
calvinchai 260e95a
Merge branch 'oct-stitch' into lsm-features
calvinchai cb11c08
feat: improve tile stitching process and normalize coordinates
calvinchai 88d743c
feat: add tile configuration generator for PSOCT mosaics
calvinchai 4c72768
fix: add logging and remove print statement in spool file loading
calvinchai eee7d05
refactor: move the stitching utility
calvinchai abe099f
fix: added missing import
calvinchai c628f3b
refactor: merge matlab io utils into one file
calvinchai f36b318
fix: correct voxel size format in NIfTI header construction
calvinchai 62bc9c9
chore: make info_file to be optional in strip converter
calvinchai c5e44c2
tests: add regression test for lsm pipelines
calvinchai 497e0b4
style: cleanup
calvinchai f56c989
refactor: move complex2processed function
calvinchai f54006e
docs: add type annotation for psoct pipelines
calvinchai 960bfd6
tests: add regression test for psoct pipelines
calvinchai b1008f5
fix: make the edge of blending ramp non-zero
calvinchai 395f2c3
style: clean up
calvinchai 5827f7f
refactor: make the tile config generation to be a pipeline in psoct m…
calvinchai 08c8788
chore: update test markers and options in pyproject.toml; remove work…
calvinchai 18ae7cc
refactor: move lsm data fixture to be shared between files
calvinchai 3460dfa
chore: update dependencies in poetry.lock and pyproject.toml; add sci…
calvinchai 302498a
refactor: clean up whitespace and improve formatting in stitch.py
calvinchai 3fe6603
style: improve code formatting and whitespace consistency in psoct mo…
calvinchai 2220e49
fix: set XYZT units for Nifti1Image header in wk_annotation test
calvinchai db1033f
refactor: update path handling in TensorStore configuration functions…
calvinchai 7a9f80e
test: add unit tests for linc_convert.utils.stitch module, covering t…
calvinchai 021259f
fix: update array comparison in assert_zarr_equal to use assert_allcl…
calvinchai 484350f
style: fix ruff error
calvinchai 39c372c
feat: convert assembly methods in SpoolSetInterpreter to return Dask …
calvinchai 7edc9f0
Implement conditional rechunking for result array
calvinchai dc8f324
feat: add functionality to save maximum intensity projection images i…
calvinchai 4be1be6
made minor changes
8f77033
removed unused import
7205e45
docker workflow bug fix
7052050
reverted today's commits
c388aec
Apply suggestion from @kabilar
kabilar c2e0370
Apply suggestion from @kabilar
kabilar c5d7ab3
Apply suggestion from @kabilar
kabilar 3df6573
Apply suggestion from @kabilar
kabilar 7de1fd2
Apply suggestion from @kabilar
kabilar 6017245
Apply suggestion from @kabilar
kabilar 8bd371a
Apply suggestion from @kabilar
kabilar e8b02dd
Apply suggestion from @kabilar
kabilar e686add
Apply suggestion from @kabilar
kabilar 4514c38
Apply suggestion from @kabilar
kabilar 7af0cd2
Apply suggestion from @kabilar
kabilar d624d22
Apply suggestion from @kabilar
kabilar File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,53 @@ | ||
| # Git | ||
| .git | ||
| .gitignore | ||
| .github | ||
|
|
||
| # Python | ||
| __pycache__ | ||
| *.py[cod] | ||
| *$py.class | ||
| *.so | ||
| .Python | ||
| *.egg-info | ||
| dist | ||
| build | ||
| .venv | ||
| venv | ||
| env | ||
| ENV | ||
|
|
||
| # Testing | ||
| .pytest_cache | ||
| .coverage | ||
| htmlcov | ||
| .tox | ||
| .mypy_cache | ||
| .ruff_cache | ||
|
|
||
| # Documentation | ||
| site | ||
| docs/requirements.txt | ||
|
|
||
| # IDE | ||
| .vscode | ||
| .idea | ||
| *.swp | ||
| *.swo | ||
| *~ | ||
|
|
||
| # OS | ||
| .DS_Store | ||
| Thumbs.db | ||
|
|
||
| # Project specific | ||
| scripts/*.ipynb | ||
| scripts/*.nii | ||
| scripts/*.tiff | ||
| scripts/*.jpeg | ||
| scripts/*.yaml | ||
| tests/data | ||
|
|
||
| # Poetry | ||
| poetry.lock.bak | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,65 @@ | ||
| name: Build and Push Docker Image | ||
|
|
||
| on: | ||
| push: | ||
| branches: | ||
| - main | ||
| - master | ||
| tags: | ||
| - 'v*' | ||
| pull_request: | ||
| branches: | ||
| - main | ||
| - master | ||
| workflow_dispatch: | ||
|
|
||
| env: | ||
| REGISTRY: ghcr.io | ||
| IMAGE_NAME: ${{ github.repository }} | ||
|
|
||
| jobs: | ||
| build-and-push: | ||
| runs-on: ubuntu-latest | ||
| permissions: | ||
| contents: read | ||
| packages: write | ||
|
|
||
| steps: | ||
| - name: Checkout repository | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Set up Docker Buildx | ||
| uses: docker/setup-buildx-action@v3 | ||
|
|
||
| - name: Log in to Container Registry | ||
| if: github.event_name != 'pull_request' | ||
| uses: docker/login-action@v3 | ||
| with: | ||
| registry: ${{ env.REGISTRY }} | ||
| username: ${{ github.actor }} | ||
| password: ${{ secrets.GITHUB_TOKEN }} | ||
|
|
||
| - name: Extract metadata (tags, labels) for Docker | ||
| id: meta | ||
| uses: docker/metadata-action@v5 | ||
| with: | ||
| images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} | ||
| tags: | | ||
| type=ref,event=branch | ||
| type=ref,event=pr | ||
| type=semver,pattern={{version}} | ||
| type=semver,pattern={{major}}.{{minor}} | ||
| type=semver,pattern={{major}} | ||
| type=sha,prefix={{branch}}- | ||
| type=raw,value=latest,enable={{is_default_branch}} | ||
|
|
||
| - name: Build and push Docker image | ||
| uses: docker/build-push-action@v5 | ||
| with: | ||
| context: . | ||
| push: ${{ github.event_name != 'pull_request' }} | ||
| tags: ${{ steps.meta.outputs.tags }} | ||
| labels: ${{ steps.meta.outputs.labels }} | ||
| cache-from: type=gha | ||
| cache-to: type=gha,mode=max | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,62 @@ | ||
| # ---------------------------------------------------------------------------- | ||
| # STAGE 1: Builder | ||
| # Used to install Poetry, compile dependencies, and create the virtual environment. | ||
| # ---------------------------------------------------------------------------- | ||
| FROM python:3.11-slim AS builder | ||
|
|
||
| # Set working directory | ||
| WORKDIR /app | ||
|
|
||
| # Install build dependencies (GCC, etc.) | ||
| # We need these to compile packages, but we don't want them in the final image. | ||
| RUN apt-get update && apt-get install -y \ | ||
| build-essential \ | ||
| && rm -rf /var/lib/apt/lists/* | ||
|
|
||
| # Install Poetry | ||
| RUN pip install poetry==1.8.4 | ||
|
|
||
| # Configure Poetry to create the venv inside the project folder | ||
| # This makes it easy to copy the whole folder to the next stage | ||
| ENV POETRY_NO_INTERACTION=1 \ | ||
| POETRY_VIRTUALENVS_IN_PROJECT=1 \ | ||
| POETRY_VIRTUALENVS_CREATE=1 \ | ||
| POETRY_CACHE_DIR=/tmp/poetry_cache | ||
|
|
||
| # Copy dependency definition files first (for caching) | ||
| COPY pyproject.toml poetry.lock ./ | ||
| RUN poetry lock | ||
| # Install dependencies (only the libraries) | ||
| RUN poetry install --no-root --no-dev --extras all && rm -rf $POETRY_CACHE_DIR | ||
|
|
||
| # Copy the rest of the application code | ||
| COPY . . | ||
| RUN poetry lock | ||
| # Install the application itself | ||
| #RUN poetry install --no-dev --extras all | ||
| RUN poetry build -f wheel | ||
| RUN ./.venv/bin/pip install dist/*.whl | ||
| # ---------------------------------------------------------------------------- | ||
| # STAGE 2: Runtime | ||
| # A fresh, empty image that only contains the Python runtime and our copied venv. | ||
| # ---------------------------------------------------------------------------- | ||
| FROM python:3.11-slim AS runtime | ||
|
|
||
| WORKDIR /app | ||
|
|
||
| # Create a non-root user for security (Best Practice) | ||
| RUN useradd -m -r appuser && chown appuser /app | ||
| USER appuser | ||
|
|
||
| # Copy the virtual environment from the builder stage | ||
| # We assume the path structure is identical (/app/.venv) | ||
| COPY --from=builder --chown=appuser:appuser /app/.venv /app/.venv | ||
|
|
||
| # Update PATH environment variable | ||
| # This allows us to type 'linc-convert' instead of '/app/.venv/bin/linc-convert' | ||
| ENV PATH="/app/.venv/bin:$PATH" | ||
| LABEL org.opencontainers.image.source=https://github.com/lincbrain/linc-convert | ||
| # Set the entrypoint | ||
| ENTRYPOINT ["linc-convert"] | ||
| # Default command | ||
| CMD ["--help"] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,89 @@ | ||
| """ Converts TIFF to OME-Zarr or NIfTI-Zarr. """ | ||
|
kabilar marked this conversation as resolved.
Outdated
|
||
|
|
||
| import logging | ||
| import os | ||
|
|
||
| import cyclopts | ||
| import dask.array as da | ||
| import dask_image.imread | ||
| import numpy as np | ||
|
|
||
| from linc_convert.modalities.lsm.cli import lsm | ||
| from linc_convert.utils.io.zarr import from_config | ||
| from linc_convert.utils.nifti_header import build_nifti_header | ||
| from linc_convert.utils.unit import to_ome_unit | ||
| from linc_convert.utils.zarr_config import ( | ||
| GeneralConfig, | ||
| NiftiConfig, | ||
| ZarrConfig, | ||
| autoconfig, | ||
| ) | ||
|
|
||
| logger = logging.getLogger(__name__) | ||
| single_volume = cyclopts.App(name="single_volume", help_format="markdown") | ||
| lsm.command(single_volume) | ||
|
|
||
|
|
||
| @single_volume.default | ||
| @autoconfig | ||
| def convert( | ||
| inp: str, | ||
| *, | ||
|
kabilar marked this conversation as resolved.
|
||
| general_config: GeneralConfig = None, | ||
| zarr_config: ZarrConfig = None, | ||
| nii_config: NiftiConfig = None, | ||
| ) -> None: | ||
| """ | ||
| Tiff to OME-Zarr. | ||
|
|
||
| Convert tiff files | ||
| into a pyramidal OME-ZARR (or NIfTI-Zarr) hierarchy. | ||
|
|
||
| Parameters | ||
| ---------- | ||
| inp | ||
| Path to the input tiff file | ||
|
kabilar marked this conversation as resolved.
|
||
| general_config | ||
| General configuration | ||
| zarr_config | ||
| Zarr related configuration | ||
| nii_config | ||
| NIfTI header related configuration | ||
| """ | ||
| general_config.set_default_name(os.path.splitext(inp)[0]) | ||
|
|
||
| inp_data = dask_image.imread.imread(inp) | ||
|
|
||
| # Prepare Zarr group | ||
| zgroup = from_config(general_config.out, zarr_config) | ||
|
|
||
| if not hasattr(inp_data, "dtype"): | ||
| raise Exception("Input is not a numpy array. This is unexpected.") | ||
|
|
||
| dataset = zgroup.create_array( | ||
| "0", | ||
| shape=inp_data.shape, | ||
| dtype=np.dtype(inp_data.dtype), | ||
| zarr_config=zarr_config, | ||
| ) | ||
|
|
||
| if dataset.shards: | ||
| inp_data = da.rechunk(inp_data, dataset.shards) | ||
| else: | ||
| inp_data = da.rechunk(inp_data, dataset.chunks) | ||
|
|
||
| da.store(inp_data, dataset) | ||
|
kabilar marked this conversation as resolved.
|
||
| zgroup.generate_pyramid(mode="mean", no_pyramid_axis=zarr_config.no_pyramid_axis) | ||
| logger.info("Write OME-Zarr multiscale metadata") | ||
| zgroup.write_ome_metadata(axes=["z", "y", "x"], space_unit=to_ome_unit("um")) | ||
|
|
||
| if nii_config.nii: | ||
| header = build_nifti_header( | ||
| zgroup=zgroup, | ||
| voxel_size_zyx=[1, 1, 1], | ||
| unit="um", | ||
|
kabilar marked this conversation as resolved.
Outdated
|
||
| nii_config=nii_config, | ||
| ) | ||
| zgroup.write_nifti_header(header) | ||
|
|
||
| logger.info("Conversion complete.") | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.