From Saturday, Nov 23rd 7:00 PM CST - Sunday, Nov 24th 7:45 AM CST, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
From Saturday, Nov 23rd 7:00 PM CST - Sunday, Nov 24th 7:45 AM CST, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
01-15-2016 03:04 PM
Since the image processing toolkit is not available in Mathscript nodes, I've been porting some of the code over so that I can use it. Mostly it's been going well, but I ran into a wall today.
Currently I'm digging into imadjust.m, and thats led me to imhist (and imhistc). I've written a very simplified version of that (shown below) which works great when I run it in Matlab.
The mathscript node doesn't show any code errors, and the run arrow isn't broken so everything is good at that point, but when I run it, the following error pops up...
I assume this means that the error occurs in CHH_clinic_imhist.m, on line 25
this is my code for CHH_clinic_imhist.m...
function y_out =CHH_clinic_imhist( a, n ) %Simplification of the imhist function that is found in the signal %processing toolkit. imhist calls imhistc which is a compiled c function. A %version of that can be found at %https://code.google.com/p/mirone/source/browse/trunk/mex/imhistc.c?r=1874&spec=svn1874 % %This is derived mainly from that code y_out = zeros(n,1); D = size(a); %isScaled = true; top = 1; scale = (n)/top; for r=1:D(1) for c=1:D(2) zed = floor(a(r,c)*scale + 0.5)+1; if (zed < 0.0) y_out(1) = y_out(1) + 1; elseif (zed > n) y_out(n) = y_out(n) + 1; else y_out(zed) = y_out(zed) + 1; end end end end
Line 25 is...
y_out(zed) = y_out(zed) + 1;
So there are no function calls there. y_out is an array, and zed is an integer.
So the error doesn't make any sense to me. Am I looking in the right spot?
01-18-2016 05:06 PM
Are you using a complex number anywhere?
01-18-2016 09:48 PM
No
I'm processing a intensity spectrogram, all values in the array are doubles between 0. and 1.
01-19-2016 05:45 PM
Hmmm... What does line 25 look like in the others?
01-20-2016 08:53 AM
In stretchlim, the 25th line is a blank line
in imadjust, there is less than 25 lines
01-20-2016 06:06 PM
Can you clarify what you mean by porting over code? What exactly are you doing?
01-20-2016 10:45 PM
Simple, porting may not be the most precise word, but...
The functions in the image processing toolkit aren't available to the MathScript Modules, but I need them for my program. So i look at the code for the functions I need, I pick out the bits that my program needs specifically, and I use that code to write my own, simplifed versions that work for my specific program.
The primary function that I'm "porting" here is imadjust, which calls stretchlim, which calls imhist. Each of these I've gone through, picked out what I needed, and wrote my own (which I rename with the CHH_clinic_ prefix). I did all of this in Matlab, and tested them to make sure I got exactly the same numbers out that I got when using the original functions (I do). Once I was sure they worked, I moved them over to use in my MathScript module, I've actually done this with other functions as well, with much success. But I've come to a brick wall with this error. The program just slams to a halt, and I'm not even sure how to debug/troubleshoot it.
My functions work perfectly in Matlab, and in Mathscript, the error I get and the line that it's pointing to are nonsense. I don't even know where to begin debugging it.
01-21-2016 03:30 PM
incidently, commenting out that line makes the error go away.
01-21-2016 06:57 PM
Oh wow, that's really odd. Are you sure everything is an integer and nothing is complex?
01-22-2016 12:53 PM
well, not anymore.
the only thing that could make zed complex is if 'a' is complex, so to check I replaced 'a' with 'abs(a)'...and the program ran without crashing. So 'a' MUST be complex at that point.
Thing is, I'm sure that at that point, 'a' should be double. In fact, I went back to the identical code in Matlab, and checked a's data type at that point and it IS double.
I dunno, lol. I should have thought to do the abs trick earlier. Now I need to backtrack to see if I did in fact change something,
Cheers