From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW MathScript RT Module

cancel
Showing results for 
Search instead for 
Did you mean: 

When running some code I get error -90018

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...

 

Screenshot 2016-01-15 14.34.24.png

 

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?  

0 Kudos
Message 1 of 10
(6,979 Views)

Are you using a complex number anywhere?

0 Kudos
Message 2 of 10
(6,939 Views)

No

 

I'm processing a intensity spectrogram, all values in the array are doubles between 0. and 1.

0 Kudos
Message 3 of 10
(6,929 Views)

Hmmm... What does line 25 look like in the others?

0 Kudos
Message 4 of 10
(6,914 Views)

In stretchlim, the 25th line is a blank line

 

in imadjust, there is less than 25 lines

0 Kudos
Message 5 of 10
(6,903 Views)

Can you clarify what you mean by porting over code? What exactly are you doing?

0 Kudos
Message 6 of 10
(6,887 Views)

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.

0 Kudos
Message 7 of 10
(6,879 Views)

incidently, commenting out that line makes the error go away.

0 Kudos
Message 8 of 10
(6,864 Views)

Oh wow, that's really odd. Are you sure everything is an integer and nothing is complex?

0 Kudos
Message 9 of 10
(6,859 Views)

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

 

 

 

 

0 Kudos
Message 10 of 10
(6,849 Views)