-
Notifications
You must be signed in to change notification settings - Fork 28
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
Add support for pixel trigger acquisition in quantumdetector reader #235
Add support for pixel trigger acquisition in quantumdetector reader #235
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #235 +/- ##
==========================================
+ Coverage 86.36% 86.39% +0.03%
==========================================
Files 83 83
Lines 10604 10632 +28
Branches 2307 2316 +9
==========================================
+ Hits 9158 9186 +28
Misses 930 930
Partials 516 516 ☔ View full report in Codecov by Sentry. |
4d38ff2
to
c11b54a
Compare
c11b54a
to
126e26c
Compare
@magnunor, since you mentioned that you are "very interested" in this feature (#219 (comment)), can you please review it? If not, I will merge it. |
@ericpre, very nice! I'll have a look at this, and test it on some of my datasets. Probably tomorrow. |
I tested this on a number of datasets, and it seems to work nicely! In the current |
I have some more feedback, but I won't have time to do it before Thursday. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One thing which is missing is either i) a better error message when the navigation shape is missing, and the automatic navigation-shape-guesser doesn't work, or ii) better handling of mib-files where the navigation shape is unknown.
For example, I have file where the HDR-file says 'Frames in Acquisition (Number)': '0'
, and where there are no flyback pixels. Currently the error message is a bit cryptic: ValueError: cannot reshape array of size 0 into shape (256,256)
For ii), it should be possible to estimate the number of frames based on the size of the file, header size, number of chips and dtype. It could then return a 3D array.
Thanks @magnunor for the review. If this PR doesn't introduce any regression, I think that it would be useful to merge it to include it in the next release.
Most of the time, the
Do you know in what situation does this occur? I am wondering if there is some buggy/corrupted file or if this actually corresponding to a specific use case. If so, it would be useful to add a comment about it in the code. Assuming this should be with single frame files, there are already some of these file in the test suite and the tests are still passing?
The number of frames is already known from the code, how do you think this information should be used for reshaping purposes? |
@magnunor, the |
Based on testing this PR on a number of datasets, I don't think there are any regressions.
One case could be where flyback was not used, meaning all the pixels have the same frame time. Another case could be where the acquisition was interrupted. On some older datasets, it seems like the HDR file has a higher number ('Frames in Acquisition (Number)':) than the actual data in the MIB-file. Here is an example of such a file: https://filesender.sikt.no/?s=download&token=91e8ff4b-dda8-4cb8-997b-0504d7edaca2 (the link will expire 20. april)
I am actually not sure when the 'Frames in Acquisition (Number)': '0' occurs. The file is not single-frame. This is a dataset from 2018, so an older version of the Merlin software.
Looking a bit closer at this, it seems like the part which is checking for the number of frames in the rosettasciio/rsciio/quantumdetector/_api.py Line 276 in 4f2d78e
However, these issues also happen in the current |
4f2d78e
to
6b33702
Compare
Okay, but in that case, this is no way to estimate the navigation shape and it needs to be provided by the users. By default the current implementation will return a navigation_shape of (number_of_frames, ).
I checked the merlin manual, it seems that it may correspond to a case where the acquisition is set to be "continuous and indefinite". The wording is not exactly as the one of used in the hdr file but it seems to make sense to a certain extent!
This was a bug in the code to reshape in case of interrupted acquisition - this should be fixed now. Can you confirm that the dataset you shared here have 5 pixels per line? |
This should be ready for merging now! Very nice improvements to the MIB-reader :)
Indeed! Ignore the things I was writing about that, due to the bug you fixed this is no longer relevant.
I think for this specific dataset, things are a bit strange. These frames should be from a single line. But the array([-8.66666667, -8.66666667, -8.66666667, -8.66666667, 1.33333333,
1.33333333, 1.33333333, 1.33333333, 1.33333333, 1.33333333,
1.33333333, 1.33333333, 1.33333333, 1.33333333, 1.33333333,
1.33333333, 1.33333333, 1.33333333, 1.33333333, 1.33333333,
1.33333333, 1.33333333, 1.33333333, 1.33333333, 1.33333333,
1.33333333, 1.33333333, 1.33333333, 1.33333333, 1.33333333]) But I don't expect the file reader to be able to handle the navigation shape in strange datasets such as these. What was annoying earlier was that the data wasn't loading at all, but with the bug fix it loads just nicely :) |
6b33702
to
468482c
Compare
Okay, thank you, I fixed the typos in the test name, we should be all good now! |
Fix first item of #219.
Progress of the PR
upcoming_changes
folder (seeupcoming_changes/README.rst
),docs/readthedocs.org:rosettasciio
build of this PR (link in github checks)