大量のファイルをイン​プットするコードを簡​潔に書くことは可能で​しょうか?

6 vues (au cours des 30 derniers jours)
YASUNORI HAMAGUCHI
YASUNORI HAMAGUCHI le 10 Déc 2019
nrun = 1; % enter the number of runs here
jobfile = {'C:\0spm Caltech\normalization_job.m'};
jobs = repmat(jobfile, 1, nrun);
inputs = cell(2, nrun);
for crun = 1:nrun
inputs{1, crun} ={'C:\0spm Caltech\data\0051456\meanrest.nii,1'};
inputs{2, crun} = {'C:\0spm Caltech\data\0051456\rrest.nii,1'
'C:\0spm Caltech\data\0051456\rrest.nii,2'
'C:\0spm Caltech\data\0051456\rrest.nii,3'};
end
spm('defaults', 'FMRI');
spm_jobman('run', jobs, inputs{:});
ファイルをインプットするために
上記のコードでは3個のファイルを読みこんでいますが、
150個のファイルを読みこむ方法を教えていただきたいです。
'C:\0spm Caltech\data\0051456\rrest.nii,150'までのファイルを読みこむ必要があります。
よろしくお願いします。

Réponse acceptée

michio
michio le 10 Déc 2019
Modifié(e) : michio le 10 Déc 2019
spm の機能には詳しくないのですが、inputs にファイル名を並べるのであれば
for crun = 1:nrun
inputs{1, crun} ={'C:\0spm Caltech\data\0051456\meanrest.nii,1'};
inputs{2, crun} = cell(150,1);
for ii = 1:150
inputs{2,crun}{ii} = ['C:\0spm Caltech\data\0051456\rrest.nii,' num2str(ii)];
end
end
でどうでしょう。
  1 commentaire
YASUNORI HAMAGUCHI
YASUNORI HAMAGUCHI le 11 Déc 2019
ありがとうございます!!
処理を実行することが出来ました。
matlab初心者でコードの書き方がわからず、悩んでましたが、
解決しました。

Connectez-vous pour commenter.

Plus de réponses (1)

YASUNORI HAMAGUCHI
YASUNORI HAMAGUCHI le 11 Déc 2019
重ねて質問してもよろしいでしょうか。
matlabbatch{1}.spm.spatial.normalise.estwrite.subj.vol = {'C:\0spm Caltech\data\0051456\meanrest.nii,1'};
matlabbatch{1}.spm.spatial.normalise.estwrite.subj.resample = cell(150,1);
for ii = 1:150
matlabbatch{1}.spm.spatial.normalise.estwrite.subj.resample{ii} = ['C:\0spm Caltech\data\0051456\rrest.nii,' num2str(ii)];
end
ご回答を参考に別の箇所でもコードを書いてみたのですが、うまく行きません。
下線部は何か間違っていますか。
よろしくお願いいたします
matlabbatch{1}.spm.spatial.normalise.estwrite.subj.resample = {
'C:\0spm Caltech\data\0051456\rrest.nii,1'
'C:\0spm Caltech\data\0051456\rrest.nii,2'
'C:\0spm Caltech\data\0051456\rrest.nii,3'}
このように150個のファイルを読みこむものです。
  2 commentaires
michio
michio le 11 Déc 2019
コードに気になる点は特に見当たらないですが、、エラーメッセージなどあるともしかしたら・・。spm 特有の何かに起因しているのであれば、私には経験が無いので他の方のコメントを待ちましょう。
YASUNORI HAMAGUCHI
YASUNORI HAMAGUCHI le 11 Déc 2019
ご丁寧にありがとうございます。
そのようにさせていただきます。
ありがとうございました。

Connectez-vous pour commenter.

Catégories

En savoir plus sur アプリの作成 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!