Dear Anca,
when you use "Save Batch and Script", you don't usually need to modify
the saved job file at all. The "<-X" mark should appear in the Batch
GUI for each input item that needs to be filled by your script. In your
case this would be the file list. Make sure there is an "<-X" mark for
the files to convert before "Save Batch and Script". Then just modify
the saved script to populate the inputs. spm_jobman('run'...) will take
care of passing the inputs to the appropriate items in the job.
There should be no mention of f_list in your job file, as it is not a
known variable in this context. This results in the "No batch job found
in 'Test_Conv_batch_job.m'" message, because MATLAB can't evaluate this
file.
Hope this helps,
Volkmar
Am Donnerstag, dem 15.09.2022 um 23:39 +0000 schrieb Anca-Larisa Sandu:
> Dear Volkmar,
>
> Thank you very much for your reply. It made me understand better the
> problem but I still wasn’t able to solve it.
> Indeed I was using the "Save Batch and Script" in the batch GUI.
> Now I suspect I was also not defining correctly the inputs in my job
> file:
>
> matlabbatch{1}.spm.util.import.dicom.data = f_list;
> matlabbatch{1}.spm.util.import.dicom.root = 'flat';
> matlabbatch{1}.spm.util.import.dicom.outdir =
> {'\Anca\Converted_TEST_PET'};
> matlabbatch{1}.spm.util.import.dicom.protfilter = '.*';
> matlabbatch{1}.spm.util.import.dicom.convopts.format = 'nii';
> matlabbatch{1}.spm.util.import.dicom.convopts.meta = 0;
> matlabbatch{1}.spm.util.import.dicom.convopts.icedims = 0;
>
> My main code remains the same:
> for crun = 1:nrun
> f_list_struct=dir(pwd);
> f_list_struct=f_list_struct(~endsWith({f_list_struct.name},
> '.imageHistory'));
> f_list=cellstr({f_list_struct(3:end).name}');
> inputs{1, crun} = (f_list); % DICOM Import: DICOM files -
> cfg_files - NOT WORKING
> end
> spm('defaults', 'PET');
> spm_jobman('run', jobs, inputs{:});
>
> The error message I get is the following:
>
> Warning: Load failed: 'Test_Conv_batch_job.m'
> > In spm_jobman>load_jobs (line 329)
> In spm_jobman (line 143)
> In Test_Conv_batch3 (line 28)
> Warning: No batch job found in 'Test_Conv_batch_job.m'
> > In spm_jobman>load_jobs (line 354)
> In spm_jobman (line 143)
> In Test_Conv_batch3 (line 28)
> Error using spm_jobman (line 246)
> No valid job.
>
> Error in Test_Conv_batch3 (line 28)
>
> (Line 28 is spm_jobman('run', jobs, inputs{:}); )
>
> I did verify my code and I get the correct list however I did not
> understand the “Your job should have an "<-X" mark for the input
> files”.
>
> Probably I am missing something obvious ☹
>
> Best regards,
> Anca
>
>
> On Wednesday, 14 September 2022 at 09:28:39 BST, Volkmar Glauche
> <[log in to unmask]> wrote:
>
>
> Dear Anca,
>
> can you be more specific about how this is not working for you? Does
> the call to spm_jobman return an error, does the job operate on wrong
> data or do you get warning/error messages during DICOM conversion?
>
> The f_list you create looks fine, also the assignment to the inputs
> cell array. Just to make sure, you may want to check the inputs array
> to verify that each input is a cellstr list of filenames. Your job
> should have an "<-X" mark for the input files, and it should be
> replicated in your script nrun times (this replication code will be
> generated automatically if you use "Save Batch and Script" in the
> batch GUI).
>
> Best,
> Volkmar
|