@@ -38,27 +38,27 @@ def numbered_vector(nrows, symbol_prefix):
38
38
missing_r_col = numbered_vector (3 , 'k' )
39
39
pos_pat_0 = numbered_vector (3 , 'T^1' )
40
40
pos_pat_N = numbered_vector (3 , 'T^N' )
41
- pixel_spacing = symbols (('\Delta{r}' , '\Delta{c}' ))
41
+ pixel_spacing = symbols ((r '\Delta{r}' , r '\Delta{c}' ))
42
42
NZ = Symbol ('N' )
43
43
slice_spacing = Symbol ('\Delta{s}' )
44
44
45
45
R3 = orient_pat * np .diag (pixel_spacing )
46
- R = zeros (( 4 , 2 ) )
46
+ R = zeros (4 , 2 )
47
47
R [:3 ,:] = R3
48
48
49
49
# The following is specific to the SPM algorithm.
50
- x1 = ones (( 4 , 1 ) )
51
- y1 = ones (( 4 , 1 ) )
50
+ x1 = ones (4 , 1 )
51
+ y1 = ones (4 , 1 )
52
52
y1 [:3 ,:] = pos_pat_0
53
53
54
- to_inv = zeros (( 4 , 4 ) )
54
+ to_inv = zeros (4 , 4 )
55
55
to_inv [:,0 ] = x1
56
- to_inv [:,1 ] = symbols ('abcd ' )
56
+ to_inv [:,1 ] = symbols ('a b c d ' )
57
57
to_inv [0 ,2 ] = 1
58
58
to_inv [1 ,3 ] = 1
59
- inv_lhs = zeros (( 4 , 4 ) )
59
+ inv_lhs = zeros (4 , 4 )
60
60
inv_lhs [:,0 ] = y1
61
- inv_lhs [:,1 ] = symbols ('efgh ' )
61
+ inv_lhs [:,1 ] = symbols ('e f g h ' )
62
62
inv_lhs [:,2 :] = R
63
63
64
64
def spm_full_matrix (x2 , y2 ):
@@ -69,17 +69,17 @@ def spm_full_matrix(x2, y2):
69
69
return lhs * rhs .inv ()
70
70
71
71
# single slice case
72
- orient = zeros (( 3 , 3 ) )
72
+ orient = zeros (3 , 3 )
73
73
orient [:3 ,:2 ] = orient_pat
74
74
orient [:,2 ] = orient_cross
75
75
x2_ss = Matrix ((0 ,0 ,1 ,0 ))
76
- y2_ss = zeros (( 4 , 1 ) )
76
+ y2_ss = zeros (4 , 1 )
77
77
y2_ss [:3 ,:] = orient * Matrix ((0 ,0 ,slice_spacing ))
78
78
A_ss = spm_full_matrix (x2_ss , y2_ss )
79
79
80
80
# many slice case
81
81
x2_ms = Matrix ((1 ,1 ,NZ ,1 ))
82
- y2_ms = ones (( 4 , 1 ) )
82
+ y2_ms = ones (4 , 1 )
83
83
y2_ms [:3 ,:] = pos_pat_N
84
84
A_ms = spm_full_matrix (x2_ms , y2_ms )
85
85
@@ -91,7 +91,7 @@ def spm_full_matrix(x2, y2):
91
91
# single slice case
92
92
single_aff = eye (4 )
93
93
rot = orient
94
- rot_scale = rot * np .diag (pixel_spacing [:] + [ slice_spacing ] )
94
+ rot_scale = rot * np .diag (pixel_spacing [:] + ( slice_spacing ,) )
95
95
single_aff [:3 ,:3 ] = rot_scale
96
96
single_aff [:3 ,3 ] = pos_pat_0
97
97
@@ -140,23 +140,23 @@ def my_latex(expr):
140
140
S = sympy .latex (expr )
141
141
return S [1 :- 1 ]
142
142
143
- print 'Latex stuff'
144
- print ' R = ' + my_latex (to_inv )
145
- print ' '
146
- print ' L = ' + my_latex (inv_lhs )
147
- print
148
- print ' 0B = ' + my_latex (one_based )
149
- print
150
- print ' ' + my_latex (solved )
151
- print
152
- print ' A_{multi} = ' + my_latex (multi_aff_solved )
153
- print ' '
154
- print ' A_{single} = ' + my_latex (single_aff )
155
- print
156
- print r' \left(\begin{smallmatrix}T^N\\1\end{smallmatrix}\right) = A ' + my_latex (trans_z_N )
157
- print
158
- print ' A_j = A_{single} ' + my_latex (nz_trans )
159
- print
160
- print ' T^j = ' + my_latex (IPP_j )
161
- print
162
- print ' T^j \cdot \mathbf{c} = ' + my_latex (spm_z )
143
+ print ( 'Latex stuff' )
144
+ print ( ' R = ' + my_latex (to_inv ) )
145
+ print ( ' ' )
146
+ print ( ' L = ' + my_latex (inv_lhs ) )
147
+ print ()
148
+ print ( ' 0B = ' + my_latex (one_based ) )
149
+ print ()
150
+ print ( ' ' + my_latex (solved ) )
151
+ print ()
152
+ print ( ' A_{multi} = ' + my_latex (multi_aff_solved ) )
153
+ print ( ' ' )
154
+ print ( ' A_{single} = ' + my_latex (single_aff ) )
155
+ print ()
156
+ print ( r' \left(\begin{smallmatrix}T^N\\1\end{smallmatrix}\right) = A ' + my_latex (trans_z_N ) )
157
+ print ()
158
+ print ( ' A_j = A_{single} ' + my_latex (nz_trans ) )
159
+ print ()
160
+ print ( ' T^j = ' + my_latex (IPP_j ) )
161
+ print ()
162
+ print ( ' T^j \cdot \mathbf{c} = ' + my_latex (spm_z ) )
0 commit comments