@@ -101,10 +101,10 @@ def diff_header_fields(key, inputs):
101
101
102
102
103
103
def get_headers_diff (files , opts ):
104
- """
104
+ """
105
105
Getting the difference of headers.
106
106
Returns a dictionary that is later processed.
107
-
107
+
108
108
Parameters
109
109
----------
110
110
files: list of files
@@ -113,7 +113,7 @@ def get_headers_diff(files, opts):
113
113
114
114
header_list = [nib .load (f ).header for f in files ]
115
115
116
- if opts .header_fields : # will almost always have a header field
116
+ if opts .header_fields : # will almost always have a header field
117
117
# signals "all fields"
118
118
if opts .header_fields == 'all' :
119
119
# TODO: header fields might vary across file types, thus prior sensing would be needed
@@ -134,19 +134,17 @@ def get_headers_diff(files, opts):
134
134
return {}
135
135
136
136
137
- def get_data_diff (files ):
137
+ def get_data_md5sums (files ):
138
138
139
- data_list = [nib .load (f ).get_data () for f in files ]
140
- output = []
139
+ md5sums = [
140
+ hashlib .md5 (np .ascontiguousarray (nib .load (f ).get_data (), dtype = np .float32 )).hexdigest ()
141
+ for f in files
142
+ ]
141
143
142
- for a , b in itertools .combinations (data_list , 2 ):
143
- if diff_values (hash (str (a )), hash (str (b ))):
144
- if hash (str (a )) not in output :
145
- output .append (str (hash (str (a ))))
146
- if hash (str (b )) not in output :
147
- output .append (str (hash (str (b ))))
144
+ if len (set (md5sums )) == 1 :
145
+ return []
148
146
149
- return output
147
+ return md5sums
150
148
151
149
152
150
def main ():
@@ -164,7 +162,7 @@ def main():
164
162
nib .imageglobals .logger .level = 50
165
163
166
164
header_diff = get_headers_diff (files , opts )
167
- data_diff = get_data_diff (files )
165
+ data_diff = get_data_md5sums (files )
168
166
169
167
if len (data_diff ) != 0 and len (header_diff ) != 0 :
170
168
print ("{:<11}" .format ('Field' ), end = "" )
0 commit comments