MathOnco / valis

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

warp and save slides failing #52

Closed Gibbsdavidl closed 1 year ago

Gibbsdavidl commented 1 year ago

Hi there,

I'm registering 7 tiffs following the examples given in the readthedocs, but the script is failing at the warp and save slides step.
It's failing in both warp_and_save_slides and warp_and_merge_slides attempts.

For merging, I'm creating a channel dictionary in (nearly) the same way, so each file in registrar.original_img_list has a channel name. Not sure what's going wrong.

Thank you!!

========================================================================= ERROR FOR warp and save slides:

11%|████████████ | 1/9 [01:40<13:22, 100.32s/it]/users/dgibbs/anaconda3/envs/valis_env/lib/python3.9/site-packages/valis/slide_io.py:1587: FutureWarning: Unlike other reduction functions (e.g. skew, kurtosis), the default behavior of mode typically preserves the axis it acts along. In SciPy 1.11.0, this behavior will change: the default value of keepdims will become False, the axis over which the statistic is taken will be eliminated, and the value None will no longer be accepted. Set keepdims to True or False to avoid this warning. most_common_channel_count = stats.mode(all_channels)[0][0] 11%|████████████ | 1/9 [01:40<13:23, 100.46s/it] Traceback (most recent call last): File "/users/dgibbs/code/valis_code/valis_reg.py", line 20, in registrar.warp_and_save_slides(reg_slide_dst_f, crop="overlap") File "/users/dgibbs/anaconda3/envs/valis_env/lib/python3.9/site-packages/valis/valtils.py", line 29, in wrapper return f(*args, kwargs) File "/users/dgibbs/anaconda3/envs/valis_env/lib/python3.9/site-packages/valis/registration.py", line 4332, in warp_and_save_slides slide_obj.warp_and_save_slide(dst_f=dst_f, level = level, File "/users/dgibbs/anaconda3/envs/valis_env/lib/python3.9/site-packages/valis/valtils.py", line 29, in wrapper return f(*args, *kwargs) File "/users/dgibbs/anaconda3/envs/valis_env/lib/python3.9/site-packages/valis/registration.py", line 983, in warp_and_save_slide ome_xml_obj = slide_io.update_xml_for_new_img(current_ome_xml_str=slide_meta.original_xml, File "/users/dgibbs/anaconda3/envs/valis_env/lib/python3.9/site-packages/valis/valtils.py", line 29, in wrapper return f(args, kwargs) File "/users/dgibbs/anaconda3/envs/valis_env/lib/python3.9/site-packages/valis/slide_io.py", line 2644, in update_xml_for_new_img temp_new_ome = create_ome_xml(new_xyzct, bf_dtype, is_rgb, pixel_physical_size_xyu, channel_names, colormap=colormap) File "/users/dgibbs/anaconda3/envs/valis_env/lib/python3.9/site-packages/valis/valtils.py", line 29, in wrapper return f(*args, **kwargs) File "/users/dgibbs/anaconda3/envs/valis_env/lib/python3.9/site-packages/valis/slide_io.py", line 2568, in create_ome_xml channels = [create_channel(i, name=channel_names[i], color=colormap[channel_names[i]]) for i in range(c)] File "/users/dgibbs/anaconda3/envs/valis_env/lib/python3.9/site-packages/valis/slide_io.py", line 2568, in channels = [create_channel(i, name=channel_names[i], color=colormap[channel_names[i]]) for i in range(c)] KeyError: 'None'

============================================================================= ERROR FOR warp and merge slides:

..... ==== Performing microregistration

100%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████| 8/8 [01:58<00:00, 14.81s/it]

======== Non-rigid registration complete in 1.989 minutes

==== Measuring error

100%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████| 9/9 [00:05<00:00, 1.59it/s]

/users/dgibbs/anaconda3/envs/valis_env/lib/python3.9/site-packages/valis/slide_io.py:1587: FutureWarning: Unlike other reduction functions (e.g. skew, kurtosis), the default behavior of mode typically preserves the axis it acts along. In SciPy 1.11.0, this behavior will change: the default value of keepdims will become False, the axis over which the statistic is taken will be eliminated, and the value None will no longer be accepted. Set keepdims to True or False to avoid this warning.

most_common_channel_count = stats.mode(all_channels)[0][0]

Traceback (most recent call last): File "/users/dgibbs/code/valis_code/valis_merge.py", line 33, in merged_img, channel_names, ome_xml = registrar.warp_and_merge_slides(merged_slide_dst_f, File "/users/dgibbs/anaconda3/envs/valis_env/lib/python3.9/site-packages/valis/valtils.py", line 29, in wrapper return f(*args, **kwargs) File "/users/dgibbs/anaconda3/envs/valis_env/lib/python3.9/site-packages/valis/registration.py", line 4442, in warp_and_merge_slides keep_channels = [warped_slide[c] for c in keep_idx] File "/users/dgibbs/anaconda3/envs/valis_env/lib/python3.9/site-packages/valis/registration.py", line 4442, in keep_channels = [warped_slide[c] for c in keep_idx] File "/users/dgibbs/anaconda3/envs/valis_env/lib/python3.9/site-packages/pyvips/vimage.py", line 1418, in getitem i = range(self.bands)[arg] IndexError: range object index out of range

Gibbsdavidl commented 1 year ago

Going to try converting them to ome.tiffs first.

Gibbsdavidl commented 1 year ago

After converting the images to ome.tiffs with bfconvert, it made it through one file, but then crashed again:

==== Measuring error

100%|██████████████████████████████████████████████████████████████████████████████████████████| 9/9 [00:05<00:00, 1.59it/s] 0%| | 0/9 [00:00<?, ?it/s]Converting slide to pyvips image 100%|████████████████████████████████████████████████████████████████████████████████████| 240/240 [00:00<00:00, 1290.72it/s]saving /users/dgibbs/res0/img/ctl_indiv/reg/20230322_9-968277_FLC_72hCTL-2_2C_B01_w4.ome.tiff (39205 x 38957 and 1 channels)] [====================================================================================================] 100.0% in 1.031 minute[====================================================================================================] 100.0% in 1.347 minutes Complete

11%|██████████ | 1/9 [01:26<11:33, 86.74s/it]Converting slide to pyvips image 100%|█████████████████████████████████████████████████████████████████████████████████████| 240/240 [00:00<00:00, 323676.19it/s] 11%|██████████ | 1/9 [01:29<11:58, 89.80s/it]/s] Traceback (most recent call last): File "/users/dgibbs/code/valis_code/valis_reg.py", line 18, in registrar.warp_and_save_slides(reg_slide_dst_f, crop="overlap") File "/users/dgibbs/anaconda3/envs/valis_env/lib/python3.9/site-packages/valis/valtils.py", line 29, in wrapper return f(*args, kwargs) File "/users/dgibbs/anaconda3/envs/valis_env/lib/python3.9/site-packages/valis/registration.py", line 4332, in warp_and_save_slides slide_obj.warp_and_save_slide(dst_f=dst_f, level = level, File "/users/dgibbs/anaconda3/envs/valis_env/lib/python3.9/site-packages/valis/valtils.py", line 29, in wrapper return f(*args, *kwargs) File "/users/dgibbs/anaconda3/envs/valis_env/lib/python3.9/site-packages/valis/registration.py", line 983, in warp_and_save_slide ome_xml_obj = slide_io.update_xml_for_new_img(current_ome_xml_str=slide_meta.original_xml, File "/users/dgibbs/anaconda3/envs/valis_env/lib/python3.9/site-packages/valis/valtils.py", line 29, in wrapper return f(args, kwargs) File "/users/dgibbs/anaconda3/envs/valis_env/lib/python3.9/site-packages/valis/slide_io.py", line 2644, in update_xml_for_new_img temp_new_ome = create_ome_xml(new_xyzct, bf_dtype, is_rgb, pixel_physical_size_xyu, channel_names, colormap=colormap) File "/users/dgibbs/anaconda3/envs/valis_env/lib/python3.9/site-packages/valis/valtils.py", line 29, in wrapper return f(*args, **kwargs) File "/users/dgibbs/anaconda3/envs/valis_env/lib/python3.9/site-packages/valis/slide_io.py", line 2568, in create_ome_xml channels = [create_channel(i, name=channel_names[i], color=colormap[channel_names[i]]) for i in range(c)] File "/users/dgibbs/anaconda3/envs/valis_env/lib/python3.9/site-packages/valis/slide_io.py", line 2568, in channels = [create_channel(i, name=channel_names[i], color=colormap[channel_names[i]]) for i in range(c)] KeyError: 'None'

Looks like the same error as before.

Gibbsdavidl commented 1 year ago

resolved. not sure what the problem was. somehow the local environment was "bad".