Skip to content

Commit

Permalink
Merge pull request #24 from nipype/mif-gz-converter
Browse files Browse the repository at this point in the history
commented out read_array code that is causing error due to types
  • Loading branch information
tclose committed Sep 10, 2024
2 parents 08d2287 + 4c7cec8 commit c31c861
Showing 1 changed file with 16 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@
from fileformats.medimage import MedicalImage, Nifti1
from fileformats.medimage_mrtrix3 import ImageFormat

if sys.version_info >= (3, 9):
from typing import TypeAlias
else:
from typing_extensions import TypeAlias
# if sys.version_info >= (3, 9):
# from typing import TypeAlias
# else:
# from typing_extensions import TypeAlias


DataArrayType: TypeAlias = (
"numpy.typing.NDArray[ty.Union[np.floating[ty.Any], np.integer[ty.Any]]]"
)
# DataArrayType: TypeAlias = (
# "numpy.typing.NDArray[ty.Union[np.floating[ty.Any], np.integer[ty.Any]]]"
# )


@extra_implementation(FileSet.generate_sample_data)
Expand All @@ -32,12 +32,12 @@ def generate_mrtrix_sample_data(
return mif.fspaths


@extra_implementation(MedicalImage.read_array)
def mrtrix_read_array(mif: ImageFormat) -> DataArrayType:
raise NotImplementedError(
"Need to work out how to use the metadata to read the array in the correct order"
)
data = mif.read_contents(offset=mif.data_offset)
array = np.asarray(data)
data_array = array.reshape(mif.dims)
return data_array
# @extra_implementation(MedicalImage.read_array)
# def mrtrix_read_array(mif: ImageFormat) -> DataArrayType:
# raise NotImplementedError(
# "Need to work out how to use the metadata to read the array in the correct order"
# )
# data = mif.read_contents(offset=mif.data_offset)
# array = np.asarray(data)
# data_array = array.reshape(mif.dims)
# return data_array

0 comments on commit c31c861

Please sign in to comment.