@@ -73,91 +73,42 @@ def check_nib_diff_examples(opts=[], hdrs_str="", other_str=""):
73
73
# test nib-diff script
74
74
fnames = [pjoin (DATA_PATH , f )
75
75
for f in ('example4d.nii.gz' , 'standard.nii.gz' )]
76
+ target_output = """\
77
+ These files are different.
78
+ Field example4d.nii.gz standard.nii.gz
79
+ regular r
80
+ dim_info 57 0
81
+ dim [4, 128, 96, 24, 2, 1, 1, 1] [3, 4, 5, 7, 1, 1, 1, 1]
82
+ datatype 4 2
83
+ bitpix 16 8
84
+ pixdim [-1.0, 2.0, 2.0, 2.199999, 2000.0, 1.0, 1.0, 1.0][1.0, 1.0, 3.0, 2.0, 1.0, 1.0, 1.0, 1.0]
85
+ slice_end 23 0
86
+ xyzt_units 10 0
87
+ cal_max 1162.0 0.0
88
+ descrip FSL3.3? v2.25 NIfTI-1 Single file format
89
+ qform_code 1 0
90
+ sform_code 1 2
91
+ quatern_b -1.94510681403e-26 0.0
92
+ quatern_c -0.996708512306 0.0
93
+ quatern_d -0.081068739295 0.0
94
+ qoffset_x 117.855102539 0.0
95
+ qoffset_y -35.7229423523 0.0
96
+ qoffset_z -7.24879837036 0.0
97
+ srow_x [-2.0, 6.7147157e-19, 9.0810245e-18, 117.8551][1.0, 0.0, 0.0, 0.0]
98
+ srow_y [-6.7147157e-19, 1.9737115, -0.35552824, -35.722942][0.0, 3.0, 0.0, 0.0]
99
+ srow_z [8.255481e-18, 0.32320762, 2.1710818, -7.2487984][0.0, 0.0, 2.0, 0.0]
100
+ DATA(md5) b0abbc492b4fd533b2c80d82570062cf 0a2576dd6badbb25bfb3b12076df986b"""
76
101
fnames2 = [pjoin (DATA_PATH , f )
77
102
for f in ('example4d.nii.gz' , 'example4d.nii.gz' )]
78
103
code , stdout , stderr = run_command (['nib-diff' ] + fnames , check_code = False )
79
- hi = difflib .context_diff (stdout , "Field " + "{:<45}" .format ("example4d.nii.gz" ) + "{:<45}" .format ("standard.nii.gz" )
80
- + "\n " + "regular b'r' b'' "
81
- " " + "\n " + "dim_info 57 "
82
- " 0 "
83
- " "
84
- " " + "\n "
85
- "dim [4, 128, 96, 24, 2, 1, 1, 1] [3, 4, 5, 7, 1, 1, 1, 1] "
86
- + "\n " + "datatype 4 2 "
87
- " " + "\n " + "bitpix 16 8 "
88
- " " + "\n " + "pixdim [-1.0, 2.0, 2.0, "
89
- "2.1999991, 2000.0, 1.0, 1.0,"
90
- " 1.0][1.0, 1.0, 3.0, 2.0, "
91
- "1.0, 1.0, 1.0, 1.0] " +
92
- "\n " + "slice_end 23 0 "
93
- " " + "\n " + "xyzt_units 10 0 "
94
- " " + "\n " + "cal_max 1162.0 "
95
- " 0.0 "
96
- " " + "\n " +
97
- "descrip b'FSL3.3\\ x00 v2.25 NIfTI-1 Single file format'b'' "
98
- " \n " + "qform_code 1 0 "
99
- " " + "\n " + "sform_code 1 2 "
100
- " \n " + "quatern_b -1.9451068140294884e-26 "
101
- " 0.0 "
102
- " " + "\n " +
103
- "quatern_c -0.9967085123062134 0.0 "
104
- + "\n " + "quatern_d -0.0810687392950058 0.0 "
105
- " " + "\n " + "qoffset_x 117.8551025390625 0.0 "
106
- " " + "\n " + "qoffset_y -35.72294235229492"
107
- " 0."
108
- "0 "
109
- " " + "\n " +
110
- "qoffset_z -7.248798370361328 0.0 "
111
- + "\n " + "srow_x [-2.0, 6.7147157e-19, 9.0810245e-18, 117.8551][1.0, 0.0, 0.0, 0.0] "
112
- " " + "\n " + "srow_y [-6.7147157e-19, 1.9737115, -0.35552824, -35.722942][0.0, 3"
113
- ".0, 0.0, 0.0] " + "\n " +
114
- "srow_z [8.2554809e-18, 0.32320762, 2.1710818, -7.2487984][0.0, 0.0, 2.0, 0.0] "
115
- " " + "\n " + "DATA: These files are different.\n Checksum b0abbc49 "
116
- + " 0a2576dd" )
117
- delta = '' .join (hi )
118
- print (delta )
119
- assert_equal (stdout , "Field " + "{:<45}" .format ("example4d.nii.gz" ) + "{:<45}" .format ("standard.nii.gz" )
120
- + "\n " + "regular b'r' b'' "
121
- " " + "\n " + "dim_info 57 "
122
- " 0 "
123
- " "
124
- " " + "\n "
125
- "dim [4, 128, 96, 24, 2, 1, 1, 1] [3, 4, 5, 7, 1, 1, 1, 1] "
126
- + "\n " + "datatype 4 2 "
127
- " " + "\n " + "bitpix 16 8 "
128
- " " + "\n " + "pixdim [-1.0, 2.0, 2.0, "
129
- "2.1999991, 2000.0, 1.0, 1.0,"
130
- " 1.0][1.0, 1.0, 3.0, 2.0, "
131
- "1.0, 1.0, 1.0, 1.0] " +
132
- "\n " + "slice_end 23 0 "
133
- " " + "\n " + "xyzt_units 10 0 "
134
- " " + "\n " + "cal_max 1162.0 "
135
- " 0.0 "
136
- " " + "\n " +
137
- "descrip b'FSL3.3\\ x00 v2.25 NIfTI-1 Single file format'b'' "
138
- " \n " + "qform_code 1 0 "
139
- " " + "\n " + "sform_code 1 2 "
140
- " \n " + "quatern_b -1.9451068140294884e-26 "
141
- " 0.0 "
142
- " " + "\n " +
143
- "quatern_c -0.9967085123062134 0.0 "
144
- + "\n " + "quatern_d -0.0810687392950058 0.0 "
145
- " " + "\n " + "qoffset_x 117.8551025390625 0.0 "
146
- " " + "\n " + "qoffset_y -35.72294235229492"
147
- " 0."
148
- "0 "
149
- " " + "\n " +
150
- "qoffset_z -7.248798370361328 0.0 "
151
- + "\n " + "srow_x [-2.0, 6.7147157e-19, 9.0810245e-18, 117.8551][1.0, 0.0, 0.0, 0.0] "
152
- " " + "\n " + "srow_y [-6.7147157e-19, 1.9737115, -0.35552824, -35.722942][0.0, 3"
153
- ".0, 0.0, 0.0] " + "\n " +
154
- "srow_z [8.2554809e-18, 0.32320762, 2.1710818, -7.2487984][0.0, 0.0, 2.0, 0.0] "
155
- " " + "\n " + "DATA: These files are different.\n Checksum b0abbc49 "
156
- + " 0a2576dd" )
104
+ # n1, n2 = 2300, 2400
105
+ # stdout, target_output = stdout[n1:n2], target_output[n1:n2]
106
+ delta_diff = difflib .context_diff (stdout , target_output )
107
+ print ('' .join (delta_diff ))
108
+ assert_equal (stdout , target_output )
157
109
158
110
code , stdout , stderr = run_command (['nib-diff' ] + fnames2 , check_code = False )
159
- assert_equal (stdout , "DATA: These files are identical!" )
160
-
111
+ assert_equal (stdout , "These files are identical." )
161
112
162
113
163
114
@script_test
0 commit comments