Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

list index out of range #96

Open
dr-sayyadhury opened this issue Jan 25, 2024 · 5 comments
Open

list index out of range #96

dr-sayyadhury opened this issue Jan 25, 2024 · 5 comments

Comments

@dr-sayyadhury
Copy link

dr-sayyadhury commented Jan 25, 2024

Hi there,

I am running into lots of issues with trying to save the output after image registration. I finally thought i fixed it when i made sure the initial images that I used for registration were of the 'ome-tiff' format. And I can see that its converting the slide to an image (which has never hapenned berfore). BUt now it seems to indicate an error in the series and it says list index out of rnage.

Below is the error message and after which, I have written my code...Would be really grateful if you can help me with this.

Many thanks.


Error

Attributes of one: ['M', 'class', 'delattr', 'dict', 'dir', 'doc', 'eq', 'format', 'ge', 'getattribute', 'gt', 'hash', 'init', 'init_subclass', 'le', 'lt', 'module', 'ne', 'new', 'reduce', 'reduce_ex', 'repr', 'setattr', 'sizeof', 'slotnames', 'str', 'subclasshook', 'weakref', '_bk_dxdy_f', '_bk_dxdy_np', '_fwd_dxdy_f', '_fwd_dxdy_np', 'aligned_slide_shape_rc', 'bg_color', 'bg_px_pos_rc', 'bk_dxdy', 'check_if_empty', 'crop', 'fixed_slide', 'fwd_dxdy', 'get_aligned_to_ref_slide_crop_xywh', 'get_bg_color_px_pos', 'get_bk_dxdy', 'get_crop_method', 'get_crop_xywh', 'get_displacement_f', 'get_fwd_dxdy', 'get_overlap_crop_xywh', 'image', 'img_type', 'is_empty', 'is_rgb', 'name', 'non_rigid_reg_img_f', 'non_rigid_reg_mask', 'nr_rigid_reg_img_f', 'original_xml', 'processed_img', 'processed_img_f', 'processed_img_shape_rc', 'reader', 'reg_img_shape_rc', 'resolution', 'rigid_reg_img_f', 'rigid_reg_mask', 'series', 'set_bk_dxdy', 'set_fwd_dxdy', 'slide2image', 'slide2vips', 'slide_dimensions_wh', 'slide_shape_rc', 'src_f', 'stack_idx', 'stored_dxdy', 'units', 'update_results_img_paths', 'val_obj', 'warp_and_save_slide', 'warp_geojson', 'warp_geojson_from_to', 'warp_img', 'warp_img_from_to', 'warp_slide', 'warp_xy', 'warp_xy_from_to', 'xy_in_prev', 'xy_in_prev_in_bbox', 'xy_matched_to_prev', 'xy_matched_to_prev_in_bbox']
Converting slide to pyvips image
100%|██████████| 1521/1521 [03:46<00:00, 6.71it/s]
No series provided. Selecting series with largest image, which is series 0
No series provided. Selecting series with largest image, which is series 0
An error occurred with slide one: list index out of range
Attributes of C03030A6_dup1: ['M', 'class', 'delattr', 'dict', 'dir', 'doc', 'eq', 'format', 'ge', 'getattribute', 'gt', 'hash', 'init', 'init_subclass', 'le', 'lt', 'module', 'ne', 'new', 'reduce', 'reduce_ex', 'repr', 'setattr', 'sizeof', 'slotnames', 'str', 'subclasshook', 'weakref', '_bk_dxdy_f', '_bk_dxdy_np', '_fwd_dxdy_f', '_fwd_dxdy_np', 'aligned_slide_shape_rc', 'bg_color', 'bg_px_pos_rc', 'bk_dxdy', 'check_if_empty', 'crop', 'fixed_slide', 'fwd_dxdy', 'get_aligned_to_ref_slide_crop_xywh', 'get_bg_color_px_pos', 'get_bk_dxdy', 'get_crop_method', 'get_crop_xywh', 'get_displacement_f', 'get_fwd_dxdy', 'get_overlap_crop_xywh', 'image', 'img_type', 'is_empty', 'is_rgb', 'name', 'non_rigid_reg_img_f', 'non_rigid_reg_mask', 'nr_rigid_reg_img_f', 'original_xml', 'processed_img', 'processed_img_f', 'processed_img_shape_rc', 'reader', 'reg_img_shape_rc', 'resolution', 'rigid_reg_img_f', 'rigid_reg_mask', 'series', 'set_bk_dxdy', 'set_fwd_dxdy', 'slide2image', 'slide2vips', 'slide_dimensions_wh', 'slide_shape_rc', 'src_f', 'stack_idx', 'stored_dxdy', 'units', 'update_results_img_paths', 'val_obj', 'warp_and_save_slide', 'warp_geojson', 'warp_geojson_from_to', 'warp_img', 'warp_img_from_to', 'warp_slide', 'warp_xy', 'warp_xy_from_to', 'xy_in_prev', 'xy_in_prev_in_bbox', 'xy_matched_to_prev', 'xy_matched_to_prev_in_bbox']
Converting slide to pyvips image
100%|██████████| 441/441 [00:22<00:00, 19.65it/s]
No series provided. Selecting series with largest image, which is series 0
No series provided. Selecting series with largest image, which is series 0
An error occurred with slide C03030A6_dup1: list index out of range

code

from valis import registration
import os

Iterate over slides and inspect them

for slide_name, slide_obj in registrar.slide_dict.items():
try:
# Inspect the Slide object
print(f"Attributes of {slide_name}: {dir(slide_obj)}")

    # Replace the following line with the correct way to access metadata
    metadata = slide_obj.original_xml

    # Example warp and save operation (update as needed)
    dst_f = os.path.join(registered_slide_dst_dir, f"{slide_name}.ome.tiff")
    slide_obj.warp_and_save_slide(dst_f=dst_f, crop="overlap", level=0)

except Exception as e:
    print(f"An error occurred with slide {slide_name}: {e}")
@cdgatenbee
Copy link
Collaborator

Hi @dr-sayyadhury,
Sorry to hear you've been running into issues. I've just pushed an update (1.0.3), which should have more robust slide read/write methods, and may solve this issue. Could you please try updating valis to see if those fixes resolve this issue for you?

Best,
-Chandler

@dr-sayyadhury
Copy link
Author

dr-sayyadhury commented Jan 28, 2024 via email

@cdgatenbee
Copy link
Collaborator

Hi @dr-sayyadhury,
Glad to hear the update fixed one issue, but sorry you're having this other one. I'd be more than happy to take a look at some images to see if I can figure out what the problem is though. If you'd prefer to share them privately, you can send a link to my e-mail at Chandler[dot]Gatenbee[at]moffitt[dot]org.

Best,
-Chandler

@dr-sayyadhury
Copy link
Author

HI so sorry i took so long. I am running into new issues. Anyway, I finally found the time to put together a few images and just sent you an email.

Hope we can work this one out soon.

Thank you.

@cdgatenbee
Copy link
Collaborator

Hi @dr-sayyadhury,
Thank you for sharing the images! I'll take a look and see if I can figure out what is causing the issue.

Best,
-Chandler

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

No branches or pull requests

2 participants