punch-mission / regularizepsf

A Python package for manipulating and correcting variable point spread functions.
https://regularizepsf.readthedocs.io/en/latest/
Other
18 stars 4 forks source link

Working with microscopy images #58

Closed kvinicki closed 1 year ago

kvinicki commented 1 year ago

Hi,

I'm attempting to fix coma in microscopy images. I took an image of a calibration slide with a grid of points: blue

The image is originally in tif format. When trying to process it using find_stars_and_average(), I encounter errors.

When providing the image in fits format (after converting from tif):

    537 def _calculate_pad_shape(self, size: int) -> Tuple[int, int]:
    538     print(size, self.size)
--> 539     pad_amount = size - self.size
    540     if pad_amount < 0:
    541         raise InvalidSizeError(f"The average window size (found {size})" 
    542                                "must be larger than the existing patch size"
    543                                f"(found {self.size}).")

TypeError: unsupported operand type(s) for -: 'int' and 'NoneType'

When providing the image as a numpy array:


--> 406 background = sep.Background(image)
    407 image_background_removed = image - background
    408 image_star_coords = sep.extract(image_background_removed, 
    409                                 star_threshold, 
    410                                 err=background.globalrms,
    411                                 mask=star_mask)

File sep.pyx:415, in sep.Background.__cinit__()
File sep.pyx:313, in sep._parse_arrays()
File sep.pyx:227, in sep._get_sep_dtype()
ValueError: input array dtype not supported: uint16

However, when I use tests/data/DASH.fits as an input, the function works without any errors.

kvinicki commented 1 year ago

My mistake, I just had to set star_threshold=2.5

jmbhughes commented 1 year ago

Thanks for reaching out! So everything is working now?

You may run into a few other problems potentially, and I'd be happy to help with them. This package was initially intended for astronomical imaging systems, but it could certainly be used with other optical systems. You might benefit from a function other than find_stars_and_average because you already know the positions of all your calibration points. We'd just have to work together to write some utility functions for it.

Finally, if there's anything in your experience of using the package that you think could be explained more clearly, please let me know by opening an issue or discussion. We want to improve the ease of use for others.