Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into DataOrder-rebase
Browse files Browse the repository at this point in the history
  • Loading branch information
casperdcl committed Aug 19, 2024
2 parents 714434b + f25b198 commit 441135d
Show file tree
Hide file tree
Showing 17 changed files with 671 additions and 71 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,6 @@
__pycache__/
/Wrappers/Python/build/
/Wrappers/Python/cil/version.py
/build*
*.vscode*
*.egg*
9 changes: 5 additions & 4 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
* 24.x.x
- New Features:
- Added SVRG and LSVRG stochastic functions (#1625)
- Added SAG and SAGA stochastic functions (#1624)
- Allow `SumFunction` with 1 item (#1857)
- Added `labels` module with `ImageDimensionLabels`, `AcquisitionDimensionLabels`,`AcquisitionDimensions`, `AcquisitionTypes`, `UnitsAngles`, `FillTypes`. (#1692)
- Added `labels` module with `ImageDimensionLabels`, `AcquisitionDimensionLabels`,`AcquisitionDimensions`, `AcquisitionTypes`, `UnitsAngles`, `FillTypes` (#1692)
- Enhancements:
- Use ravel instead of flat in KullbackLeibler numba backend (#1874)
- Upgrade Python wrapper (#1873, #1875)
- Internal refactor: Replaced string-based label checks with enum-based checks for improved type safety and consistency (#1692)
- Bug fixes:
- `ImageData` removes dimensions of size 1 from the input array. This fixes an issue where single slice reconstructions from 3D data would fail due to shape mismatches (#1885)
- Make Binner accept accelerated=False (#1887)

* 24.1.0
- New Features:
Expand Down Expand Up @@ -35,9 +39,6 @@
- Merged the files `BlockGeometry.py` and `BlockDataContainer.py` in `framework` to one file `block.py`. Please use `from cil.framework import BlockGeometry, BlockDataContainer` as before (#1799)
- Bug fix in `FGP_TV` function to set the default behaviour not to enforce non-negativity (#1826).




* 24.0.0
- Update to new CCPi-Regularisation toolkit v24.0.0. This is a backward incompatible release of the toolkit.
- CIL plugin support for TIGRE version v2.6
Expand Down
4 changes: 3 additions & 1 deletion Wrappers/Python/cil/framework/acquisition_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
from .data_container import DataContainer
from .partitioner import Partitioner


class AcquisitionData(DataContainer, Partitioner):
'''DataContainer for holding 2D or 3D sinogram'''
__container_priority__ = 1
Expand Down Expand Up @@ -62,7 +63,8 @@ def __init__(self,
elif issubclass(type(array) , DataContainer):
array = array.as_array()
elif issubclass(type(array) , numpy.ndarray):
pass
# remove singleton dimensions
array = numpy.squeeze(array)
else:
raise TypeError('array must be a CIL type DataContainer or numpy.ndarray got {}'.format(type(array)))

Expand Down
8 changes: 4 additions & 4 deletions Wrappers/Python/cil/framework/acquisition_geometry.py
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@ class Parallel2D(SystemConfiguration):
def __init__ (self, ray_direction, detector_pos, detector_direction_x, rotation_axis_pos, units='units'):
"""Constructor method
"""
super(Parallel2D, self).__init__(dof=2, geometry = AcquisitionTypes.PARALLEL, units=units)
super(Parallel2D, self).__init__(dof=2, geometry=AcquisitionTypes.PARALLEL, units=units)

#source
self.ray.direction = ray_direction
Expand Down Expand Up @@ -518,7 +518,7 @@ class Parallel3D(SystemConfiguration):
def __init__ (self, ray_direction, detector_pos, detector_direction_x, detector_direction_y, rotation_axis_pos, rotation_axis_direction, units='units'):
"""Constructor method
"""
super(Parallel3D, self).__init__(dof=3, geometry = AcquisitionTypes.PARALLEL, units=units)
super(Parallel3D, self).__init__(dof=3, geometry=AcquisitionTypes.PARALLEL, units=units)

#source
self.ray.direction = ray_direction
Expand Down Expand Up @@ -803,7 +803,7 @@ class Cone2D(SystemConfiguration):
def __init__ (self, source_pos, detector_pos, detector_direction_x, rotation_axis_pos, units='units'):
"""Constructor method
"""
super(Cone2D, self).__init__(dof=2, geometry = AcquisitionTypes.CONE, units=units)
super(Cone2D, self).__init__(dof=2, geometry=AcquisitionTypes.CONE, units=units)

#source
self.source.position = source_pos
Expand Down Expand Up @@ -982,7 +982,7 @@ class Cone3D(SystemConfiguration):
def __init__ (self, source_pos, detector_pos, detector_direction_x, detector_direction_y, rotation_axis_pos, rotation_axis_direction, units='units'):
"""Constructor method
"""
super(Cone3D, self).__init__(dof=3, geometry = AcquisitionTypes.CONE, units=units)
super(Cone3D, self).__init__(dof=3, geometry=AcquisitionTypes.CONE, units=units)

#source
self.source.position = source_pos
Expand Down
32 changes: 11 additions & 21 deletions Wrappers/Python/cil/framework/data_container.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,6 @@ def size(self):
__container_priority__ = 1
def __init__ (self, array, deep_copy=True, dimension_labels=None,
**kwargs):
'''Holds the data'''

if type(array) == numpy.ndarray:
if deep_copy:
self.array = array.copy()
Expand Down Expand Up @@ -192,8 +190,6 @@ def reorder(self, order):
:param order: ordered list of labels from self.dimension_labels
:type order: list, sting
'''


try:
if len(order) != len(self.shape):
raise ValueError('The axes list for resorting must have {0} dimensions. Got {1}'.format(len(self.shape), len(order)))
Expand All @@ -220,7 +216,6 @@ def reorder(self, order):
else:
self.geometry.set_labels(dimension_labels_new)


def fill(self, array, **dimension):
'''fills the internal data array with the DataContainer, numpy array or number provided
Expand All @@ -243,10 +238,6 @@ def fill(self, array, **dimension):
return
if dimension == {}:
if isinstance(array, numpy.ndarray):
if array.shape != self.shape:
raise ValueError('Cannot fill with the provided array.' + \
'Expecting shape {0} got {1}'.format(
self.shape,array.shape))
numpy.copyto(self.array, array)
elif isinstance(array, Number):
self.array.fill(array)
Expand Down Expand Up @@ -543,7 +534,6 @@ def sapyb(self, a, y, b, out=None, num_threads=NUM_THREADS):
ax = self * a
y.multiply(b, out=out)
out.add(ax, out=out)

return out

def _axpby(self, a, b, y, out, dtype=numpy.float32, num_threads=NUM_THREADS):
Expand Down Expand Up @@ -629,19 +619,19 @@ def _axpby(self, a, b, y, out, dtype=numpy.float32, num_threads=NUM_THREADS):
ctypes.POINTER(ctypes.c_float), # pointer to the second array
ctypes.POINTER(ctypes.c_float), # pointer to the third array
ctypes.POINTER(ctypes.c_float), # pointer to A
ctypes.c_int, # type of type of A selector (int)
ctypes.c_int, # type of type of A selector (int)
ctypes.POINTER(ctypes.c_float), # pointer to B
ctypes.c_int, # type of type of B selector (int)
ctypes.c_longlong, # type of size of first array
ctypes.c_int, # type of type of B selector (int)
ctypes.c_longlong, # type of size of first array
ctypes.c_int] # number of threads
cilacc.daxpby.argtypes = [ctypes.POINTER(ctypes.c_double), # pointer to the first array
ctypes.POINTER(ctypes.c_double), # pointer to the second array
ctypes.POINTER(ctypes.c_double), # pointer to the third array
ctypes.POINTER(ctypes.c_double), # type of A (c_double)
ctypes.c_int, # type of type of A selector (int)
ctypes.POINTER(ctypes.c_double), # type of B (c_double)
ctypes.c_int, # type of type of B selector (int)
ctypes.c_longlong, # type of size of first array
cilacc.daxpby.argtypes = [ctypes.POINTER(ctypes.c_double), # pointer to the first array
ctypes.POINTER(ctypes.c_double), # pointer to the second array
ctypes.POINTER(ctypes.c_double), # pointer to the third array
ctypes.POINTER(ctypes.c_double), # type of A (c_double)
ctypes.c_int, # type of type of A selector (int)
ctypes.POINTER(ctypes.c_double), # type of B (c_double)
ctypes.c_int, # type of type of B selector (int)
ctypes.c_longlong, # type of size of first array
ctypes.c_int] # number of threads

if f(x_p, y_p, out_p, a_p, a_vec, b_p, b_vec, ndx.size, num_threads) != 0:
Expand Down
4 changes: 2 additions & 2 deletions Wrappers/Python/cil/framework/image_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@ def __init__(self,
elif issubclass(type(array) , DataContainer):
array = array.as_array()
elif issubclass(type(array) , numpy.ndarray):
pass
# remove singleton dimensions
array = numpy.squeeze(array)
else:
raise TypeError('array must be a CIL type DataContainer or numpy.ndarray got {}'.format(type(array)))

Expand Down Expand Up @@ -190,7 +191,6 @@ def apply_circular_mask(self, radius=0.99, in_place=True):

return image_data_out


def reorder(self, order):
'''
Reorders the data in memory as requested. This is an in-place operation.
Expand Down
2 changes: 1 addition & 1 deletion Wrappers/Python/cil/framework/processors.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,11 +153,11 @@ def __call__(self, x, out=None):

return out


class DataProcessor(Processor):
'''Basically an alias of Processor Class'''
pass


class DataProcessor23D(DataProcessor):
'''Regularizers DataProcessor
'''
Expand Down
1 change: 1 addition & 0 deletions Wrappers/Python/cil/framework/vector_geometry.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

from .labels import FillTypes


class VectorGeometry:
'''Geometry describing VectorData to contain 1D array'''
@property
Expand Down
Loading

0 comments on commit 441135d

Please sign in to comment.