Effacer les filtres
Effacer les filtres

How to convert file format from .mat to .nii format

42 vues (au cours des 30 derniers jours)
Dhafer
Dhafer le 8 Juin 2013
Dear All
I'm beginner in using mat lab. I don't have much information to do coding by mat lab. I really need you help.
I would like to create nii file from 16 mat files:
  1. .nii file from 16 mat files for T2_star (my file name).
  2. .nii file from another 16 files for T2 (my 2nd file name).
for slice 1:16;
  1. - load mat file.
  2. - store it in 3D variable, because my files are 2D matrix.
end save_nii
%% Please send explanation with each step and appreciated your help.
Regards
Dhafer
  1 commentaire
Walter Roberson
Walter Roberson le 8 Juin 2013
What is .nii format? Something to do with National Instruments? But T2 and T2_star are MRS and MRI terms, suggesting that .nii might be a format used by a spectrometer or something like that ?

Connectez-vous pour commenter.

Réponse acceptée

Dhafer
Dhafer le 11 Juin 2013
Modifié(e) : Walter Roberson le 18 Juil 2015
Dear All The following code is to create .nii file from 16mat files.
what I need is to do opiste. Svae .nii file to 16 mat files.
files=dir('*.mat');
A=[10:16 1:9] % this is because the volume not in the right order.
for f=1:16;
g=A(f);
load(files(f).name);
M0vol(:,:,g)= M0;
t2starvol(:,:,g)=T2star;
r2starvol(:,:,g)=R2star;
end
nii=make_nii(M0vol);
save_nii(nii,'N_144_M0.nii');
nii=make_nii(r2starvol);
save_nii(nii,'N_144_R2star.nii');
nii=make_nii(t2starvol);
save_nii(nii,'N_144_T2star.nii');
  1 commentaire
tahoorasf
tahoorasf le 10 Mar 2015
in this line M0vol(:,:,g)= M0; what is M0?

Connectez-vous pour commenter.

Plus de réponses (1)

Dhafer
Dhafer le 11 Juin 2013
Modifié(e) : Walter Roberson le 11 Juin 2013
Dear All
I have written this code but there is problem with load line! I do not know what is the error?
files=dir('N_144_slice_*.mat');
A=[10:16 1:9] % this is because the volume not in the right order.
for f=1:16;
g=A(f);
load(files(f).name);
M0vol(:,:,g)= M0;
t2starvol(:,:,g)=T2star;
r2starvol(:,:,g)=R2star;
end
nii=make_nii(M0vol);
save_nii(nii,'N_144_M0.nii');
nii=make_nii(r2starvol);
save_nii(nii,'N_144_R2star.nii');
nii=make_nii(t2starvol);
save_nii(nii,'N_144_T2star.nii');
  2 commentaires
Walter Roberson
Walter Roberson le 11 Juin 2013
Do you get an error message?
Dhafer
Dhafer le 11 Juin 2013
Modifié(e) : Walter Roberson le 18 Juil 2015
yes,
I solved the error message and I really need you help to do the opposite code for me.
The following code is to create .nii file from 16mat files.
what I need is to do opiste. Svae .nii file to 16 mat files.
files=dir('*.mat'); ]
A=[10:16 1:9] % this is because the volume not in the right order. for for f=1:16;
g=A(f);
load(files(f).name);
M0vol(:,:,g)= M0;
t2starvol(:,:,g)=T2star;
r2starvol(:,:,g)=R2star;
end
nii=make_nii(M0vol);
save_nii(nii,'N_144_M0.nii');
nii=make_nii(r2starvol);
save_nii(nii,'N_144_R2star.nii');
nii=make_nii(t2starvol);
save_nii(nii,'N_144_T2star.nii');
Your help is appreciated.
Regards
Dhafer

Connectez-vous pour commenter.

Catégories

En savoir plus sur MATLAB dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by