Kim O
Kim O

Reputation: 621

Medical imaging (PyRadiomics) with .nii.gz files

I am trying to implement the package:

https://pyradiomics.readthedocs.io/en/latest/usage.html

It looks super simple, but they expect .nrrd files. My files are .nii.gz. How do I solve this? Also, have anyone tried to apply PyRadiomics on TCIA data? if so, can I see your github or Jupyter Notebook?

Thanks a lot.

Upvotes: 1

Views: 3278

Answers (3)

Francisco Maria Calisto
Francisco Maria Calisto

Reputation: 3250

The DWIConverter converts diffusion-weighted MR images in DICOM series into nrrd format for analysis in Slicer. It parses the DICOM header to extract necessary information about measurement frame, diffusion weighting directions, b-values, etc, and write out a nrrd image. For non-diffusion weighted DICOM images, it loads in an entire DICOM series and writes out a single DICOM volume in a .nhdr/.raw pair.

So that trying to convert your .nii.gz inside DICOM files for the nrrd format is a possibility by using this tools. Also, you can look at the SlicerDMRI that is a similar module.

Upvotes: 0

CrackedStone
CrackedStone

Reputation: 113

You could turn NII into numpy array firstly and then turn it into NRRD with using:

nrrd and nibabel

import numpy as np
import nibabel as nib
import nrrd

# Download NII
example_filename = "image.nii.gz"
image = nib.load(example_filename)

# Turn into numpy array
array = np.array(img.dataobj)

# Save NRRD
nrrd_path_to = "image.nrrd"
nrrd.write(image_path_to, array)

Upvotes: 2

JoostJM
JoostJM

Reputation: 367

Although the examples are in .nrrd, PyRadiomics uses SimpleITK for image operations. This allows PyRadiomics to support a whole range of image formats, including .nii.gz. You don't have to convert them.

Upvotes: 1

Related Questions