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
8
votes
1 answer

How to convert 3D numpy array to nifti image in nibabel?

From this question How to convert Nifti file to Numpy array? , I created a 3D numpy array of nifti image. I made some modifications to this array, like I changed depth of the array by adding padding of zeroes. Now I want to convert this array back…
Prvt_Yadav
  • 324
  • 1
  • 6
  • 20
7
votes
1 answer

Down-sample mri T1 image in python with Nipy

I have a T1 image (NIFTI), already aligned, with dimension 121 x 145 x 121. The image is loaded by nibabel. The voxel size is 1.5 x 1.5 x 1.5 mm. I want to down-sample it to an image with 2.0 x 2.0 x 2.0 mm resolution and keep the images aligned. I…
RemiDav
  • 463
  • 3
  • 16
6
votes
1 answer

What is difference between get_data and get_fdata in Nibabel library?

I'm working with Nibabel to read some .nii files. I came across different examples and some of them use get_data() function while some of them use get_fdata() function. I could not find what the difference is in their documentation (nibabel manuel).…
umitkilic
  • 327
  • 1
  • 4
  • 17
4
votes
4 answers

How to get images intensity matrix from Nifti images with Nibabel?

i'm new with NiBabel. I want to know how to get intensity matrix from a Nifti images with this library. I use the following script to get voxels: import nibabel as ni example_img = ni.load('myImage.nii') data = example_img.get_data() I thought at…
chaw359
  • 505
  • 1
  • 5
  • 14
3
votes
0 answers

.nii.gz file to properly oriented grayscale image

I have been doing some deep learning, usually with normal image dataset like jpeg or png. Recently, I came across a dataset where I have been provided with test images as png/jpeg with ground truth in .nii.gz file. If I open the .nii.gz file it…
prc777
  • 211
  • 1
  • 7
3
votes
2 answers

Loading a Nifti through Nibabel and using the shape function

I have a nifti file 1.nii.gz Now, i never dealt with nifti files. So, just opening it using this software i realized that a nii.gz is a sort of container that contains 3 arrays of 2d pictures. In fact, if i scroll the mouse i can see 448 2d…
AleWolf
  • 133
  • 1
  • 6
3
votes
1 answer

Aligning nifti files with different shape and q_offset values in header

I have a whole-body MRI scans with the header below: { dim : [ 3 320 260 96 1 0 0 0] pixdim : [1. 1.40625 1.40625 3. 0.00436 0. 0. 0. ] qoffset_x : -216.09375 qoffset_y :…
Jyotirmay
  • 1,533
  • 3
  • 21
  • 41
3
votes
1 answer

Why does Nibabel change the size of my file?

I am working with images in the format nii.gz. Therefore, I am using nibabel in order to open them. The problem is that when I open the images, transform them to numpy arrays and convert them back to Nifti format, the output size is changed. The…
2
votes
1 answer

How to Flip MRI image in Python

I am trying to flip image shown in picture 1 to match the orientation of the image in picture 2, but I am not sure how. This is how image should be oriented: Any ideas how I can do this in Python with SimpleITK or nibabel for example?
CodingAddict
  • 181
  • 2
  • 15
2
votes
2 answers

How to get transformation affine from ITK registration?

Given 3D MRI scans A, B, and C I want to perform an affine (co)registration of B onto A, take the transformation affine matrix of the registration and apply it on C. My problem is that the affine matrix of the registration transform has the wrong…
Spenhouet
  • 6,556
  • 12
  • 51
  • 76
2
votes
1 answer

How to check NIFTI image is in the right orientation/position with Python

I am new here. Currently learning about medical imaging data on Python and wondering if it is possible to identify the NIFti image is in the right orientation and how to do the transformation. I looked up online and found some algorithm to 'rotate'…
amyleeslie
  • 21
  • 1
  • 3
2
votes
3 answers

How to resize a nifti (nii.gz medical image) file

I have some medical images of nii.gz format which are of different shapes. I want to resize all to the same shape inorder to feed to a deep learnig model, I tried using resample_img() of nibabel, but it destroys my images. I want to do some other…
Shilpa Mathew
  • 31
  • 1
  • 2
2
votes
2 answers

How to compute the volume of a single voxel of nifti medical image?

I have loaded a nifti image file using nibabel tool and I have played with some properties. But I don’t have idea how to compute the volume (in mm³) of a single voxel.
Carlao
  • 74
  • 1
  • 5
2
votes
0 answers

Multiprocessing Pool gets stuck

The code below is extracted from a much longer script. The sequential version (without multiprocessing) works fine. However, when I use Pool, the script gets stuck in a specific line. I'd like to apply the same function crop_image in parallel to…
Tommaso Di Noto
  • 1,208
  • 1
  • 13
  • 24
2
votes
2 answers

Swap axes of a 3D image in nilearn/numpy

I am working with some neuroimaging data and my dimensions for a scan is (100, 150, 100). I am currently working with the nibabel formatted file. Is there a nice way to swap the axes? For example, I want my image to be (100, 100, 150). I would…
intl
  • 2,753
  • 9
  • 45
  • 71
1
2 3 4 5 6