DrCoffey / DeepSqueak

DeepSqueak v3: Using Machine Vision to Accelerate Bioacoustics Research
BSD 3-Clause "New" or "Revised" License
373 stars 89 forks source link

DS V3.01 Excel Export Bug #129

Closed Marrekko closed 3 years ago

Marrekko commented 3 years ago

Hi,

I've analyzed some data using the V3 from Agust 16 with Matlab 2021a. While exporting results to Excel, some files will produce a bug, some will be exported without problems. I don't really see the difference between them or what is causing this. Some files that do not work will hang up in early stages of exporting, some in later (according to the progress bar). So I guess there is a problem with single calls or boxes.

The command window reports repeatedly "lowering threshold" and will not stop until one interrupts the code, which doesn't really help to exactly find the error:

Operation terminated by user during CalculateStats (line 63)

In excel_Callback/loop_calls (line 21)
                stats =
                CalculateStats(I,windowsize,noverlap,nfft,rate,box,handles.data.settings.EntropyThreshold,handles.data.settings.AmplitudeThreshold);

In export_Calls (line 39)
    t = loop_function(Calls,hc,includereject,['Exporting calls from file ' num2str(j) ' of '
    num2str(length(fname))],handles,currentfile, audioReader);

In excel_Callback (line 34)
    export_Calls(@loop_calls,'_Stats.xlsx',hObject, eventdata, handles);

In gui_mainfcn (line 95)
        feval(varargin{:});

In DeepSqueak (line 29)
    gui_mainfcn(gui_State, varargin{:});

In
matlab.graphics.internal.figfile.FigFile/read>@(hObject,eventdata)DeepSqueak('excel_Callback',hObject,eventdata,guidata(hObject)) 
Interrupt while evaluating Menu Callback. 

I've attached a file that produces this bug and I hope there is an easy solution for this :)

Best wishes

Marek Export_Test.zip

Marrekko commented 3 years ago

Follow up: Sometimes it helps to track the error from the beginning :D The code stucks in line 63 of CalculateStats if a call has less than 6 datapoints, as threshold lowering does not help in this case:

  if iter > 2
        disp('lowering threshold')
    end

It works fine if one reactivates the lines

    if iter > 10
%         disp('Could not detect contour')
        greaterthannoise = true(1, size(I, 2));
        break;

from March 2019. Maybe one can include a warning prompt that calls are ignored as they were to short. Best would be a possibility to review these and skip or really include them, but I don't have enough time for that now (or talent to do that in a short time)

DrCoffey commented 3 years ago

Hey @Marrekko. Yup, this bug was is caused by boxes less than 5 pixels wide. I have pushed an update that fixes the problem. In the future I think I will try to automatically pad box sizes that are too small so we won't have to worry about minuscule boxes causing other problems.