MathOnco / valis

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

Error #149

Closed snackthingy closed 2 months ago

snackthingy commented 3 months ago

Hello,

I've been troubleshooting the package for a few weeks at this point and right when I thought I'd fixed everything, I get this message:

UnboundLocalError: local variable 'slide_obj' referenced before assignment

I know what this means but its sourced within files in the package so I know it's likely a prerequisite that I am missing? I installed Maven and a JVM system wide, then I installed pyvips and VALIS itself in a venv. Does anyone know which requisite I likely have messed up given this error?

The code I'm using is just the very basic registration model:

from valis import registration slide_src_dir = "/Users/User1/Desktop/Alignment Imgs/Test" results_dst_dir = "/Users/User1/Desktop/Reg" registered_slide_dst_dir = "/Users/User1/Desktop/Results"

registrar = registration.Valis(slide_src_dir, results_dst_dir) rigid_registrar, non_rigid_registrar, error_df = registrar.register()

I'm aligning .ome.tif images and I tried both exporting it with 1 file per z-layer--didnt work, so I tried keeping the .ome.tif compressed and still didn't work.

At this point I feel like I've tried a lot of things, downgraded and tested many different versions.

I would really appreciate any help you can give.

cdgatenbee commented 3 months ago

Hi @snackthingy, Sorry you've had so much trouble getting valis installed and running. The error you're seeing is more indicative that something is going wrong in the registration process, not necessarily that a package is missing. A slide_obj is created for each image at the very beginning of the process, so if this is occurring early, it may mean that there is an error reading the images. But, to rule out that there is an install issue, could you let me know if you are able to get the cycif example to work , using the example images, located here?

Best, -Chandler

snackthingy commented 3 months ago

Hey Chandler,

So the registration was completed without errors with the example data and code, but the files never appeared in the folders. Does it take time for them to appear or something?

snackthingy commented 3 months ago

Ok never mind the registration worked well (the merge did not thought).

cdgatenbee commented 3 months ago

I'm guessing it's an error with reading the images. Based on your description, it sounds like your ome.tiff is 3D, but could you tell me more about the images you want to register? Also, it could be that valis is trying to read your ome.tiff using libvips, but if it is 3D, maybe you need to use the bioformats slide reader, i.e. slide_io.BioFormatsSlideReader. You could try that by setting the reader_cls=slide_io.BioFormatsSlideReader argument when you call Valis.register:

from valis import registration, slide_io

registrar.register(reader_cls=slide_io.BioFormatsSlideReader)

Best, -Chandler

snackthingy commented 3 months ago

I tried using the bioformats slide reader and got the same error. My images are meant to be 2D ome-tiffs but they could have been accidentally saved as 3D? I converted them from CZI with ImageJ and used the BioFormat exporter there. They each have 2 ROIs (10 z-stacks per ROI so it says 20 when they're together and 10 when I crop one out) which I thought could've been creating an issue so I cropped one ROI out and tried just aligning that but got the same error.