MathOnco / valis

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

Specify Channel Order When Merging #156

Closed ewestlundicr closed 2 weeks ago

ewestlundicr commented 2 weeks ago

Hi,

I have a question regarding the channel orders when you merge multichannel images together.

I have imaged the same region 4 times, that is 4 cycles of the same region with different fluorescence markers. In each cycle, I have DAPI + 3 unique markers. I have set cycle 1 as the reference image.

The alignment looks great, but I have noticed an issue when I have repeated the process for multiple images - the channels are added in different orders in the different alignments.

So, for one merged image, the channels are ordered as cycle 3, cycle 4, cycle 1, cycle 2 whilst on the next image the order is cycle 1, cycle 2, cycle 3, cycle 4. (See image at the bottom.)

I was wondering if there is a way to specify in which order you want the channels to be in as this mix-match of orders creates issues when analysing the images later, or what is determining in which order the cycles end up.

Valis_Image1 Valis_Image2

Thank you in advance

cdgatenbee commented 2 weeks ago

Hi @ewestlundicr, Thanks for the question, I think it's probably one that many others will have. The reason the order isn't consistent is because valis sorts the images so that the most similar ones are adjacent (although you can specify the order if you prefer), and then merges them in that same order. However, you should be able to specify the order to merge the files using the src_f_list argument in Valis.warp_and_merge_slides, as the images will be merged in the same order as the list, as opposed to their similarity order. For example, setting registrar.warp_and_merge_slides(dst_f="merged.ome.tiff", src_f_list=["cycle1.tif", "cycle2.tif", "cycle3.tif". "cycle4.tif"]) should merge all of the cycles in order. Please try that out and let me know how it goes.

Best, -Chandler

ewestlundicr commented 2 weeks ago

Thank you very much!

Works like a charm :D