Dear Bob and Torben,
Not very elegant but if you have enough memory to hold the data twice in
memory then the following code should do the job:
Ni = nifti('4D.nii');
No = nifti;
No.mat = Ni.mat;
d = diff(Ni.dat(),1,4);
No.dat = file_array('diff.nii',size(d),Ni.dat.dtype);
create(No);
No.dat(:,:,:,:) = d;
Best regards,
Guillaume.
On 14/11/2018 10:16, Torben Lund wrote:
> Dear Bob
>
> The current version of ImCalc does only support multiple image in single
> image out equations. Until the function is changed you will need to use
> a loop and run imcalc several times.
>
> Best
> Torben
>
>
>
>
>> Den 13. nov. 2018 kl. 23.10 skrev Bob Bob <[log in to unmask]
>> <mailto:[log in to unmask]>>:
>>
>> Hello,
>>
>> I am having an issue with imcalc that I cannot quite see where I'm
>> going wrong.
>>
>> I want to create image-by-image difference images across my
>> timeseries. I have tried to use the function 'diff(X)' but I keep
>> getting the error '"diff(X)" produced incompatible image.' All the
>> images are from the same timeseries from the same subject.
>>
>> For reference, here is the batch I've been using.
>>
>> Any help appreciated!
>> Bob
>>
>> matlabbatch{1}.spm.util.imcalc.input = {'myimgs'
>> };
>> %%
>> matlabbatch{1}.spm.util.imcalc.output = 'output';
>> matlabbatch{1}.spm.util.imcalc.outdir = {'mydir'};
>> matlabbatch{1}.spm.util.imcalc.expression = 'diff(X)';
>> matlabbatch{1}.spm.util.imcalc.var = struct('name', {}, 'value', {});
>> matlabbatch{1}.spm.util.imcalc.options.dmtx = 1;
>> matlabbatch{1}.spm.util.imcalc.options.mask = 0;
>> matlabbatch{1}.spm.util.imcalc.options.interp = 1;
>> matlabbatch{1}.spm.util.imcalc.options.dtype = 4;
>
--
Guillaume Flandin, PhD
Wellcome Centre for Human Neuroimaging
UCL Queen Square Institute of Neurology
London WC1N 3BG
|