Skip to content

Commit 96a221f

Browse files
committed
Fixed str method of TrkFile
1 parent aadcf57 commit 96a221f

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

nibabel/streamlines/trk.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
import numpy as np
1313
import nibabel as nib
1414

15-
from nibabel.affines import apply_affine
1615
from nibabel.openers import Opener
1716
from nibabel.py3k import asbytes, asstr
1817
from nibabel.volumeutils import (native_code, swapped_code)
@@ -791,19 +790,23 @@ def __str__(self):
791790
hdr_field = getattr(Field, attr)
792791
if hdr_field in vars:
793792
vars[attr] = vars[hdr_field]
794-
vars['scalar_names'] = '\n'.join(map(asstr, vars['scalar_name']))
795-
vars['property_names'] = "\n".join(map(asstr, vars['property_name']))
793+
vars['scalar_names'] = '\n '.join([asstr(s)
794+
for s in vars['scalar_name']
795+
if len(s) > 0])
796+
vars['property_names'] = "\n ".join([asstr(s)
797+
for s in vars['property_name']
798+
if len(s) > 0])
796799
return """\
797800
MAGIC NUMBER: {MAGIC_NUMBER}
798801
v.{version}
799802
dim: {DIMENSIONS}
800803
voxel_sizes: {VOXEL_SIZES}
801804
orgin: {ORIGIN}
802805
nb_scalars: {NB_SCALARS_PER_POINT}
803-
scalar_name:\n {scalar_names}
806+
scalar_name:\n {scalar_names}
804807
nb_properties: {NB_PROPERTIES_PER_STREAMLINE}
805-
property_name:\n {property_names}
806-
vox_to_world: {VOXEL_TO_RASMM}
808+
property_name:\n {property_names}
809+
vox_to_world:\n{VOXEL_TO_RASMM}
807810
voxel_order: {VOXEL_ORDER}
808811
image_orientation_patient: {image_orientation_patient}
809812
pad1: {pad1}

0 commit comments

Comments
 (0)