Absfunction sirf compatibility#2339
Draft
paskino wants to merge 2 commits into
Draft
Conversation
paskino
commented
Jun 12, 2026
Comment on lines
+176
to
+178
| rgeo = x.geometry.copy() | ||
| rgeo.dtype = real_dtype | ||
| r = rgeo.allocate(None) |
Contributor
Author
There was a problem hiding this comment.
Suggested change
| rgeo = x.geometry.copy() | |
| rgeo.dtype = real_dtype | |
| r = rgeo.allocate(None) | |
| r = x.geometry.allocate(None, dtype=real_dtype) |
paskino
commented
Jun 12, 2026
| out = out_geom.allocate(None) | ||
| out = x * 0 | ||
| if np.isreal(x.as_array()).all(): | ||
| print("Input is real, returning real output") |
Contributor
Author
There was a problem hiding this comment.
Suggested change
| print("Input is real, returning real output") |
paskino
commented
Jun 12, 2026
| print("Input is real, returning real output") | ||
| out.fill( np.real(fvals_np.astype(complex_dtype)*Phi)) | ||
| else: | ||
| print("Input is complex, returning complex output") |
Contributor
Author
There was a problem hiding this comment.
Suggested change
| print("Input is complex, returning complex output") |
paskino
commented
Jun 12, 2026
Comment on lines
+151
to
+153
| rgeo = x.geometry.copy() | ||
| rgeo.dtype = real_dtype | ||
| r = rgeo.allocate(0) |
Contributor
Author
There was a problem hiding this comment.
Suggested change
| rgeo = x.geometry.copy() | |
| rgeo.dtype = real_dtype | |
| r = rgeo.allocate(0) | |
| r = x.geometry.allocate(None, dtype=read_dtype) |
paskino
commented
Jun 12, 2026
| import numpy as np | ||
| from cil.optimisation.functions import Function | ||
| from cil.framework import DataContainer | ||
| from cil.framework import DataContainer, ImageGeometry |
Contributor
Author
There was a problem hiding this comment.
DataContainer is only needed for type-hints reasons.
paskino
commented
Jun 12, 2026
Comment on lines
+201
to
+203
| tmparr = tmp.as_array() | ||
| tmparr[tmparr < 0] = 0. | ||
| tmp.fill(tmparr) |
Contributor
Author
There was a problem hiding this comment.
Check: tmp is a CIL ImageData so this could be simplified as:
Suggested change
| tmparr = tmp.as_array() | |
| tmparr[tmparr < 0] = 0. | |
| tmp.fill(tmparr) | |
| tmp.array[tmp.array < 0] = 0. | |
Or check IndicatorBox
paskino
commented
Jun 12, 2026
| '''An internal function to find the type of x and set the corresponding real and complex data types ''' | ||
|
|
||
| x_dtype = x.as_array().dtype | ||
| x_dtype = x.dtype |
Contributor
Author
There was a problem hiding this comment.
@fmwatson does your data container have a dtype member?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Function of Abs has been developed for CIL like objects and fails when used with SIRF.
These changes allow using the functionality with SIRF MR ImageData.
Example Usage
Contribution Notes
❤️ Thanks for your contribution!
Changes
Testing you performed
Related issues/links
Checklist