We're Hiring!

Recovering "annotation file"

General and open developer discussion about using OMERO APIs from C++, Java, Python, Matlab and more! Please new questions at https://forum.image.sc/tags/omero
Please note:
Historical discussions about OMERO. Please look for and ask new questions at https://forum.image.sc/tags/omero

If you are having trouble with custom code, please provide a link to a public repository, ideally GitHub.

Recovering "annotation file"

Postby yuriy_alexandrov » Fri Mar 22, 2013 4:11 pm

Hi All,

The program for which we develop our OMERO Matlab client is FLIMfit.
To store service files in OMERO (like IRFs, etc.), we use "annotation file" option.
It works well for text IRF files, but for small B&H *sdt's there were difficulties.

Here is the code retrieving the bytes:

Code: Select all
        originalFile = ann.getFile();       
        rawFileStore = session.createRawFileStore();
        rawFileStore.setFileId(originalFile.getId().getValue());       
        byteArr  = rawFileStore.read(0,originalFile.getSize().getValue());
        rawFileStore.close();

Here is how these bytes are saved on disk (bytes are "str" variable):
Then, the saved file becomes useful for loading to program.

Code: Select all
            full_temp_file_name = [tempdir fname];
            fid = fopen(full_temp_file_name,'w');   
            %
            if strcmp('sdt',fname(numel(fname)-2:numel(fname)))
                fwrite(fid,typecast(str,'uint16'),'uint16');
            else               
                fwrite(fid,str,'*uint8');
            end
            %
            fclose(fid);

Other words, if it is "sdt" file, bytes are written after casting them to 'uint16' - that was found by trials and errors. Reasons are unknown, but "sdt" files are saved to disk correctly this way.

The next challenge is to work with Excel "xlsx" annotation files, as our program loads Plate metadata in this format. Both methods shown above failed to write the "xlsx" file to disk correctly, - the saved file has the same size as original but Excel can't open it. It is also binary-different from the original.

If one uses "Download" option in "Insight" - the file is saved to disk correctly, Excel opens it.

I wonder if anyone has any thoughts about why it behaves like this, and how to resolve it.
I use Omero Matlab Toolbox 4.4.6, but problem with "sdt" was there for some time, for previous versions.

Best regards,
Y.
yuriy_alexandrov
 
Posts: 126
Joined: Thu Oct 25, 2012 2:06 pm

Re: Recovering "annotation file"

Postby sbesson » Mon Mar 25, 2013 2:01 pm

Hi Yuriy,

Can you try casting your byte array to 'int8' instead of 'uint8' and let me know if this solves your problem?

Code: Select all
fwrite(fid, byteArr, 'int8');


Sebastien
User avatar
sbesson
Team Member
 
Posts: 421
Joined: Tue Feb 28, 2012 7:20 pm

Re: Recovering "annotation file"

Postby yuriy_alexandrov » Mon Mar 25, 2013 2:37 pm

Hi Sebastien,

Yes it worked.
:D
I will check if switching to "int8" solves it in other places.

Many thanks,
Y.
yuriy_alexandrov
 
Posts: 126
Joined: Thu Oct 25, 2012 2:06 pm

Re: Recovering "annotation file"

Postby sbesson » Wed Apr 03, 2013 9:05 am

Hi Yuriy,

glad to hear it worked.
Fyi, we opened a Pull Request with a new OMERO.matlab function to download the content of a file annotation using OMERO.matlab (https://github.com/openmicroscopy/openm ... y/pull/976).

Sebastien
User avatar
sbesson
Team Member
 
Posts: 421
Joined: Tue Feb 28, 2012 7:20 pm


Return to Developer Discussion

Who is online

Users browsing this forum: No registered users and 0 guests