SPM99 Gem 3: NaNing zero values

Subject: Re: normalization of contrast images
From: John Ashburner 
Date: Wed, 2 Aug 2000 14:37:38 +0100 (BST)
To: spm@mailbase.ac.uk, gpagnon@emory.edu
  

[…]

| And, while I am at it, does anybody know how to convert a mask that
| has zeros outside the brain to a mask that has NaN outside the brain?
| I tried ImCalc with something like 'i1(find(i1==0))=NaN', but it
| doesn't like it.

By default, ImCalc outputs the data as 16 bit integer with scalefactors.
There is no NaN representation for this, so the data would need to be
written as floating point or double precision floating point.  I think
you can do this by typing something like:
        P     = spm_get(1,'*.img');
        Q     = 'output.img';
        f     = 'i1.*(i1./i1)';
        flags = {0,0,spm_type('float'),1};
        spm_imcalc_ui(P,Q,f,flags);

Best regards,
-John
  

Note you can NaN-out voxels below a threshold, say, 3:


f = 'i1 + 0./(i1>3)'

Also note that this is a general way for making spm_imcalc write out images with float or double precision; concisely


f = 'sqrt(i1)'; % whatever you like

spm_imcalc_ui('in.img','out.img',f,{[],[],spm_type('float')});

Using  [],[] instead of  0,0 ensures that default values will be used for those two flags.

2 thoughts on “SPM99 Gem 3: NaNing zero values

  1. Pingback: SPM2 Gem 9: Masking w/ ImCalc | NISOx Blog
  2. Pingback: SPM8 Gem 1: Zero NaN’s with the zeronan.m script | NISOx Blog

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s