Complex variable in test clause

Hi,

Playing with FFT and Images and prepping to do some thresholding to look for structure in the images.

I have 2 complex waves of equal size, ten_fft and test,  and was testing this statement:

test = magsqr(tem_fft) >10000 ? Tem_fft : cmplx(0,0)

It returns an error "function not available for this number type"

How do I proceed?

Andy

 

Igor's simplistic handling of compiling complex expressions sees `magsqr()` at the start and assumes a real result. I think you'll have to use the less-compact if-else-endif construction, and to make that fit in a wave assignment will require putting your expression into a separate function. There might be some tricky and hard to read construction that would get around the problem, but it's probably not worth it.

> There might be some tricky and hard to read construction that would get around the problem, but it's probably not worth it.

Have you tried if SelectNumber supports complex? If not you could write your own SelectComplexNumber. I've written a similiar SelectWave to be able to write something like:

WAVE outCombinedType = SelectWave(WaveExists(outT), out, outT)

Have you tried if SelectNumber supports complex?

It does, so this code should work:

test = SelectNumber(magsqr(tem_fft) > 10000, tem_fft, cmplx(0,0))

It does in deed work, with one small caveat to keep in mind.  SelectNumber is looking for 0,1 in this case so if it evaluates as true and returns a 1, it will use the second value, complex(0,0).  Conversely if it returns false or 0, if will use the first term, tem_fft.  Counter to the naive scanning of the function.

Andy

In reply to by hegedus

hegedus wrote:

It does in deed work, with one small caveat to keep in mind.  SelectNumber is looking for 0,1 in this case so if it evaluates as true and returns a 1, it will use the second value, complex(0,0).  Conversely if it returns false or 0, if will use the first term, tem_fft.  Counter to the naive scanning of the function.

Andy

Good catch, yes those inputs should be reversed. 

 

Any time you encounter the error "function not available for this number type" you should ditch standard instructions and use MatrixOP which takes care of real and complex waves without this bellyaching.  In this particular case:

MatrixOP/O test=tem_fft*greater(abs(tem_fft),threshold)

AG