Skip to content

Commit fdd34b5

Browse files
committed
DOC+PL: docstring corrections and minor clarifications.
1 parent 880b89a commit fdd34b5

File tree

1 file changed

+18
-15
lines changed
  • nibabel/brainvoyager

1 file changed

+18
-15
lines changed

nibabel/brainvoyager/bv.py

+18-15
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,7 @@ def pack_BV_header(hdr_dict_proto, hdr_dict, parent_hdr_dict=None):
230230
if hdr_dict[def_or_name[1]] == def_or_name[2]:
231231
part = pack('<' + pack_format, value)
232232
else:
233+
# skip to next header field if condition is not met
233234
continue
234235
else:
235236
part = pack('<' + pack_format, value)
@@ -309,7 +310,7 @@ def update_BV_header(hdr_dict_proto, hdr_dict_old, hdr_dict_new,
309310
When update_BV_header() is called recursively the not yet updated
310311
(parent) hdr_dict is passed to give access to n_fields_name fields
311312
outside the current scope (see below).
312-
parent_new: OrderedDict
313+
parent_new: None or OrderedDict, optional
313314
When update_BV_header() is called recursively the not yet updated
314315
(parent) hdr_dict is passed to give access to n_fields_name fields
315316
outside the current scope (see below).
@@ -321,16 +322,18 @@ def update_BV_header(hdr_dict_proto, hdr_dict_old, hdr_dict_new,
321322
conditional fields.
322323
"""
323324
for name, pack_format, def_or_name in hdr_dict_proto:
324-
# handle nested loop fields
325-
if isinstance(pack_format, tuple):
325+
# handle only nested loop fields
326+
if not isinstance(pack_format, tuple):
327+
continue
328+
else:
326329
# calculate the change of array length and the new array length
327330
if def_or_name in hdr_dict_old:
328-
delta_values = hdr_dict_new[def_or_name] - \
329-
hdr_dict_old[def_or_name]
331+
delta_values = (hdr_dict_new[def_or_name] -
332+
hdr_dict_old[def_or_name])
330333
n_values = hdr_dict_new[def_or_name]
331334
else:
332-
delta_values = parent_new[def_or_name] - \
333-
parent_old[def_or_name]
335+
delta_values = (parent_new[def_or_name] -
336+
parent_old[def_or_name])
334337
n_values = parent_new[def_or_name]
335338
if delta_values > 0: # add nested loops
336339
for i in range(delta_values):
@@ -384,8 +387,8 @@ def combine_st(st_array, inv=False):
384387
385388
Parameters
386389
----------
387-
st_array: array
388-
array filled with transformation matrices of shape (4, 4)
390+
st_array: array of shape (n, 4, 4)
391+
array filled with n transformation matrices of shape (4, 4)
389392
390393
inv: boolean
391394
Set to true to invert the transformation matrices before
@@ -754,12 +757,12 @@ def get_bbox_center(self):
754757
framing cube.
755758
"""
756759
hdr = self._hdr_dict
757-
x = hdr['x_start'] + \
758-
((hdr['x_end'] - hdr['x_start']) / 2)
759-
y = hdr['y_start'] + \
760-
((hdr['y_end'] - hdr['y_start']) / 2)
761-
z = hdr['z_start'] + \
762-
((hdr['z_end'] - hdr['z_start']) / 2)
760+
x = (hdr['x_start'] +
761+
((hdr['x_end'] - hdr['x_start']) / 2))
762+
y = (hdr['y_start'] +
763+
((hdr['y_end'] - hdr['y_start']) / 2))
764+
z = (hdr['z_start'] +
765+
((hdr['z_end'] - hdr['z_start']) / 2))
763766
return z, y, x
764767

765768
def get_zooms(self):

0 commit comments

Comments
 (0)