MATLAB For Loop/coding question, any help greatly appreciated!
Afficher commentaires plus anciens
Hi all! I've attached my code below. Basically I'm trying to write a MATLAB script which hep analyze large sets of fMRI scans. Each patient has 1 structural MRI scan, and 1-2 functional MRI scan (the 'f'MRI part). The script here is intended to find the scans and start processing them. I've written this for just 2 patients (1=1:2) but it will eventually be for > 1000. The problem I'm having is allowing it to accept that some patients have 1 functional scan and others have 2 (either is okay). My current script only works if they have 2....Any help would be greatly appreciated! The part I'm specifically referring to is:
filename = sprintf('/media/nir/SharedDrive/Ben/BATCHtester1/Sub014%d_Ses1/Sub014%d_Ses1_Scan_0%d_BOLD%d.nii', i, i, j + 1, j)
Thanks! (see below for full code)
Ben
clear BATCH;
BATCH.filename= '/media/nir/SharedDrive/Ben/BATCHtester1/conn_2.mat';
BATCH.Setup.isnew=1;
BATCH.Setup.nsubjects=2;
for i = 1:2
for j = 1:2
filename = sprintf('/media/nir/SharedDrive/Ben/BATCHtester1/Sub014%d_Ses1/Sub014%d_Ses1_Scan_0%d_BOLD%d.nii', i, i, j + 1, j)
BATCH.Setup.functionals{i}{j}= filename;
clear filename;
end
end
for i = 1:2
filename = sprintf('/media/nir/SharedDrive/Ben/BATCHtester1/Sub014%d_Ses1/Sub014%d_Ses1_Scan_01_ANAT1.nii', i, i)
BATCH.Setup.structurals{i}= filename;
clear filename;
end
BATCH.Setup.preprocessing.steps={'default_mni'};
BATCH.Setup.preprocessing.fwhm=8;
BATCH.Setup.preprocessing.voxelsize_func=2;
BATCH.Setup.preprocessing.sliceorder=[1:2:47,2:2:47];
BATCH.Setup.RT=3.0;
BATCH.Setup.analyses=[1,2];
BATCH.Setup.voxelmask=1;
BATCH.Setup.voxelresolution=1;
BATCH.Setup.outputfiles=[0,1,0];
BATCH.Setup.roi.names={'LeftVentralStriatum','RightVentralStriatum', 'LeftDorsalPutamen', 'RightDorsalPutamen', 'LeftMedialDorsalThalamus', 'RightMedialDorsalThalamus', 'LeftVentralPutamen', 'RightVentralPutamen', 'LeftDorsalStriatum', 'RightDorsalStriatum'};
conn_batch(BATCH);
Réponses (0)
Catégories
En savoir plus sur Neuroimaging dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!