Bioformat upgrade matlab

Dear all,

I am constantly experiencing the following same issue when I am trying to upgrade the bioformat programmatically from matlab 2018b on a Win10 machine. The path where the bioformat should be installed is on a NAS:

*** A new stable version of Bio-Formats is available ***
*** Downloading... ***Error using bfUpgradeCheck (line 64)
Java exception occurred:
java.lang.NegativeArraySizeException

	at loci.formats.UpgradeChecker.install(UpgradeChecker.java:310)


Error in InterCal (line 21)
bfUpgradeCheck(true);

Obviously it works fine if I am downloading myself the bioformat…

Hi @miocikot,

thanks for bringing this issue to our attention. The auto-download logic of the upgrade check logic has not minimally tested for the last years and some sections of it are now in a broken state.

We will review the code and deprecate as necessary. Immediately, could you set the autoDownload option to false in your code? If you rely on the programmatic way to get the latest version of the toolbox, you should be to download https://downloads.openmicroscopy.org/latest/bio-formats/artifacts/bfmatlab.zip which contains the JARs as well as the M files.

Best,
Sebastien

Hi @s.besson

ok sure.
somehow the unzip function of Matlab is not working anymore with bfmatlab.zip… Originally I had my own routine for upgrading thought the artifacts/bfmatlab.zip. Then came the unzip issue… then I found out the bfUpgradeCheck which never worked…

thank you for your help!

@miocikot: the unzip issue is slightly concerning. Could you paste a copy of the routine you were using for upgrading ?

Hi @s.besson,

here it is:

[~, installed_version] = bfCheckJavaPath(true);
str = urlread('http://downloads.openmicroscopy.org/bio-formats');
expression = ['"\[DIR\]" \/><\/td><td><a href="\d+.\d+.\d+\/">(?<bf_vers>\d+.\d+.\d+\/)'...
    '</a><\/td><td align="right">(?<bf_date>\d+-\w+-\d+ \d+:\d+  )<\/td>'];
tok = regexp(str,expression,'names');
bf_vers = {tok.bf_vers};
bf_date = {tok.bf_date};
bf_date = deblank(bf_date);
[~,idx] = sort(datenum(bf_date),'descend');
last_vers = bf_vers(idx(1));
last_vers = last_vers{1}(1:end-1);

% upgrader = javaObject('loci.formats.UpgradeChecker')

if strcmp(installed_version,last_vers)
    fprintf(['*** bioformats_package.jar version ' last_vers ' is up-to-date ***\n']);
    return
else
    choice = questdlg(['Do you want to upgrade from ' installed_version ' to ' last_vers '?'], ...
        'Bioformat upgrade', ...
        'Yes','No','Yes');
    switch choice
        case 'Yes'
            hwait = msgbox(['Please wait while downloading and unzipping Bioformat...'],...
                'Bioformat upgrade...');
            set(hwait,'WindowStyle','modal','CloseRequestFcn','')
            unzip(['http://downloads.openmicroscopy.org/bio-formats/' last_vers '/artifacts/bfmatlab.zip'],...
                [pwd filesep 'mfiles']);
            
            delete(hwait)
            h = helpdlg('Please restart MATLAB','');
            set(h,'WindowStyle','modal')
            uiwait(h)
            exit
        case 'No'
            return
    end
    
end

@miocikot thanks, now I see what went wrong. Various URLs have been reviewed to use systematically HTTPS and redirect from HTTP to HTTPS on our side including everything under the downloads.openmicroscopy.org domain.

Testing the second line of your script locally,

str = urlread(‘http://downloads.openmicroscopy.org/bio-formats’);

it seems that the urlread built-in function does not follow redirects. You should be able to fix your upgrade function either by using the HTTPS from or by switching to webread which handles both variants.

2 Likes

great, thank you for your fast reply.
Any news about the bfUpgradeCheck function?

@miocikot: the UpgradeChecker logic and by extension bfUpgradeCheck logic needs a more serious review. I have created https://github.com/openmicroscopy/bioformats/issues/3390 to start acting on this in the upcoming 6.2.0 roadmap.