klasma / BaxterAlgorithms

Software for segmentation, tracking and analysis of cells in microscope image sequences.
MIT License
40 stars 13 forks source link

Unexpected Standard exception from MEX file #14

Closed Sum02dean closed 4 years ago

Sum02dean commented 4 years ago

Hi Klas,

I am trying to run segmentation and tracking by calling BaxterAlgorithmsTermial.m from within matlab. This results in an "unexpected error" being thrown therefor I can not complete tracking. Here is my script:

% Location of the experiments folder 
aEx = '/projects/cp/TCRP/baxter/test_data/experiment/';

% Name of the tracking metadata file
aVer = 'tracking_test';

% Run BaxterAlgorithmsTerminal for experiment folder
BaxterAlgorithmsTermial(aEx, aVer);

And here is the new error

Computing features for image 86 / 90
Computing features for image 87 / 90
Computing features for image 88 / 90
Computing features for image 89 / 90
Computing features for image 90 / 90
Segmentation Done.

Running ViterbiTrackLinking from Matlab.

Error using Track (line 179)
Unexpected Standard exception from MEX file.
What() is:std::bad_array_new_length
..

Error in SaveTrack (line 41)
        cells = Track(aImData, 'SegmentationCores', aSegmentationCores);

Error in BaxterAlgorithmsTermial (line 43)
parfor i = 1:length(allSeqPaths)

Error in dean_image_data (line 22)
BaxterAlgorithmsTermial(aEx, aVer);

Note: This is after I compiled the mex files from an earlier issue.

Best,

Dean

klasma commented 4 years ago

Hi Dean,

I cannot figure out what is wrong. I do not get this exception on Windows. Can you paste the following lines on line 90 of ViterbiTrackLinking.cpp, recompile and run the program again.

lout << "tMax = " << tMax << endl;
lout << "maxCount = " << maxCount << endl;
lout << "numMigs = " << numMigs << endl;
lout << "numMits = " << numMits << endl;
lout << "numApos = " << numApos << endl;
lout << "numAppear = " << numAppear << endl;
lout << "numDisappear = " << numDisappear << endl;

That will print the values of all variables that could have incorrect values due to the changes in my last commit. Hopefully we find something there which explains the exception.

Sum02dean commented 4 years ago

Hi,

Here is the printouts that you requested:

Running ViterbiTrackLinking from Matlab.

tMax = 90
maxCount = -3
numMigs = 29797
numMits = 68861
numApos = 0
numAppear = 8502
numDisappear = 8517
Error using Track (line 179)
Unexpected Standard exception from MEX file.
What() is:std::bad_array_new_length
..

Error in SaveTrack (line 41)
        cells = Track(aImData, 'SegmentationCores', aSegmentationCores);

Error in BaxterAlgorithmsTermial (line 44)
parfor i = 1:length(allSeqPaths)
klasma commented 4 years ago

Exellent! Thank you! The problem is that maxCount is negative. Something went wrong when the dimensions of one of the inputs was extracted. That was the problem before my last commit. Have you updated the whole repository including ViterbiTrackLinking.cpp?

Is this what you have on lines 72-85?

// Get the dimensions of the inputs.
const mwSize *countSize = mxGetDimensions(prhs[1]);
const mwSize *migSize = mxGetDimensions(prhs[2]);
const mwSize *mitSize = mxGetDimensions(prhs[3]);
const mwSize *apoSize = mxGetDimensions(prhs[4]);
const mwSize *appearSize = mxGetDimensions(prhs[5]);
const mwSize *disappearSize = mxGetDimensions(prhs[6]);
int tMax = (int) mxGetNumberOfElements(prhs[0]);  // Allow numDetsA to be either row or column vector.
int maxCount = countSize[1]-3; // first element is t, second is detection index and the third is the debris probability
int numMigs = migSize[0];
int numMits = mitSize[0];
int numApos = apoSize[0];
int numAppear = appearSize[0];
int numDisappear = disappearSize[0];

If so I am missing something here.

Sum02dean commented 4 years ago

Good Morning!

Yes the issue was that I only copied the Segmentation directory... My mistake, everything seems in order now. I will make a new pull request.

tack så mycket

Sum02dean commented 4 years ago

Merge request has been sent. Please if you see two merge requests, use the most recent one titled "Merge Request Dean - Compiled and functioning code." Decline the other.