any(~isnan(img(:)))
sum(~isnan(img(:)))

should work.

The first will produce a 1 if there are real values (including 0). The second will produce a number greater than 0 if there are any real values (including 0).

You might also want to check to make sure that there are non-zero values as well.

Best Regards, Donald McLaren
=================
D.G. McLaren, Ph.D.
Postdoctoral Research Fellow, GRECC, Bedford VA
Research Fellow, Department of Neurology, Massachusetts General Hospital and
Harvard Medical School
Office: (773) 406-2464
=====================
This e-mail contains CONFIDENTIAL INFORMATION which may contain PROTECTED
HEALTHCARE INFORMATION and may also be LEGALLY PRIVILEGED and which is
intended only for the use of the individual or entity named above. If the
reader of the e-mail is not the intended recipient or the employee or agent
responsible for delivering it to the intended recipient, you are hereby
notified that you are in possession of confidential and privileged
information. Any unauthorized use, disclosure, copying or the taking of any
action in reliance on the contents of this information is strictly
prohibited and may be unlawful. If you have received this e-mail
unintentionally, please immediately notify the sender via telephone at (773)
406-2464 or email.



On Mon, Nov 14, 2011 at 12:29 PM, Roy Cox <[log in to unmask]> wrote:
Hi all,

Does anyone know of a way to check whether an img file actually holds data other than NaNs? (Other than opening the file from the gui and looking at it.)

I'm scripting my way through a large number of analyses, and sometimes a subject's data contains only NaNs. As I also use an implicit mask (where NaNs are masked out), such a state of affairs results in a completely masked out image. Is there a way to look at the img files to exclude the irrelevant ones? Is there a matlab function that has direct access to the data values in an img file?

Thanks,

Roy


--
Roy Cox, M.Sc. | Brain & Cognition Group | Department of Psychology | University of Amsterdam | Weesperplein 4 | 1018 XA Amsterdam | the Netherlands | room 3.21 | phone: +31 20 525 6847 | email: [log in to unmask]