-
Notifications
You must be signed in to change notification settings - Fork 52
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
Import SAXSLAB Ganesha tiff files containing both headers #336
Comments
Hi. Do you have any question? I mean, if it is working with PIL, it's fine no? Why would you need to convert it to fabio? |
Here is what we have with fabio. There is not much, IFAIK
|
But if you want to hack the code, you could take a look at the way fabio manage the Pilatus TIFF images. Here is a way to enforce using this reader.
The code is inside |
Indeed, I can make it work with PIL. |
Oh, I was looking at the TIFFIO.py for a while now. Where I found the |
No you was right. Everything is inside I check and you have to update the tag info (maybe not needed) And update
and
Yet it is not easy to custom. I think it would be great to create a kind of TAG_INFO that we could patch manually, in case. |
This was helpful. Basically, the main issue was name 'artist', I had just made something up there which apparently didn't work. But now it's great. How did you inspect that it had to be TAG_ARTIST? Added the following to TiffIO.py:
and added this to
It's probably cleaner to do the HTML parsing at another location, but now I can use my original import routine and
and obviously Just the question remains what happens if one opens a non-SAXSLAB/Ganesha Tiff now. |
Cause 315, from your code, is the artist tag: https://www.awaresystems.be/imaging/tiff/tifftags/artist.html
If you want to provide a PR for the patch of TiffIO, i can try to look at it. Obviously the HTML parsing have to stay on your side, as it have nothing to do with pilatus, if i understand well. |
So how to go about it? Although it's mainly tweaking |
Actually, maybe both would be good.
Only question is then how to determine that it's using |
I think exposing the artist tag is enough. Creating and maintaining a |
Hi there, I don't agree with you Valentin: Creating a GaneshaImage class deriving from TiffImage (or PilatusImage) is probably the way to go (even if ESRF has no direct interest in supporting SAXSLAB hardware). FabIO has been built to support all kind of X-ray detectors to allow people to do better science by removing the burden of parsing the data files. So, Matthias, could you please help us in submit a pull-request for this feature. I promise I will take some time to help you on the way. Then comes the issue of how to distinguish the file from a "basic" tiff of from another coming from a Pilatus detector ... I will have to think about it |
@kif so to clarify, you think I should follow my suggested approach:
|
Yes, sounds good. Next we could find a way to autodetect the |
I recently revisited this. And turned out SAXSLab introduces double entries (e.g. 'detector_dist') which lead to undesired behavior for the HTMLparser in retrieving the meta data as a dict (I don't know if this behavior is peculiar to our device/setup or standard). I have now improved the HTMLparser to deal with double entries. In case those are not mere double entries but the values are actually different, this is now raised with the user, but meta data extraction proceeds with the first value encountered.
|
Hi, I am now facing the pain to modify every fabio installation of my colleagues to make the Ganesha patch work for them, too. Therefore, I'd like to work a bit on getting this into the main functionality of fabio. Is there now a more clearer picture on where I should put that functionality? I am currently trying a monkey patch, which already gives me some insight into the fabio package. But I think I would need some guidance on how to proceed with this please. |
Monkey-patching is great, but only for quick fixes. It hardly ever scales (gevent :þ). The best is always to have the code properly written somewhere so that it can be debugged when needed. About the localization of your code: create a new class deriving from TifImage or PilatusImage in a new file. PilatusImage is deriving TifImage so you can do the same. Then write a test to ensure it works. Sounds obvious but python version are changing, ... so ensuring non regression is essential to be future proof. It does not guarantee the compatibility with the future but at least we will be warned when it fails. Once this is done, you file will not be "auto-magically" be recognized by |
I am using pyfai for my datareduction of SAXSLAB Ganesha / pilatus tiff files and, thus, fabio for the image import.
The tiff-file contains two sets of x-ray relevant meta data tags. One for the pilatus detector saved in tag 270 and one for the SAXSLAB machine data which is provided in a html format.
Using PIL I found that the SAXSLAB html meta data is saved in tag 315.
I also managed to parse the html meta data into a dict. However, I am not familiar enough with fabio (but I am willing to learn) to inject this so that I can expose a complemented header consisting of both the Pilatus meta data and the SAXSLAB meta data in
fabio.tifimage.TifImage.header
.Here is my code to parse the SAXSLAB meta data using PIL instead of fabio.
which returns:
Here is a link to a dummy SAXSLAB Ganesha file: Dummy.tiff
The text was updated successfully, but these errors were encountered: