Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

commented out read_array code that is causing error due to types #24

Merged
merged 1 commit into from
Sep 10, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading