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

5 ビュー (過去 30 日間)
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 件のコメント
John D'Errico
John D'Errico 2017 年 1 月 21 日
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 2017 年 3 月 31 日
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;

サインインしてコメントする。

回答 (0 件)

カテゴリ

Help Center および File ExchangeNeuroimaging についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by