-
Notifications
You must be signed in to change notification settings - Fork 3
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
Integrate padding into runner #446
Conversation
@dkazanc Only one method, |
Thanks Yousef, can you please check if you get an assertion error by running the following pipeline. Note the saving is enabled after the median filter, if the saving is disabled the pipeline works. I'll add the median enabled padding bit in a second. cheers
|
to the error above, it actually fails on the saving the 2nd intermediate data from FBP, not the one that is after median I believe.
|
Yep, I can reproduce the error mentioned. Looks like maybe the intermediate data wrapper doesn't deal with padded blocks correctly or something, I'll take a look, thanks for testing this out! FYI, for me, I can get rid of FBP and the error still appears. So on my end it looks like it happens on saving the last block that is outputted by the median filter:
The pipeline I used was adapted from your example to run on the test data, and removes the FBP method from the picture: - method: standard_tomo
module_path: httomo.data.hdf.loaders
parameters:
name: tomo
data_path: entry1/tomo_entry/data/data
image_key_path: entry1/tomo_entry/instrument/detector/image_key
rotation_angles:
data_path: /entry1/tomo_entry/data/rotation_angle
- method: find_center_vo
module_path: httomolibgpu.recon.rotation
parameters:
ind: mid
smin: -50
smax: 50
srad: 6
step: 0.25
ratio: 0.5
drop: 20
id: centering
side_outputs:
cor: centre_of_rotation
- method: normalize
module_path: httomolibgpu.prep.normalize
parameters:
cutoff: 10.0
minus_log: true
nonnegativity: false
remove_nans: true
- method: median_filter
module_path: httomolibgpu.misc.corr
parameters:
kernel_size: 5
dif: 0.0
save_result: true |
Oh yeah I see what you mean, I have to squint a bit at the second image, but I do see a fainter line still! I'll have a think/look and see if I can come up with anything to explain this unexpected behaviour - looks like the padding is sort of half working only... 😅 |
Also, the latest commit I pushed should have fixed the error when saving the last block. |
It would be nice to have a test that runs a method with padding on the whole region as a full 3D method and then also imitates the blocking with more processed padded blocks than needed. The the framework does it thing to unpad, etc., but the results of both approaches should be identical. |
Mmm, I had a similar thought when you shared the first pair of screenshots. It feels like, to have absolute confidence that the both the following produce the same result:
a test making assertions on arrays would be best, so then we don't have to rely on visual inspection. Idea for a testI was having a think about at what "level" would be the best place to test this. The objects that are involved in padded blocks have tests, and we need to be careful to not have this new test testing stuff that is already tested. My idea after an initial thought was that this could be a test for the task runner:
It would then be considered an integration test of the runner for padding I guess, which doesn't yet exist I think. And it avoids testing padding for the lower-level objects (like 3D method requiring padding that is used in the testAnother thing to mention is that, if possible, I'd prefer to not have to rely on a 3D method in some external package for testing padding. This is so then the test of the padding framework in httomo is independent of any methods backend. I'm not 100% sure if it'd work nicely, but if it did, would you be okay with the test defining a small 3D GPU method local to the test, that can be used? The wrapper in the section probably can be patched to use this dummy 3D method, and I reckon all the other stuff relating to the methods database can be fiddled with/mocked in order to get the wrapper in the test to execute this dummy 3D method? |
Yes, that sounds like a good solution. We don't need a 3D method for that indeed. We can simply randomly generate a 3D data first and a method that modifies this data, for instance, scaling or adding a number. If things will go wrong with the padding, I believe, we should be able to trace it only with that. But the input data must be random or the standard data we use. |
Ok cool, I'll get started on that test 🙂 (And it should fail at first, given the horizontal lines in the data shown earlier). One thing I'd like to clarify since I'm not sure now: I thought the dummy method in the test does have to be 3D, in the sense that it has to use the neighbourhood/padded slices in some way? I thought that if it doesn't use the padded slices, then there won't be any difference between:
The goal of the test is to be able to tell if the blocks have been padded correctly by the task runner, so I thought we need to be able to see the difference between those two cases? And there's only a difference between the two cases when the method is 3D? Or have I gotten things mixed up (which is quite possible, apologies)?... 😅 |
thanks @yousefmoazzam . Yes, I think by simply changing a value per pixel won't change anything as I think the stitching of the boundaries back to the original position is happening correctly at the moment (we do not see jumps in the image). So we need a 3D change indeed. The simplest could be a sum over 6+1(central) pixels if we consider |
Yeah I agree about the emphasis on having a simple 3D method in the test; while the method does need to be 3D, it doesn't need to be complex, just enough to ensure that a change of neighbourhood has a detectable effect on its output. What you suggested sounds like a good candidate, I'll give it a go 🙂 |
I can confirm that after the fix 0a3cd1a the lines disappeared. So visually all seem to work correctly and I hope that the test should pass. |
Note that this test currently makes some assumptions about the internals of the task runner in order to verify that the result of processing the padded blocks is as expected. See the code comments marked `NOTE` for more details.
Ok, apologies for being quiet after the integration test was added, I was investigating the two issues that are linked above:
I think the integration test is mostly ok, but I have added two notes marked If we feel that it's a bad way to test things we can always remove the test and try to think of better ways to do it (which probably requires some refactoring to get rid of the need to inspect internals of the task runner), since the horizontal lines were gone even before I wrote the test. Let me know what you think @dkazanc 🙂 |
Many thanks @yousefmoazzam. I think we can live with #453 in place for know as it mainly the issue of the small data? I've run tests, they all pass for me. Feel free to wrap up this PR. |
Yeah, I think #453 affects small data mostly. I agree that it can be left for later, so I'll merge this to wrap up the main integration of padding into the runner. |
This enables the task runner to load and process padded blocks.
Checklist