Questions tagged [nibabel]

Nibabel is an open source python package for processing neuroimaging files. It supports processing of ANALYZE (plain, SPM99, SPM2 and later), GIFTI, NIfTI1, NIfTI2, MINC1, MINC2, MGH and ECAT file formats.

Nibabel is an open source python package for processing neuroimaging files. It supports processing of ANALYZE (plain, SPM99, SPM2 and later), GIFTI, NIfTI1, NIfTI2, MINC1, MINC2, MGH and ECAT file formats.

Resources

Nibabel

80 questions
1
vote
0 answers

Splitting NIFTI images to voxel patches

I am trying to split a set 3D MRA NIFTI images into voxel patches of equal sizes (e.g. 32 x 32 x 32). The goal is to use the voxels to train a 3D CNN to detect anomalies within the cerebral arteries. How can this be achieved with Python using some…
anonuser1
  • 347
  • 1
  • 7
  • 17
1
vote
3 answers

More pythonic way to iterate through volume in arbitrary axis?

I have a function which takes a 3D numpy array (which we'll call a volume), and converts it into a list of 2D slices. I want the user to be able to specify the axis through which it is sliced. I am managing this with the code below, but the triple…
Mohamad Zeina
  • 404
  • 3
  • 20
1
vote
1 answer

How do I edit and save voxel size and the corresponding affine of a 3D volume in Nifti format in python?

I'm changing the voxel size of some 3D volumes. How do I edit the pixdim field and calculate the new affine? I have some MR volumes which are anisotropic, the voxel sizes are, say, 0.5 x 0.5 x 3 mm. And I've some code to interpolate them into…
kaltu
  • 330
  • 5
  • 17
1
vote
1 answer

How to preprocess NIfTI data format using NiBabel (Python)

after convertig a NIfTI-file to an array using NiBabel, the array has three dimensions and the numbers look like this: [-9.35506855e-42 -1.78675141e-35 1.18329136e-30 -1.58892995e-24 5.25227377e-24 1.11677966e-23 -2.41237451e-24…
1
vote
4 answers

ImportError: No module named 'nilearn'

I'm trying to plot .nii data using nibabel and nilearn. I'm using python 3.5 and installed both packages successfully. But, when I'm trying to import the module, it's returning - ImportError: No module named 'nilearn'. What am I missing here ??
MD. Khairul Basar
  • 4,976
  • 14
  • 41
  • 59
0
votes
1 answer

How to combine image slices into a NIfTI file

I have a function which, given a NIfTI file, generates a set of images. How can I essentially reverse that process with another function which takes in these images and creates a NIfTI file from them?
0
votes
1 answer

AttributeError: module 'numpy' has no attribute 'float' while importing nibabel

When i try to install nibabel lirary i get an error like this. Tried different version of numpy and didn't work out. Any idea how to solve this? --------------------------------------------------------------------------- AttributeError …
0
votes
0 answers

How to move nibabel.Nifti1Image metadata into a SimpleITK.Image object?

I am working with MRI images which in their raw form are 5-dimensional. I can load them in using nibabel package which gives me nibabel.Nifti1Image objects. Then I can slice that object into a bunch of 3D numpy arrays from which I create…
Jeremy Joe
  • 11
  • 3
0
votes
2 answers

RuntimeError: expected scalar type Double but found Float in Pytorch code

def encoder_block(inp, max_pool, in_channels): conv = torch.nn.Conv2d(in_channels=in_channels, out_channels=64, kernel_size=3, padding='same')(inp.double()) relu = torch.nn.ReLU()(conv) conv = torch.nn.Conv2d(in_channels=64,…
Ryan Marr
  • 83
  • 7
0
votes
1 answer

Loading large sets of data for TensorFlow deep learning

I'm loading data consisting of thousands of MRI images. I'm doing it like this using nibabel to obtain the 3D data arrays from the MRI files: def get_voxels(path): img = nib.load(path) data = img.get_fdata() return data.copy() df =…
Paul Reiners
  • 8,576
  • 33
  • 117
  • 202
0
votes
0 answers

How to convert the annotation label?

I have a question about the conversion of images. In segmentation tasks of medical images, if DICOM files are converted to NifTI files with dicom2nifti, discrepancies could occur between original images and annotation labels. How to correct these…
kodhoi
  • 23
  • 5
0
votes
1 answer

Niftis being plotted skewed

When I plot single images they appear to be skewed, but doesn't appear that way when I look at the images in 3DSlicer or another viewer. I'm not sure if there's something I should be adjusting that I'm not aware of. The below is how I converted from…
Cenoc
  • 11,172
  • 21
  • 58
  • 92
0
votes
0 answers

Import nibabel Jupyter Notebook

How do I import the nibabel module in Jupyter notebook on MacOS? I already installed nibabel on my Macbook using PIP, but the jupyter notebook still gives ModuleNotFoundError: No module named 'nibabel'
Annemijn
  • 1
  • 1
0
votes
0 answers

nii file becomes zero after applying resampling

I am trying to resample a nii. file, I am applying transformations below; the voxel dimensions are resampled as I can see from the header information; however, the final resampled file after .get_fdata() has all zeros. import…
Abbas Khan
  • 56
  • 6
0
votes
0 answers

How do I save each iteration as my file format without overwriting the previous iteration?

I am new to coding. I basically have a bunch of files in "nifti" format, I wanted to simply load them, apply a thresholding function to them and then save them. I was able to write the few lines of code to do it to one file (it worked), but I have…
era
  • 1
  • 1