Skip to content

Commit 897eb31

Browse files
authored
Merge pull request #655 from MichielCottaar/opt_genfromtxt
Speed up reading of CIFTI's: replace genfromtxt with loadtxt
2 parents 0408783 + 370c811 commit 897eb31

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

nibabel/cifti2/parse_cifti2.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -517,28 +517,28 @@ def flush_chardata(self):
517517
# conversion to numpy array
518518
c = BytesIO(data.strip().encode('utf-8'))
519519
vertices = self.struct_state[-1]
520-
vertices.extend(np.genfromtxt(c, dtype=np.int))
520+
vertices.extend(np.loadtxt(c, dtype=np.int))
521521
c.close()
522522

523523
elif self.write_to == 'VoxelIndices':
524524
# conversion to numpy array
525525
c = BytesIO(data.strip().encode('utf-8'))
526526
parent = self.struct_state[-1]
527-
parent.voxel_indices_ijk.extend(np.genfromtxt(c, dtype=np.int).reshape(-1, 3))
527+
parent.voxel_indices_ijk.extend(np.loadtxt(c, dtype=np.int).reshape(-1, 3))
528528
c.close()
529529

530530
elif self.write_to == 'VertexIndices':
531531
# conversion to numpy array
532532
c = BytesIO(data.strip().encode('utf-8'))
533533
index = self.struct_state[-1]
534-
index.extend(np.genfromtxt(c, dtype=np.int))
534+
index.extend(np.loadtxt(c, dtype=np.int))
535535
c.close()
536536

537537
elif self.write_to == 'TransformMatrix':
538538
# conversion to numpy array
539539
c = BytesIO(data.strip().encode('utf-8'))
540540
transform = self.struct_state[-1]
541-
transform.matrix = np.genfromtxt(c, dtype=np.float)
541+
transform.matrix = np.loadtxt(c, dtype=np.float)
542542
c.close()
543543

544544
elif self.write_to == 'Label':

0 commit comments

Comments
 (0)