Skip to content

Commit

Permalink
Merge pull request #655 from MichielCottaar/opt_genfromtxt
Browse files Browse the repository at this point in the history
Speed up reading of CIFTI's: replace genfromtxt with loadtxt
  • Loading branch information
effigies committed Aug 7, 2018
2 parents 0408783 + 370c811 commit 897eb31
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions nibabel/cifti2/parse_cifti2.py
Original file line number Diff line number Diff line change
Expand Up @@ -517,28 +517,28 @@ def flush_chardata(self):
# conversion to numpy array
c = BytesIO(data.strip().encode('utf-8'))
vertices = self.struct_state[-1]
vertices.extend(np.genfromtxt(c, dtype=np.int))
vertices.extend(np.loadtxt(c, dtype=np.int))
c.close()

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

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

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

elif self.write_to == 'Label':
Expand Down

0 comments on commit 897eb31

Please sign in to comment.