Skip to content

Commit 0f7db31

Browse files
unidesignermatthew-brett
authored andcommitted
ENH - Supporting two types of data array specification strings
1 parent accb977 commit 0f7db31

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

nibabel/gifti/gifti.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -196,23 +196,27 @@ def data_tag(dataarray, encoding, datatype, ordering):
196196
else:
197197
ord = 'C'
198198

199-
if encoding == "GIFTI_ENCODING_ASCII":
199+
if encoding == gifti_encoding_codes.giistring[1] or \
200+
encoding == gifti_encoding_codes.specs[1]:
200201
c = BytesIO()
201202
# np.savetxt(c, dataarray, format, delimiter for columns)
202203
np.savetxt(c, dataarray, datatype, ' ')
203204
c.seek(0)
204205
da = c.read()
205206

206-
elif encoding == "GIFTI_ENCODING_B64BIN":
207+
elif encoding == gifti_encoding_codes.giistring[2] or \
208+
encoding == gifti_encoding_codes.specs[2]:
207209
da = base64.encodestring(dataarray.tostring(ord))
208210

209-
elif encoding == "GIFTI_ENCODING_B64GZ":
211+
elif encoding == gifti_encoding_codes.giistring[3] or \
212+
encoding == gifti_encoding_codes.specs[3]:
210213
# first compress
211214
comp = zlib.compress(dataarray.tostring(ord))
212215
da = base64.encodestring(comp)
213216
da = da.decode()
214217

215-
elif encoding == "GIFTI_ENCODING_EXTBIN":
218+
elif encoding == gifti_encoding_codes.giistring[4] or \
219+
encoding == gifti_encoding_codes.specs[4]:
216220
raise NotImplementedError("In what format are the external files?")
217221
da = ''
218222
else:

0 commit comments

Comments
 (0)