Page 1 of 1

dealing with RawPixelsStore results in matlab

PostPosted: Wed Sep 26, 2012 1:56 pm
by achessel
Hi all,

I am using a RawPixelsStore in Matal to crop an hyperstack out of a 3D volume; the method gives back a linear array of byte which, according to the doc, "can and will be interpreted according to results of getByteWidth(), isFloat(), and isSigned()". I would not mind some more detail on how to do that, ie transfrom the linear array of byte into a usable matlab 3D array of float (or whatever).

Is there a documentation (good job on the improved documentation btw!...) page detailing that somewhere? I ran into the reverse problem a while back and the solution I ended up using was not the most concise...

A.

Re: dealing with RawPixelsStore results in matlab

PostPosted: Thu Sep 27, 2012 8:26 am
by sbesson
Hi Anatole,

thanks for you email. I created a ticket to improve our documentation on this matter. OMERO.matlab will be reviewed for 4.5.0 so that we have functions performing this conversion automatically. Let me know if you want to be cc'ed on this ticket.

In the meantime, you can take a look at the Bio-Formats bfGetPlane.m function. This functions converts linear byte arrays into 2D matrices using getBytesPerPixel(), isFloatingPoint(), and isSigned().

Let me know if you need additional information.

Sébastien

Re: dealing with RawPixelsStore results in matlab

PostPosted: Tue Oct 02, 2012 7:03 pm
by achessel
Thank you for your answer; having some helper function for that kind of thing would be quite useful indeed...

I ended up doing it manually. I's probably kludgy and hard coded in many ways, but in case it can be of use to others, here it is:
Code: Select all
%once the store is initialised properly:
   st=store.getHypercube(offset, size, step);
   st2=arrayfun(@(x) (typecast([int8(st(2*x)),int8(st(2*x-1))],'uint16')),1:(length(st)/2));
   st3=reshape(st2,sizex,sizey,sizez);