-
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 reading mib
acquired with a given number of frame to skip per line
#272
base: main
Are you sure you want to change the base?
Conversation
b79ac3f
to
4a8edc2
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #272 +/- ##
==========================================
- Coverage 86.33% 86.20% -0.13%
==========================================
Files 83 83
Lines 10668 10692 +24
Branches 2330 2337 +7
==========================================
+ Hits 9210 9217 +7
- Misses 939 953 +14
- Partials 519 522 +3 ☔ View full report in Codecov by Sentry. |
mib
acquired with a given number of frame to skip per line
Thanks @emichr. As mentioned in #270 (comment), the logic needs to take into account interrupted acquisition. Can you make and add small test files to cover this use case (and different number of frame to skip per line)? FAILED rsciio/tests/test_quantumdetector.py::test_interrupted_acquisition - assert (9,) == (4, 2)
FAILED rsciio/tests/test_quantumdetector.py::test_non_square[navigation_shape1] - assert (4, 2) == (8,)
FAILED rsciio/tests/test_quantumdetector.py::test_first_last_frame_8[kwargs0-navigation_shape1] - assert (8,) == (4, 2)
FAILED rsciio/tests/test_quantumdetector.py::test_first_last_frame_8[kwargs1-navigation_shape1] - assert (8,) == (4, 2)
FAILED rsciio/tests/test_quantumdetector.py::test_first_last_frame_8[kwargs2-navigation_shape1] - assert (8,) == (4, 2)
FAILED rsciio/tests/test_quantumdetector.py::test_first_last_frame_8[kwargs3-navigation_shape1] - assert (8,) == (4, 2)
FAILED rsciio/tests/test_quantumdetector.py::test_first_last_frame_8[kwargs4-navigation_shape1] - assert (8,) == (4, 2)
FAILED rsciio/tests/test_quantumdetector.py::test_first_last_frame_8[kwargs5-navigation_shape1] - assert (8,) == (4, 2)
FAILED rsciio/tests/test_quantumdetector.py::test_first_last_frame_8[kwargs6-navigation_shape1] - assert (8,) == (4, 2)
FAILED rsciio/tests/test_quantumdetector.py::test_navigation_shape_list_error - Failed: DID NOT RAISE <class 'TypeError'> |
Sure, I'll look into it as soon as possible! |
4a8edc2
to
3b6b7c7
Compare
@ericpre There was a bug in my PR that caused the tests to fail. I fixed the bug and it should run fine now - sorry for not checking sooner! I plan on making some test data soon with the updated Merlin software with various linetriggers, but it will take some time. |
This sounds good. Are you okay with including the test file as part of the PR? I would like to review with the test file. When you make the test file, can you also make one with interrupted acquisition? Would it make sense to actually skip the frame(s) (by slicing the data array in the right place?), instead of increasing the navigation shape? |
Read navigation shape of .mib files from .hdr Added a function to read the navigation shape and any eventual lineskips of a .mib dataset from the corresponding .hdr file. In case the data contains more frames than expected from the .hdr scan shape, the scan shape is compared to the number of frames to see if an integer number of frames are skipped per line (i.e. a lineskip>0 was used when acquiring the data). If a mismatch is detected, the function returns None rather than doing a best guess (the data is most likely incomplete, but it is not certain whether frames are missing inside the scan or if the scan was stopped before it was finished. Also fixed some typos in various docstrings. Created 270.enhancements.rst
3b6b7c7
to
a4d40ba
Compare
I probably won't be able to make the test data files this week, so the tests will have to wait a bit. I'm okay with waiting for those and including them in the PR when ready.
Yes, that's a good idea. It required very little changes, and I think I found the right place to do it. Let me know if it's not the best way of doing it. |
Hello! Just want to say I am looking into a related issue with some .mib files. s = hs.load(file, navigation_shape=(514,512))
s = s.inav[:512,:] Thus manually trimming the lineskip! |
Hi @sivborg, great that you tested this! Perhaps it is better to just modify the docstring with this as an example (and possibly making a note in the documentation as well) instead of including my suggested code changes? What do you think @ericpre? |
A simple approach would be to specify the number of frames to skip, as mentioned in comment in #270 (comment). This would be more convenient for the user, rather having to remember/figure out where the add the additional frames. I don't remember the details, but I would expect that it could be implemented without loading the frames to skip, which would be more efficient, particularly when loading lazily. |
Description of the change
A few sentences and/or a bulleted list to describe and motivate the change:
Progress of the PR
upcoming_changes
folder (seeupcoming_changes/README.rst
),docs/readthedocs.org:rosettasciio
build of this PR (link in github checks)Minimal example of the bug fix or the new feature
SPEDSTEM_256x256_8cm_100pct.txt