Skip to content

Commit

Permalink
FIX ensure correct datatype for mri_surf2surf
Browse files Browse the repository at this point in the history
  • Loading branch information
mvdoc committed Oct 30, 2023
1 parent 2a9a5bc commit 5221e7a
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion cortex/freesurfer.py
Original file line number Diff line number Diff line change
Expand Up @@ -573,6 +573,15 @@ def _mri_surf2surf_command(src_subj, trg_subj, input_file, output_file, hemi):
return cmd


def _check_datatype(data):
dtype = data.dtype
if dtype == np.int64:
return np.int32
elif dtype == np.float64:
return np.float32
else:
return dtype


def mri_surf2surf(data, source_subj, target_subj, hemi, subjects_dir=None):
"""Uses freesurfer mri_surf2surf to transfer vertex data between
Expand All @@ -596,7 +605,8 @@ def mri_surf2surf(data, source_subj, target_subj, hemi, subjects_dir=None):
=====
Requires path to mri_surf2surf or freesurfer environment to be active.
"""
data_arrays = [gifti.GiftiDataArray(d) for d in data]
datatype = _check_datatype(data)
data_arrays = [gifti.GiftiDataArray(d, datatype=datatype) for d in data]
gifti_image = gifti.GiftiImage(darrays=data_arrays)

tf_in = NamedTemporaryFile(suffix=".gii")
Expand Down

0 comments on commit 5221e7a

Please sign in to comment.