Complex variable in test clause
hegedus
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.
June 11, 2024 at 09:49 am - Permalink
> 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)
June 11, 2024 at 11:01 am - Permalink
It does, so this code should work:
June 11, 2024 at 01:09 pm - Permalink
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
June 11, 2024 at 03:50 pm - Permalink
In reply to It does in deed work, with… by hegedus
Good catch, yes those inputs should be reversed.
June 11, 2024 at 04:43 pm - Permalink
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
June 12, 2024 at 08:58 am - Permalink