Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
IP
elsa
Commits
b72053f6
Commit
b72053f6
authored
Apr 25, 2022
by
AndiBraimllari
Browse files
Merge branch 'master' into metrics
parents
309ca2f9
77b23415
Pipeline
#880816
passed with stages
in 19 minutes and 32 seconds
Changes
6
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
elsa/core/DataContainer.cpp
View file @
b72053f6
...
...
@@ -11,6 +11,7 @@
#include "Assertions.h"
#include <utility>
#include <algorithm>
namespace
elsa
{
...
...
@@ -609,6 +610,22 @@ namespace elsa
}
}
template
<
typename
data_t
>
DataContainer
<
data_t
>
clip
(
DataContainer
<
data_t
>
dc
,
data_t
min
,
data_t
max
)
{
std
::
transform
(
dc
.
begin
(),
dc
.
end
(),
dc
.
begin
(),
[
&
](
auto
x
)
{
if
(
x
<
min
)
{
return
min
;
}
else
if
(
x
>
max
)
{
return
max
;
}
else
{
return
x
;
}
});
return
dc
;
}
template
<
typename
data_t
>
DataContainer
<
data_t
>
concatenate
(
const
DataContainer
<
data_t
>&
dc1
,
const
DataContainer
<
data_t
>&
dc2
)
...
...
@@ -693,6 +710,9 @@ namespace elsa
template
class
DataContainer
<
complex
<
double
>
>
;
template
class
DataContainer
<
index_t
>;
template
DataContainer
<
float
>
clip
<
float
>
(
DataContainer
<
float
>
dc
,
float
min
,
float
max
);
template
DataContainer
<
double
>
clip
<
double
>
(
DataContainer
<
double
>
dc
,
double
min
,
double
max
);
template
DataContainer
<
float
>
concatenate
<
float
>
(
const
DataContainer
<
float
>&
,
const
DataContainer
<
float
>&
);
template
DataContainer
<
double
>
concatenate
<
double
>
(
const
DataContainer
<
double
>&
,
...
...
elsa/core/DataContainer.h
View file @
b72053f6
...
...
@@ -517,6 +517,10 @@ namespace elsa
return
os
;
}
/// clip the container values outside of the interval, to the interval edges
template
<
typename
data_t
>
DataContainer
<
data_t
>
clip
(
DataContainer
<
data_t
>
dc
,
data_t
min
,
data_t
max
);
/// Concatenate two DataContainers to one (requires copying of both)
template
<
typename
data_t
>
DataContainer
<
data_t
>
concatenate
(
const
DataContainer
<
data_t
>&
dc1
,
...
...
elsa/core/LinearOperator.cpp
View file @
b72053f6
...
...
@@ -270,7 +270,7 @@ namespace elsa
}
if
(
_mode
==
CompositeMode
::
SCALAR_MULT
)
{
return
new
LinearOperator
<
data_t
>
(
*
_rhs
,
_isAdjoint
);
return
new
LinearOperator
<
data_t
>
(
*
this
);
}
}
...
...
elsa/core/tests/test_DataContainer.cpp
View file @
b72053f6
...
...
@@ -927,6 +927,150 @@ TEST_CASE("DataContainer: Testing iterators for DataContainer")
}
}
TEST_CASE_TEMPLATE
(
"DataContainer: Clip a DataContainer"
,
data_t
,
float
,
double
)
{
GIVEN
(
"some 1D vectors"
)
{
index_t
size
=
7
;
IndexVector_t
numCoeff
(
1
);
numCoeff
<<
size
;
VolumeDescriptor
desc
(
numCoeff
);
data_t
min
=
6
;
data_t
max
=
19
;
Vector_t
<
data_t
>
dataVec1
(
desc
.
getNumberOfCoefficients
());
dataVec1
<<
6
,
10
,
7
,
18
,
10
,
11
,
9
;
Vector_t
<
data_t
>
expectedDataVec1
(
desc
.
getNumberOfCoefficients
());
expectedDataVec1
<<
6
,
10
,
7
,
18
,
10
,
11
,
9
;
Vector_t
<
data_t
>
dataVec2
(
desc
.
getNumberOfCoefficients
());
dataVec2
<<
4
,
-
23
,
7
,
18
,
18
,
10
,
10
;
Vector_t
<
data_t
>
expectedDataVec2
(
desc
.
getNumberOfCoefficients
());
expectedDataVec2
<<
min
,
min
,
7
,
18
,
18
,
10
,
10
;
Vector_t
<
data_t
>
dataVec3
(
desc
.
getNumberOfCoefficients
());
dataVec3
<<
14
,
23
,
7
,
18
,
20
,
10
,
10
;
Vector_t
<
data_t
>
expectedDataVec3
(
desc
.
getNumberOfCoefficients
());
expectedDataVec3
<<
14
,
max
,
7
,
18
,
max
,
10
,
10
;
Vector_t
<
data_t
>
dataVec4
(
desc
.
getNumberOfCoefficients
());
dataVec4
<<
1
,
23
,
5
,
28
,
20
,
30
,
0
;
Vector_t
<
data_t
>
expectedDataVec4
(
desc
.
getNumberOfCoefficients
());
expectedDataVec4
<<
min
,
max
,
min
,
max
,
max
,
max
,
min
;
WHEN
(
"creating a data container out of a vector within bounds"
)
{
DataContainer
dc
(
desc
,
dataVec1
);
auto
clipped
=
clip
(
dc
,
min
,
max
);
THEN
(
"the size of the clipped DataContainer is equal to that of the original container"
)
{
REQUIRE_EQ
(
clipped
.
getSize
(),
size
);
}
THEN
(
"the values correspond to the original DataContainers"
)
{
for
(
int
i
=
0
;
i
<
size
;
++
i
)
{
INFO
(
"Error at position: "
,
i
);
REQUIRE_EQ
(
clipped
[
i
],
expectedDataVec1
[
i
]);
}
}
}
WHEN
(
"creating a data container out of a vector within or lower than the bounds"
)
{
DataContainer
dc
(
desc
,
dataVec2
);
auto
clipped
=
clip
(
dc
,
min
,
max
);
THEN
(
"the size of the clipped DataContainer is equal to that of the original container"
)
{
REQUIRE_EQ
(
clipped
.
getSize
(),
size
);
}
THEN
(
"the values correspond to the original DataContainers"
)
{
for
(
int
i
=
0
;
i
<
size
;
++
i
)
{
INFO
(
"Error at position: "
,
i
);
REQUIRE_EQ
(
clipped
[
i
],
expectedDataVec2
[
i
]);
}
}
}
WHEN
(
"creating a data container out of a vector within or higher than the bounds"
)
{
DataContainer
dc
(
desc
,
dataVec3
);
auto
clipped
=
clip
(
dc
,
min
,
max
);
THEN
(
"the size of the clipped DataContainer is equal to that of the original container"
)
{
REQUIRE_EQ
(
clipped
.
getSize
(),
size
);
}
THEN
(
"the values correspond to the original DataContainers"
)
{
for
(
int
i
=
0
;
i
<
size
;
++
i
)
{
INFO
(
"Error at position: "
,
i
);
REQUIRE_EQ
(
clipped
[
i
],
expectedDataVec3
[
i
]);
}
}
}
WHEN
(
"creating a data container out of a vector outside the bounds"
)
{
DataContainer
dc
(
desc
,
dataVec4
);
auto
clipped
=
clip
(
dc
,
min
,
max
);
THEN
(
"the size of the clipped DataContainer is equal to that of the original container"
)
{
REQUIRE_EQ
(
clipped
.
getSize
(),
size
);
}
THEN
(
"the values correspond to the original DataContainers"
)
{
for
(
int
i
=
0
;
i
<
size
;
++
i
)
{
INFO
(
"Error at position: "
,
i
);
REQUIRE_EQ
(
clipped
[
i
],
expectedDataVec4
[
i
]);
}
}
}
}
GIVEN
(
"a 2D data container"
)
{
IndexVector_t
numCoeff
(
2
);
numCoeff
<<
3
,
2
;
VolumeDescriptor
desc
(
numCoeff
);
data_t
min
=
0
;
data_t
max
=
8
;
Vector_t
<
data_t
>
dataVec
(
desc
.
getNumberOfCoefficients
());
dataVec
<<
-
19
,
-
23
,
7
,
8
,
20
,
1
;
Vector_t
<
data_t
>
expectedDataVec
(
desc
.
getNumberOfCoefficients
());
expectedDataVec
<<
min
,
min
,
7
,
8
,
max
,
1
;
WHEN
(
"creating a data container out of a vector within and outside of both bounds"
)
{
DataContainer
dc
(
desc
,
dataVec
);
auto
clipped
=
clip
(
dc
,
min
,
max
);
THEN
(
"the size of the clipped DataContainer is equal to that of the original container"
)
{
REQUIRE_EQ
(
clipped
.
getSize
(),
desc
.
getNumberOfCoefficients
());
}
THEN
(
"the values correspond to the original DataContainers"
)
{
for
(
int
i
=
0
;
i
<
desc
.
getNumberOfCoefficients
();
++
i
)
{
INFO
(
"Error at position: "
,
i
);
REQUIRE_EQ
(
clipped
[
i
],
expectedDataVec
[
i
]);
}
}
}
}
}
TEST_CASE_TEMPLATE
(
"DataContainer: Concatenate two DataContainers"
,
data_t
,
float
,
double
,
complex
<
float
>
,
complex
<
double
>
)
{
...
...
elsa/core/tests/test_LinearOperator.cpp
View file @
b72053f6
...
...
@@ -118,6 +118,37 @@ TEST_CASE_TEMPLATE("LinearOperator: Testing clone()", TestType, float, double, c
}
}
}
GIVEN
(
"a scalar multiplicative composite LinearOperator"
)
{
IndexVector_t
numCoeff
(
3
);
numCoeff
<<
50
,
41
,
22
;
IndexVector_t
numCoeff2
(
2
);
numCoeff2
<<
4
,
88
;
VolumeDescriptor
ddDomain
(
numCoeff
);
VolumeDescriptor
ddRange
(
numCoeff2
);
LinearOperator
<
TestType
>
linOp
(
ddDomain
,
ddRange
);
TestType
scalar
=
42
;
LinearOperator
<
TestType
>
scalarMultLinOp
=
scalar
*
linOp
;
WHEN
(
"cloning the LinearOperator"
)
{
auto
linOpClone
=
scalarMultLinOp
.
clone
();
THEN
(
"everything matches"
)
{
REQUIRE_NE
(
linOpClone
.
get
(),
&
scalarMultLinOp
);
REQUIRE_EQ
(
*
linOpClone
,
scalarMultLinOp
);
}
THEN
(
"copies are also identical"
)
{
auto
newOp
=
*
linOpClone
;
REQUIRE_EQ
(
newOp
,
scalarMultLinOp
);
}
}
}
}
TEST_CASE_TEMPLATE
(
"LinearOperator: Testing a leaf LinearOperator"
,
TestType
,
float
,
double
,
...
...
examples/simple_recon2d.cpp
View file @
b72053f6
/// [simplerecon header begin]
#include "elsa.h"
#include <iostream>
using
namespace
elsa
;
/// [simplerecon header end]
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment