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
2
votes
2 answers

ImageFileError: Cannot work out file type of ".nii"

When I try to load my .NII file as a 4D Niimg-like object (I've tried both nilearn and nibabel), I get the below error Error: ImageFileError: Cannot work out file type of "/Users/audreyphan/Documents/Spring2020/DESPO/res4d/1/res4d_anat.nii" Here…
audreyphan
  • 21
  • 1
  • 2
2
votes
1 answer

How to avoid big data problem when dealing nii.gz?

I have dataset of nii.gz files each around 1G including 4d tensor. There are two ways of reading them that I am aware of as the following: img = nib.load('fMRI.nii.gz') imgarr = np.array(img.dataobj) or img = nib.load('fMRI.nii.gz') imgarr =…
Saeed
  • 598
  • 10
  • 19
2
votes
2 answers

How to modify orientation of mgh/dicom/nifti file using nibabel

I have a hard time, figuring out a proper affine transformation for 3 different views i.e. coronal, axial and saggital, each having separate issues like below: 1: Axial color map get overlapped with the saggital original view. 2: Similarly Sagittal…
Jyotirmay
  • 1,533
  • 3
  • 21
  • 41
1
vote
0 answers

Need help fixing my K-means clustering on MRI-data Python script

I'm using KMeans clustering from the scikitlearn module, and nibabel to load and save nifti files. I want to: Load a nifti file Perform KMeans clustering on the data of this nifti file (acquired by using the .get_fdata() function) Take the labels…
Björn
  • 11
  • 2
1
vote
1 answer

what is the meaning for each coordinate in ( mri_image.shape ) using nibabel library?

I am checking the shape of the MRI data that I downloaded from the ADNI website. it supposes to be a 3D image but this code produces 4 coordinates! I need to know what each coordinate here means. print(img.shape) the output that I got is (170, 256,…
eso
  • 11
  • 1
1
vote
1 answer

Coloring area between pixels based on thickness

I'm trying to isolate the gray matter in a brain image and color it based on the cortical thickness at each point giving a result similar to this: Cortical thickness map based on this original: Original brain scan So far I have segmented the white…
1
vote
1 answer

How can I obtain 2D slices from a 3D NIfti volume?

I'm currently using the following code to convert DCM slices into NIfti images: import dicom2nifti import os dicom2nifti.convert_directory("input_path", "output_path", compression=True, reorient=True) This code will generate a 3D NIfti volume. How…
1
vote
1 answer

Problems with npy to nii.gz conversion

I'm trying to convert a .npy image to a nii.gz image, I'm having various problems even though I'm following instructions correctly. This is the code I'm using: import numpy as np import nibabel as nib file_dir = "D:/teste volumes slicer/" fileNPY1…
1
vote
3 answers

Install module in python locally

I have a very basic question. I want to install a new module on my computer in order to use it in Python (via Spyder). When I install the package via pip everything seems to work fine. When I want to import the package in my script it says that…
maxed
  • 11
  • 3
1
vote
0 answers

Nibabel does not load slope and inter parameters

I am saving some nparray into nifti format using nibabel package. I specify a slope and intercept value in order to scale data back to their original format. However, the scale and intercept information are not available anymore when I load back the…
BayesianMonk
  • 540
  • 7
  • 23
1
vote
0 answers

Orientation of images using nibabel

I have started reading about the orientation of Nifti images and wanted to clarify some concepts. Here are some of the questions: When accessing the data of an image: image.get_fdata() are the axes of the NumPy array always the same with respect to…
Ramon
  • 501
  • 3
  • 13
1
vote
2 answers

change voxel values in nifti image and save it

I am going to read a nifti image and change the values of the voxels and save the new nifti image similar to the main image but only different voxel values. In other words I want my labels in segmentation image be from 0 to 7 instead of having…
parvaneh
  • 490
  • 2
  • 6
  • 16
1
vote
1 answer

Load 3D Niftii images and save all slices for axial, coronal, saggital?

I have some 3D Niftii datasets of brain MRI scans (FLAIR, T1, T2,..). The FLAIR scans for example are 144x512x512 with Voxel Size of 1.1, 0.5, 0.5 and I want to have 2D-slices from axial, coronal and sagittal view, which I use as input for my…
Nanex1011
  • 39
  • 5
1
vote
2 answers

Training 3dconv neural network fails; loss converges at .6931

I wrote a script to train a neural network to use .nii files as input, using the tutorial from TensorFlow here https://www.tensorflow.org/tutorials/load_data/images. I changed it slightly to work with NiBabel and .nii files but it still follows the…
1
vote
1 answer

Reorder Nifti file axes

I have some 3D nifti files of dimension (50, 100, 50). I would like to flip the the y and z axes so that the dimension will be (50, 50, 100). What is the best way to go about doing this and how would I modify the associated affine with the…
intl
  • 2,753
  • 9
  • 45
  • 71