File: test_pattern.c

package info (click to toggle)
bart 0.9.00-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 9,040 kB
  • sloc: ansic: 116,116; python: 1,329; sh: 726; makefile: 639; javascript: 589; cpp: 106
file content (80 lines) | stat: -rw-r--r-- 1,541 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
/* Copyright 2016. The Regents of the University of California.
 * All rights reserved. Use of this source code is governed by
 * a BSD-style license which can be found in the LICENSE file.
 *
 * Authors:
 * 2016 Jonathan Tamir <jtamir@eecs.berkeley.edu>
 */

#include <stdlib.h>
#include <complex.h>

#include "num/flpmath.h"
#include "num/multind.h"

#include "misc/debug.h"
#include "misc/misc.h"
#include "misc/mri.h"

#include "utest.h"


static bool test_pattern_flags(unsigned int D, const long dims[D], unsigned int flags, const complex float* in, const complex float* ref)
{
	long odims[D];
	md_select_dims(D, ~flags, odims, dims);

	complex float* out = md_alloc(D, odims, CFL_SIZE);

	estimate_pattern(D, dims, flags, out, in);

	bool ret = (md_znrmse(D, odims, ref, out) < UT_TOL);

	md_free(out);

	return ret;
}


static bool test_pattern(void)
{
	const complex float in[1][5][3] = { {

		{ 3., 0., 0. },
		{ 0., 2., 0. },
		{ .2, 0., 0. },
		{ 0., 0., 0. },
		{ 0., 2., 0. },
	} };


	const complex float ref0[1][5][3] = { {

		{ 1., 0., 0. },
		{ 0., 1., 0. },
		{ 1., 0., 0. },
		{ 0., 0., 0. },
		{ 0., 1., 0. },
	} };

	const complex float ref2[1][1][3] = { {

		{ 1., 1., 0. },
	} };

	const complex float ref3[1][1][1] = { {

		{ 1. },
	} };

	long idims[3] = { 3, 5, 1 };


	return (test_pattern_flags(3, idims, 0, &in[0][0][0], &ref0[0][0][0]) && 
		test_pattern_flags(3, idims, 2, &in[0][0][0], &ref2[0][0][0]) &&
		test_pattern_flags(3, idims, 3, &in[0][0][0], &ref3[0][0][0]));
}


UT_REGISTER_TEST(test_pattern);