Could you help me debugging this code in which I extract the mean time course of a roi of an fmri image

6 vues (au cours des 30 derniers jours)
I have an fmri image and I have to extract the time course of a certain roi and then find the mean of this. I did the code but I don't know if it is right, because I don't know how to work with 3d and 4d images. So could someone help me debug this code?
Thank you so much.
%%finding the roi I need
nii = load_nii('Auditory.nii.gz');
data = double(nii.img);
for j = 1:size(data,3)
imagesc(data(:,:,j));
n = 5;
pause(n);
close;
end
%%extraction of time course
nii = load_nii('vol0008.nii.gz');
fMRI = double(nii.img);
voxel = 0;
times = [];
for i = 1:size(data,1)
for j = 1:size(data,2)
for k = 1:size(data,3)
if data(i,j,k) == 5
voxel = voxel+1;
time = fMRI(i,j,k,w);
times(end+1) = time;
end
end
end
end
voxels = 1:voxel;
subplot(1,2,1);
plot(voxels,times);
mean1 = mean(voxels);
mean2 = mean(times);
time_course_medio = [media1;media2];
subplot(1,2,2);
plot(time_course_medio);
  2 commentaires
John D'Errico
John D'Errico le 21 Jan 2017
You don't supply the images, so how can anyone actually test your code, which is code that apparently does not work, for some unexplained reason. Nobody can then test your code. It does something you have not explained at all well, but it does not work.
You could try simply deleting the code, replacing it with an empty file. It still will not do what you want, but it will run much more quickly. :)
Tara Chand
Tara Chand le 31 Mar 2017
Replace 'time = fMRI(i,j,k,w)' with 'time = squeeze(fMRI(i,j,k,:))' for getting the time course from the voxel i,j,k;

Connectez-vous pour commenter.

Réponses (0)

Catégories

En savoir plus sur Neuroimaging 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