Skip to content

Write channel 2 registered tiffs to reg_tif_chan2 - #1261

Open
adityasingh2400 wants to merge 1 commit into
MouseLand:mainfrom
adityasingh2400:fix-reg-tif-chan2-path
Open

Write channel 2 registered tiffs to reg_tif_chan2#1261
adityasingh2400 wants to merge 1 commit into
MouseLand:mainfrom
adityasingh2400:fix-reg-tif-chan2-path

Conversation

@adityasingh2400

Copy link
Copy Markdown

When a two-channel recording is registered with both reg_tif and reg_tif_chan2 enabled, the second channel's tiffs are written into the first channel's directory and overwrite it. The reg_tif_chan2 folder is created but stays empty, and the tiffs left in reg_tif contain channel 2 data.

assign_reg_io already computes two separate tiff directories, tif_root_align for the alignment channel and tif_root_alt for the alternate one, and picks the right folder for each depending on align_by_chan2. registration_wrapper passes tif_root_align to register_frames, which is correct, but then passes tif_root_align again to the shift_frames_and_write call that handles the alternate channel. Both channels therefore write file 0000.tif into the same folder, and since the alternate channel is written second it wins. tif_root_alt was computed and never used.

The fix passes tif_root_alt to the alternate channel write. This also repairs the case where only reg_tif_chan2 is set, where tif_root_align is None and the alternate channel silently wrote no tiffs at all. The bug is symmetric under align_by_chan2, since the roles of the two folders swap but the wrong variable is used either way.

Tested with a new parametrised case in tests/test_registration.py. It runs registration_wrapper on an 8 frame 64 by 64 synthetic pair whose two channels differ by an order of magnitude in mean intensity, so the mean of a written tiff identifies which channel produced it, and asserts that each directory holds its own channel. Both parameter values fail on main, one because reg_tif_chan2 is empty and the other because reg_tif holds the wrong channel, and both pass with this change. The rest of the file still passes, 5 passed in total.

Fixes #1208

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

Successfully merging this pull request may close these issues.

BUG: Output overwrite when saving reg_tiff for 2 channels

1 participant