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

convert .npy segmentation file into .nrrd #12

Open
silkezimm opened this issue Jul 30, 2023 · 4 comments
Open

convert .npy segmentation file into .nrrd #12

silkezimm opened this issue Jul 30, 2023 · 4 comments

Comments

@silkezimm
Copy link

Dear all,

i have the problem that i have DICOM images and a npy file of segmented data as input to pyradiomics. #
i converted the DICOM images in nrrd format with 3Dslicer. now i need to convert the segmentation/label file .npy into .nrrd.

i cant solve this;> can anyone help me and provide a solution?

thank you so much,
Silke

@ivanzhovannik
Copy link

Hi @silkezimm,

In order to give you good advice, could you please share more info about our .npy file? Given file name filename.npy (change to your file name), please run and post below:

import numpy as np

mask_array  = np.load("filename.npy", allow_pickle=True)
print(f"Shape of my mask array is {mask_array.shape}")
print(f"Unique mask values are {np.unique(mask_array)}")

Usually .npy files contain only the voxel intensities and not the grid, which can be used to understand how to place these voxel intensities in the space.

On the other hand, image files such as .nrrd contain both the grid and voxel intensities. Given your image file image.nrrd (change) please run and post below:

import SimpleITK as sitk

image = sitk.ReadImage("image.nrrd")
print(f"Image size {sitk.GetSize(image)}, image spacing and origin: {sitk.GetSpacing(image)}, {sitk.GetOrigin(image)}")

@silkezimm
Copy link
Author

silkezimm commented Aug 3, 2023 via email

@ivanzhovannik
Copy link

@silkezimm like any other command in cmd/bash/other shell, I guess. See the usage here: https://pyradiomics.readthedocs.io/en/latest/usage.html
See more in Python’s argparse package how to pass flags such as —params

@silkezimm
Copy link
Author

silkezimm commented Aug 3, 2023 via email

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

2 participants