Closed tbaudier closed 5 years ago
Hi @djboersma
I debug your unit test for image arithm: https://github.com/OpenGATE/GateTools/blob/34fc70a4f4dbe247516e12e3ff04631d67770c65/gatetools/image_arithm.py#L161
First https://github.com/OpenGATE/GateTools/blob/34fc70a4f4dbe247516e12e3ff04631d67770c65/gatetools/image_arithm.py#L112 you need to add the Update line like this:
op_instance.SetInput(i,img) op_instance.Update() return _image_output(op_instance.GetOutput(),output_file)
With itk, all filters need to be updated to create the output. This is why the unit test failed, the output did not exist and it created a segfault.
Next, I suggest you some modifications:
np.arrange(stop) function create an array from 0 to stop -1. So I suggest you to remove 1 to all your tests: https://github.com/OpenGATE/GateTools/blob/34fc70a4f4dbe247516e12e3ff04631d67770c65/gatetools/image_arithm.py#L167 https://github.com/OpenGATE/GateTools/blob/34fc70a4f4dbe247516e12e3ff04631d67770c65/gatetools/image_arithm.py#L169 https://github.com/OpenGATE/GateTools/blob/34fc70a4f4dbe247516e12e3ff04631d67770c65/gatetools/image_arithm.py#L174 https://github.com/OpenGATE/GateTools/blob/34fc70a4f4dbe247516e12e3ff04631d67770c65/gatetools/image_arithm.py#L180 https://github.com/OpenGATE/GateTools/blob/34fc70a4f4dbe247516e12e3ff04631d67770c65/gatetools/image_arithm.py#L185
np.arrange(stop)
https://github.com/OpenGATE/GateTools/blob/34fc70a4f4dbe247516e12e3ff04631d67770c65/gatetools/image_arithm.py#L167 I'm not sure the syntax .GetPixel((1,1)) is correct. You may consider to use:
index = imgCf.GetLargestPossibleRegion().GetSize() -1 self.assertTrue( imgCf.GetPixel(index) == 4.*5. -1.)
Adapt the sum filter to the input data adding
valtype=itk.US
into https://github.com/OpenGATE/GateTools/blob/34fc70a4f4dbe247516e12e3ff04631d67770c65/gatetools/image_arithm.py#L172 https://github.com/OpenGATE/GateTools/blob/34fc70a4f4dbe247516e12e3ff04631d67770c65/gatetools/image_arithm.py#L183
Remove sitk dependency https://github.com/OpenGATE/GateTools/blob/34fc70a4f4dbe247516e12e3ff04631d67770c65/gatetools/image_arithm.py#L103
Thomas
I think that this is all fixed now. Thanks! :+1:
Hi @djboersma
I debug your unit test for image arithm: https://github.com/OpenGATE/GateTools/blob/34fc70a4f4dbe247516e12e3ff04631d67770c65/gatetools/image_arithm.py#L161
First https://github.com/OpenGATE/GateTools/blob/34fc70a4f4dbe247516e12e3ff04631d67770c65/gatetools/image_arithm.py#L112 you need to add the Update line like this:
With itk, all filters need to be updated to create the output. This is why the unit test failed, the output did not exist and it created a segfault.
Next, I suggest you some modifications:
np.arrange(stop)
function create an array from 0 to stop -1. So I suggest you to remove 1 to all your tests: https://github.com/OpenGATE/GateTools/blob/34fc70a4f4dbe247516e12e3ff04631d67770c65/gatetools/image_arithm.py#L167 https://github.com/OpenGATE/GateTools/blob/34fc70a4f4dbe247516e12e3ff04631d67770c65/gatetools/image_arithm.py#L169 https://github.com/OpenGATE/GateTools/blob/34fc70a4f4dbe247516e12e3ff04631d67770c65/gatetools/image_arithm.py#L174 https://github.com/OpenGATE/GateTools/blob/34fc70a4f4dbe247516e12e3ff04631d67770c65/gatetools/image_arithm.py#L180 https://github.com/OpenGATE/GateTools/blob/34fc70a4f4dbe247516e12e3ff04631d67770c65/gatetools/image_arithm.py#L185https://github.com/OpenGATE/GateTools/blob/34fc70a4f4dbe247516e12e3ff04631d67770c65/gatetools/image_arithm.py#L167 I'm not sure the syntax .GetPixel((1,1)) is correct. You may consider to use:
Adapt the sum filter to the input data adding
into https://github.com/OpenGATE/GateTools/blob/34fc70a4f4dbe247516e12e3ff04631d67770c65/gatetools/image_arithm.py#L172 https://github.com/OpenGATE/GateTools/blob/34fc70a4f4dbe247516e12e3ff04631d67770c65/gatetools/image_arithm.py#L183
Remove sitk dependency https://github.com/OpenGATE/GateTools/blob/34fc70a4f4dbe247516e12e3ff04631d67770c65/gatetools/image_arithm.py#L103
Thomas