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

Methods for registering a sequence from one MRI sequence to another?

I am working on an AI project that involves segmentation. I currently have many volumes with manually generated segmentations on SPACE MRI sequence, but need to shift these over to volumes on a DESS sequence. SPACE volumes have dimensions of (160,…
0
votes
1 answer

Nibabel cannot read gz file

im trying to load my image with nibabel, but I keep getting an "ImageFileError". kindly note that my image is in .gz format. I get the error "file is not a gzip file":
a__ys
  • 28
  • 5
0
votes
0 answers

How can I flip .nii images using batch processing with python-nibabel?

I have 180 .nii fMRI images for each patient and I need to flip them from right to left. I've tried using 'for' statement to batch processing these images. But it seems like The following code only produce one result. Here is the following…
Lena
  • 1
  • 1
0
votes
0 answers

How to convert 3D file (.nii) to 2D sliced .tiff file?

I have a .nii file and I've tried to convert it to 2d sliced tiff file, this is what I do: import nibabel as nib import numpy as np from tifffile import imsave import tifffile as tiff #load nii a = nib.load('/a.nii').get_fdata() print(np.shape(a))…
0
votes
0 answers

raise ImageFileError(f'Cannot work out file type of "{filename}"') when working with nnunet

I'm working with nnunet network with a custom dataset. Everything works fine, I've created the new Task 88, I've launched the !nnUNet_plan_and_preprocess -t 88 --verify_dataset_integrity command and all the training cases and after the labels are…
Vibe98
  • 1
0
votes
1 answer

How to read multiple Nifti files from the same folder with Nibabel?

I did see a couple of tuts related to Nibabel, that work fine when you are reading only one nii image, but I need to read 167 files from the same folder, and I don't understand how to do it. I tried using glob as we use it for OpenCV, but it doesn't…
John
  • 47
  • 5
0
votes
1 answer

Trying to turn a non-cubic .nii brain scan into a cubic one using numpy - data deteriorating - doesnt look the same

I have a .nii brain scan file converted to an array with dimensions (240, 240, 155). I need a cubic 3D array - so I am concatenating 2 arrays of shape (240, 240, 43) and (240, 240, 42) to the original array along the 2nd axis (axis=2), which results…
0
votes
0 answers

Invalid number of channels in input image: 'VScn::contains(scn)' where 'scn' is 512 when displaying .nii.gz image on Google Colab

I need help with displaying the image. Image shape is (86, 512, 512). I have tried using solutions from other similar questions posted here on stackoverflow, but nothing worked so far. Code: import nibabel as nib from google.colab.patches import…
AurumTechie
  • 166
  • 3
  • 14
0
votes
1 answer

How can I create a 3D nibabel image using 2D nibabel images?

I have a lot of 2D nibabel (.nii) slices and I need to create a 3D nibabel (.nii) image from those slices, is there any way to do it?
0
votes
1 answer

Memmap AttributeError when trying to access nifti image header

After loading a NIFTI (.nii) image (using Nibabel) with the code scan = nibabel.load(filepath), it is useful to display the image header information via scan.header. If you call scan.get_fdata() before calling scan.header, the error arises:…
0
votes
1 answer

Problems with converting all slices into nii.gz at once

I'm using the following code to convert all my 332 npy slices into the nii.gz format: import numpy as np import nibabel as nib file_dir = "D:/Volumes convertidos LIDC/" fileNPY1 = "slice200.npy" img_array1 = np.load(file_dir + fileNPY1) nifti_file…
0
votes
1 answer

nibabel.filebasedimages.ImageFileError for large label files

I am getting the following error when loading a large labeled NIFTI file of size 14.4 MB. Traceback (most recent call last): File "/home/miran045/reine097/projects2/lab2im/lab2im/dcan/reproduce_load_error.py", line 7, in img =…
Paul Reiners
  • 8,576
  • 33
  • 117
  • 202
0
votes
2 answers

How to correctly convert RGB images into nifty format?

I have RGB images which I'm loading as a numpy array. I would like to convert these images into the nifty format, which I can open using ITK-SNAP (http://www.itksnap.org/pmwiki/pmwiki.php). Here is what I have tried to do: import nibabel as nib…
gab
  • 792
  • 1
  • 10
  • 36
0
votes
1 answer

how to convert a nift folder to png images?

*library there is a mostly known library imported from NumPy and imageio import NumPy as np import os import nibabel as nib import imageio // method where I have I write code to convert a nift to png Method convert a nift(.nii) image to png…
Sir Mayur
  • 1
  • 1
  • 1
0
votes
1 answer

Using nibabel to save nifti in "SPM" style

I have used python to analyse some fMRI data and would now like to save my results as niftis that I can then use in an SPM analysis. My data scores is an array of float64 of shape (97, 115, 97). I have used the following code to save it: import…
Max
  • 405
  • 2
  • 11