Niftiwrite - how to set orientation?

Hi,
I am combining two MRI images on matlab and I rewrote the combined image into a niftifile using niftiwrite command. However the new image lacked orientation and coordinate when I opened in image viewer software (FSLeyes).
Can somebody suggests how to fix this issue? Thank you.

댓글 수: 2

Walter Roberson
Walter Roberson 2023년 2월 13일
permute() the volume data before writing it?
Jacob Bunyamin
Jacob Bunyamin 2023년 2월 14일
I have tried permute and rotate but it did not worked

댓글을 달려면 로그인하십시오.

답변 (1개)

Abhijeet
Abhijeet 2023년 3월 8일

0 개 추천

Hi Jacob,
To fix the issue with the orientation and coordinate information missing in the combined MRI image that you wrote into a niftifile using the niftiwrite command in MATLAB, you can follow these steps:
  1. Load the combined MRI image and the original MRI image that you used to create the combined image into MATLAB.
  2. Use the "niftiinfo" function to extract the header information from the original MRI image. This header information contains the orientation and coordinate information that is missing in the combined image.
  3. Copy the header information from the original MRI image to the combined image using the "niftiwrite" function with the 'Header' argument.
  4. Save the combined image with the corrected header information to a new niftifile.
You can try this code :
% Load the original MRI image and the combined MRI image
original_image = niftiread('original_image.nii');
combined_image = imread('combined_image.nii');
% Extract header information from the original image
original_header = niftiinfo('original_image.nii');
% Copy header information to the combined image
niftiwrite(combined_image, 'fixed_combined_image.nii', 'Header', original_header);
This code should fix the issue with the missing orientation and coordinate information in the combined image.
Thank You

카테고리

도움말 센터File Exchange에서 Neuroimaging에 대해 자세히 알아보기

질문:

2023년 2월 13일

답변:

2023년 3월 8일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by