Open simomounir opened 2 months ago
Hi @simomounir,
So happy to hear you're finding valis useful! Could you tell me a little more about the other images you are trying to warp? If they're from the same slide as the DAPI one, then there is a method you can use to warp those images using the same transforms (example below). If not, it should still be possible, but would more complicated. Anyhow, here is an example of how to apply the parameters used to register the DAPI image (stored in the associated Slide
object) to warp a set of images whose filenames are defined in other_img_list
:
# Align DAPI images
registrar = registration.Valis(src_dir, dst_dir)
rigid_registrar, non_rigid_registrar, error_df = registrar.register()
# Warp images associated with "DAPI_1".
dapi_name = "DAPI_1"
dapi_slide = registrar.get_slide(dapi_name)
for img_f in other_img_list:
dst_f = os.path.join(slide_dst_dir, f"{valtils.get_name(img_f)}_warped.ome.tiff")
dapi_slide.warp_and_save_slide(src_f=img_f, dst_f=dst_f)
Hopefully that helps, but if it doesn't resolve your issue, please let me know.
Best, -Chandler
Hi @cdgatenbee!
I do not know how I missed this reply. Apologies.
So the DAPI images I am referring to come from different imaging cycles. I have a separate one-channel image DAPI_1 and another separate one-channel image DAPI_2. I am trying to align DAPI_2 against DAPI_1 and apply the transformation parameters on another third image, let's call it img_A.
I run this for now:
DAPI_1 and DAPI_2 are in src_dir ############################### registrar = registration.Valis(src_dir=slide_src_dir, dst_dir=results_dst_dir, reference_img_f=reference_img_file, align_to_reference=True, imgs_ordered=False)
rigid_registrar, non_rigid_registrar, error_df = registrar.register()
#################################
reference_img_file is DAPI_1 in this case. I want to non-rigidly register DAPI_2 to DAPI_1 and apply the same transform on img_A. How can I achieve that?
Thanks a lot in advance for your help :)
Hi @simomounir, As long as img_A is from the same tissue slice as DAPI_2 (or looks very, very similar), you could do the following:
# Align DAPI images
dapi_img_f_list = ["DAPI_1.tiff", "DAPI_2.tiff"]
registrar = registration.Valis(src_dir, dst_dir, reference_img_f="DAPI_1.tiff", img_list=dapi_img_f_list)
rigid_registrar, non_rigid_registrar, error_df = registrar.register()
# Warp image img_A, which is associated with "DAPI_2".
dapi_name = "DAPI_2.tiff"
dapi_slide = registrar.get_slide(dapi_name)
to_warp_img_f = "img_A.tiff"
dst_f = os.path.join(slide_dst_dir, f"{valtils.get_name(to_warp_img_f)}_warped.ome.tiff")
dapi_slide.warp_and_save_slide(src_f=to_warp_img_f, dst_f=dst_f)
Please try that out and let me know how it goes.
Best, -Chandler
Hi all,
I cannot thank you enough (again) for this software and letting us experiment with it. It is very resourceful and I see in it quite some potential.
My issue is: I am trying to align an image (DAPI_2) to a reference (DAPI_1). This first step goes fine, however I want to extract the transformation parameters (transformation matrix, rigid and non-rigid) and apply it on more images. I can try to align all my images by putting them in a folder and use DAPI_1 as reference, but something goes wrong and I noticed the alignment was not well performed, plus it might be computationally intensive taking into consideration the size of the images I am using.
How can I achieve this?
Thanks a lot in advance.
Cheers.