Skip to content

Commit 84a873f

Browse files
committed
RF: Set intent_code first so that, if an invalid value was passed in, other
header fields are not clobbered before the error gets raised.
1 parent 13f3fe4 commit 84a873f

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

nibabel/nifti1.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1373,12 +1373,12 @@ def set_intent(self, code, params=(), name=''):
13731373
if len(params) and len(params) != len(p_descr):
13741374
raise HeaderDataError('Need params of form %s, or empty'
13751375
% (p_descr,))
1376+
hdr['intent_code'] = icode
1377+
hdr['intent_name'] = name
13761378
all_params = [0] * 3
13771379
all_params[:len(params)] = params[:]
13781380
for i, param in enumerate(all_params):
13791381
hdr['intent_p%d' % (i + 1)] = param
1380-
hdr['intent_code'] = icode
1381-
hdr['intent_name'] = name
13821382

13831383
def get_slice_duration(self):
13841384
''' Get slice duration

0 commit comments

Comments
 (0)