MathOnco / valis

Virtual Alignment of pathoLogy Image Series
https://valis.readthedocs.io/en/latest/
MIT License
117 stars 29 forks source link

Saving as .ome.tiff #151

Open snackthingy opened 3 weeks ago

snackthingy commented 3 weeks ago

Very quick and easy question here: how can I save my post-registration images specifically to .ome.tiffs? The registration keeps converting to PNG and not preserving my z-stack which is making my data hard to analyze.

Thanks!

cdgatenbee commented 3 weeks ago

Hi @snackthingy, The only PNGs should be the thumbnails of the registration results, which would be located in the subfolders inside of "results_dst_dir/sample_name". The ome.tiffs should be getting saved in "registered_slide_dst_dir/". All of that is assuming your code is something like this:

from valis import registration
from valis.slide_io import BioFormatsSlideReader
slide_src_dir = "/Users/User1/Desktop/Bop/Test Unreg"
results_dst_dir = "/Users/User1/Desktop/Bop/Test Results"
registered_slide_dst_dir = "/Users/User1/Desktop/Bop/Test Registered"

# Perform registration
registrar = registration.Valis(slide_src_dir, results_dst_dir)
rigid_registrar, non_rigid_registrar, error_df = registrar.register(reader_cls=BioFormatsSlideReader)

# Save registered slides if the alignments look good
registrar.warp_and_save_slides(dst_dir=registered_slide_dst_dir, compression="deflate", Q=100)

# Kill JVM if all done
registration.kill_jvm()

But for clarification, are you finding that valis is saving PNGs in "registered_slide_dst_dir/", instead of ome.tiffs?

Best, -Chandler

snackthingy commented 3 weeks ago

Basically, the images I am inputting are .ome.tiffs with multiple slides (z-stacked) but the images I am getting out (which appear in the "registered_slide_dst_dir" are either PNGs or are TIFFs with no slides, just one image (usually just whatever the first slide in the z-stack was) but missing all the rest. No idea why it's happening but...

Bottom line: I am trying to align two z-stacks into one larger z-stack, but ultimately I'm getting a single-layer image as an output.

cdgatenbee commented 2 weeks ago

Hi @snackthingy,

Sorry for the delayed response, but this may have have to do with the way the original images are stored in the ome.tiff. I think what may be happening is that valis is just pulling out the 1st image to do the alignments, which is why you are only finding a single layer image in the output directory. However, I believe there is a way to get valis to align the full v-stack. Would you be able to share a pair of your images so that I can try to put something together to get this working? If so, please send a link to the folders containing the images to my e-mail, Chandler[dot]Gatenbee[@]moffitt[dot]org .

Best, -Chandler

andreevg04 commented 2 weeks ago

I would also be interested in registering multichannel images that are .ome.tiffs

cdgatenbee commented 1 week ago

Hi @andreevg04 and @snackthingy, I'd be more than happy to see if there is a way to get valis to register multiple multichannel images that contained in a single ome.tiff. Unfortunately, I don't personally have any images to test/develop with. If you have some you'd be willing to share, could you send a link to them to my email, Chandler[dot]Gatenbee[at]moffitt[dot]org?

andreevg04 commented 1 week ago

Hi @cdgatenbee I will send you some images. Also one of the folders to register and merge there is an issue when I run

registrar = registration.Valis(str(d), dst_dir, feature_detector_cls=OrbVggFD_low_fd, imgs_ordered=True, crop= "overlap")
rigid_registrar, non_rigid_registrar, error_df = registrar.register()

the error I get is raise LinAlgError("SVD did not converge") numpy.linalg.LinAlgError: SVD did not converge

Will send you images tomorrow.

snackthingy commented 1 week ago

Hi @andreevg04,

I think the issue with numpy is probably because you didn't delete the files that were generated on a previous attempt of running the code? I ran into this problem too and when I deleted the files that got generated and ran the code again, it worked. Maybe this will help?

Regards, Snack

andreevg04 commented 1 week ago

@cdgatenbee I sent you a google drive link to the images. @snackthingy thank you for the suggestion, it worked like you said.

andreevg04 commented 17 hours ago

@cdgatenbee @snackthingy Is there any progress regarding the images I sent you Chandler?