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

Imaging Format Compatibility #16

Open
tgd15 opened this issue Dec 8, 2020 · 3 comments
Open

Imaging Format Compatibility #16

tgd15 opened this issue Dec 8, 2020 · 3 comments
Assignees

Comments

@tgd15
Copy link
Collaborator

tgd15 commented Dec 8, 2020

Currently, the Topology Radiomics packages only supports nifty (.nii) images via nibabel.

Sometimes, the labs use the .mha or .mhd imaging formats. Could you please add SimpleITK and/or NumPy support in the compute_morphology_features function to expand imaging format compatibility?

SimpleITK example:

volume = sitk.ReadImage("/path/to/volume.mha") # vol type is SimpleITK.SimpleITK.Image
features = rad.compute_morphology_features(volume, config)

NumPy Array from SimpleITK example:

volume = sitk.ReadImage("/path/to/volume.mha")
volume_np = sitk.GetArrayFromImage(volume) # vol_np type is numpy.ndarray
features = rad.compute_morphology_features(volume_np, config)

To pass a NumPy array from SimpleITK into the compute_morphology_features function, I made the following change:

def compute_morphology_features(mri_mask_voxels: BinaryVoxelMask,
                                config: MorphologyConfig = MorphologyConfig()) -> MorphologyFeatures:
    #mask = mri_mask_voxels.mri_voxel_mask # commented this line out because NumPy array does not have this object
    mask = mri_mask_voxels
@satishev
Copy link
Contributor

Tagging @neshdev and @robtoth to incorporate.

@neshdev
Copy link
Contributor

neshdev commented Feb 7, 2021

@tgd15 - I just looked over the code and realized that we wanted to make the package bare bones. We planned to only support numpy arrays. Loading of other MRI images would be done by some external functions and packages written by the user of the package. For example, the code you have above can convert to numpy arrays from SimpleITK formats.

However, looking at the code above, it looks like you are using the function incorrectly

It could be something like this:

import topology_radiomics as rad
sitk_volume = sitk.ReadImage("/path/to/volume.mha")
volume = sitk.GetArrayFromImage(volume)
sanitized_voxels = rad.convert_volume_into_mask(
volume, merge_labels=[])
features_data = rad.compute_morphology_features(sanitized_voxels)

or something like this:

import topology_radiomics as rad
sitk_volume = sitk.ReadImage("/path/to/volume.mha")
volume = sitk.GetArrayFromImage(volume)
sanitized_voxels = rad.BinaryVoxelMask(volume)
features_data = rad.compute_morphology_features(sanitized_voxels)

We have some references for loading data and using other packages in the tutorial notebooks:
NiBabel:
https://github.com/radxtools/topology-radiomics/blob/master/notebooks/Tutorial%20-%20Getting%20started%20with%20topoplogy_radiomics.ipynb

MedPy:
https://github.com/radxtools/topology-radiomics/blob/master/notebooks/Tutorial%20-%20Working%20with%20medpy%20and%20topology_radiomics.ipynb

If you want, we can add another notebook for SimpleITK.

@viveksthanam
Copy link

Hello,
i am trying to use this for extracting topology features from a CT scan. but i am getting an error "AttributeError: 'numpy.ndarray' object has no attribute 'mri_voxel_mask'" when i pass numpy array, so i wanted to ask if this is only for MRI scans or can i use this for CT Scans too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants