Print

Print


Dear Christopher,

Of course - thank you!

For the record, both of these work to enter variables into spm_imcalc:


spm_imcalc_ui({'input1.img','input2.img'},'output.img',['i2.*(i1>' sprintf('%d',val1) ')']);

spm_imcalc_ui({'input1.img','input2.img'},'output.img',['i2.*(i1>' num2str(thresh1) ')']);


(It was a silly issue of brackets; I'd tried num2str before, but failed.)


Best regards,

Elliott


On Sun, May 15, 2011 at 8:17 PM, Watson, Christopher <[log in to unmask]> wrote:
It'll probably work if you use sprintf
________________________________________
From: SPM (Statistical Parametric Mapping) [[log in to unmask]] On Behalf Of G Elliott Wimmer [[log in to unmask]]
Sent: Sunday, May 15, 2011 6:45 PM
To: [log in to unmask]
Subject: [SPM] variable use in spm_imcalc

Hi,

I'm having a simple problem with spm_imcalc / spm_imcalc_ui.  I need to read in a variable to be used in the imcalc equation.

The basic idea is to do this:

spm_imcalc_ui({'input1.img','input2.img'},'output.img','i2.*(i1>thresh1)')

in a batch script, where 'thresh1' is a value previously calculated for each subject.  The function works if I use a simple number, e.g. '1', in place of the variable.

However, adapting the command to read in the extra variable, for example:

spm_imcalc({'input1.img','input2.img'},'output.img','i2.*(i1>thresh1)',{[],[],[],[]},thresh1);

has not worked.  I think I must be missing something about the syntax.  (Judging by the lack of questions posted to the board on imcalc and variables, it's something obvious, or it's a function that SPM people never use.)

Thank you for any help!

Best regards,

Elliott


Dept. of Psychology
Columbia University
New York, NY