Coder Social home page Coder Social logo

aind-ccf-registration's Introduction

aind-ccf-registration

License Code Style

This version is compatible with the Code Ocean Pipeline feature. Source code to register SmartSPIM datasets to the CCF Allen Atlas.

This module is part of a pipeline. Therefore, it assumes that the fused image comes in OME-Zarr format with different multiscales. At this point, we are using ANTS for the image registration and it's not possible to use the original resolution of the data. In consequence, we are using the 3rd multiscale from the original resolution.

$$resX=origResX*(2^m)$$ $$resY=origResY*(2^m)$$ $$resZ=origResZ*(2^m)$$

Where $$m$$ is the provided multiscale. By default, we are using the 3rd. Afterwards, we resample the image to match the $$25um$$ microns space and then, we register the resulting image to the Allen CCF atlas.

Installation

To use the software, in the root directory, run

pip install -e .

To develop the code, run

pip install -e .[dev]

In Code Ocean, it is necessary to create 5 text parameters:

  1. input_data: This parameter

Contributing

Linters and testing

There are several libraries used to run linters, check documentation, and run tests.

  • Please test your changes using the coverage library, which will run the tests and log a coverage report:
coverage run -m unittest discover && coverage report
  • Use interrogate to check that modules, methods, etc. have been documented thoroughly:
interrogate .
  • Use flake8 to check that code is up to standards (no unused imports, etc.):
flake8 .
  • Use black to automatically format the code into PEP standards:
black .
  • Use isort to automatically sort import statements:
isort .

Pull requests

For internal members, please create a branch. For external members, please fork the repo and open a pull request from the fork. We'll primarily use Angular style for commit messages. Roughly, they should follow the pattern:

<type>(<scope>): <short summary>

where scope (optional) describes the packages affected by the code changes and type (mandatory) is one of:

  • build: Changes that affect the build system or external dependencies (example scopes: pyproject.toml, setup.py)
  • ci: Changes to our CI configuration files and scripts (examples: .github/workflows/ci.yml)
  • docs: Documentation only changes
  • feat: A new feature
  • fix: A bug fix
  • perf: A code change that improves performance
  • refactor: A code change that neither fixes a bug nor adds a feature
  • test: Adding missing tests or correcting existing tests

Documentation

To generate the rst files source files for documentation, run

sphinx-apidoc -o doc_template/source/ code

Then to create the documentation html files, run

sphinx-build -b html doc_template/source/ doc_template/build/html

More info on sphinx installation can be found here: https://www.sphinx-doc.org/en/master/usage/installation.html

aind-ccf-registration's People

Contributors

camilolaiton avatar galenlynch avatar github-actions[bot] avatar jtyoung84 avatar nal10 avatar sharmishtaa avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar

aind-ccf-registration's Issues

Forward and reverse output

In the current CCF registration code, we are defining the Allen CCF template to be the "fixed" image and the (downsampled) SmartSPIM data as the "moving" image. ANTs then computes (amongst other things):

  • forward transform (fwdtransforms: Transforms to move from moving to fixed image.)
  • inverse transform (invtransforms: Transforms to move from fixed to moving image.)
    These definitions (from ANTsPy) are confusing to read - so many "moves."
    We use the "SyN" type of transform, so each of these have an affine + deformable component

The current registration code outputs:

  • fwdtransforms[1] to the affine_transforms_file
  • invtransforms[1] to the warp_transforms_file
    This is a bit weird, saving one component from each transform, but not all components from either. I guess it works for the quantification capsule because the affine gets inverted there (I think I can see that in the quantification capsule, but I don't have repo access so I can't link here. It's on quantification.py line 82).
    aside: I don't really understand why the fixed -> moving transform (inverse) deformation field correctly moves points from the original data space into the CCF...

The reason I bring this to the attention of the group is to advocate storing both forward and reverse transforms.
It may be useful, for example, to see the original high resolution data with the CCF boundaries present.
At the moment, this would require moving the full resolution image into CCF space (or at least a higher resolution version of it).
With the complete transform, you could transform a specific annotated region mask into the raw data space, then look at cell segmentation, counting, etc. in the raw data. I admit that this may be an edge case.

Suggested Changes
Either:

  1. Output the affine and warp transforms from the same (I guess inverse??? but seems like it should be forward) transform that will allow transforming original data into CCF space. This is just a more consistent version of what is happening, I think. This would be a choice to enforce always working in CCF space. aside: can we save the whole transform in one file and apply it in one step?
  2. Output both components of both forward and reverse transforms for completeness. These are both already computed, so the only reason not to do this is if the displacement array occupies a lot of disk space.

Let me tag @camilolaiton and @sharmishtaa , since I know they both work on registration.

Autobump semantic version number

User story

As a developer, I want github actions to manage the semantic version, so I don't have to worry about it.

Acceptance criteria

  • When a PR is merged into main, a github action will automatically increment the version based on the commit message.

Sprint Ready Checklist

    • Acceptance criteria defined
    • Team understands acceptance criteria
    • Team has defined solution / steps to satisfy acceptance criteria
    • Acceptance criteria is verifiable / testable
    • External / 3rd Party dependencies identified
    • Ticket is prioritized and sized

Notes

Add any helpful notes here.

Default parameters have incorrect spacing.

It looks like the ants_params:{"Spacing"} parameters are applied incorrectly when loading the light sheet volume into ants. The volume is flipped to match the CCF, but the parameters are set as though the volume is in its original smartspim configuration.

The solution is probably either to change the spacing parameters, e.g. (14.4,16,14.4) instead of the current (14.4,14.4,16) OR to reorder the parameters when they are set as the ants spacing.

Publish to PyPI

User story

As a user, I want the repo published to pypi, so I can pip install the package.

Acceptance criteria

  • When a PR is merged into main, a github action will publish the latest version to pypi.

Sprint Ready Checklist

    • Acceptance criteria defined
    • Team understands acceptance criteria
    • Team has defined solution / steps to satisfy acceptance criteria
    • Acceptance criteria is verifiable / testable
    • External / 3rd Party dependencies identified
    • Ticket is prioritized and sized

Notes

Add any helpful notes here.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.