Skip to content

Segmentify on stacks with 4 channels #24

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

Open
pranathivemuri opened this issue Oct 4, 2019 · 0 comments
Open

Segmentify on stacks with 4 channels #24

pranathivemuri opened this issue Oct 4, 2019 · 0 comments

Comments

@pranathivemuri
Copy link

I have seen a couple of hangups for me to use segmentify on my 4 channeled TZXY zarr stack that I have discussed with @sofroniewn, but I wanted to put it out here as well.

  1. add a binding for saving the output layer after segmenting, I used ipython terminal to save which is really handy, but I think it might be great to have a binding where you can go on a layer and say ctrl+s and it will save the data on the layer, maybe?

  2. also annotations and segmentations on 4 channeled images give different featurizers different errors. One with the hpa.pth's is that channels is expected to be 1 not greater than 1 and with filter featurizer, gaussian etc filters expect a 2D image error. It would be great if segmenify takes only the array at which it is right at the instant, and not the whole array in the viewer to segment

Here is my workaround command line tool for this for now

"""segmentify zarr command line viewer.
python3.6 segmentify/segmentify_zarr.py --zarr "2019-07-10-17-12-23-06-f2va.mch8.4_fused_cropped.zarr/fused/fused/"
"""

import argparse
import dask.array as da
from scipy.ndimage import zoom
from segmentify import Viewer, gui_qt


def main(args):
    """The main Command Line Interface for Segmentify zarr"""

    # parse in zarr
    array = da.from_zarr(args.zarr)

    # Rescale to t, z, 512, 512
    assert len(array.shape) == 4
    assert array.shape[2] == array.shape[3] == 2048
    img = zoom(array, [1, 1, 0.25, 0.25]).astype(float)

    # Click shift+n till you get the filter as the featurizer,
    # more generic than using
    # specific HPA Cell, nucleus etc featurizers as in README
    for x in range(img.shape[0]):
        for y in range(img.shape[1]):
            with gui_qt():
                viewer = Viewer(img[x, y, :, :].astype(float))

                # TODO add a binding for saving the output layer

                # Or run the below 4 lines in ipython terminal inside napari
                # from skimage import imsave
                # image = viewer.layers['output'].data
                # path = "groundtruth_{}_{}.png".format(x, y)
                # imsave(path, image)

            # closing the viewer will show the next image to annotate
            # TODO all multi channel images should be displayed at once and only
            # one image can be annotated and segmeted at a time


if __name__ == "__main__":
    # parser
    parser = argparse.ArgumentParser()
    parser.add_argument("--zarr", type=str, help="Zarr to view and segment.")
    args = parser.parse_args()

    main(args)```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant