Page 1 of 1

Get TimeStamp for czi files

PostPosted: Mon Dec 05, 2016 6:51 pm
by nhuebsch
Hi,

New to the forum so please forgive me if it's been posted elsewhere, but I'd like to use bfGetReader to open up time-series (X-Y-T) + have Matlab read-in the frame-rate.

Using bfGetReader and omeMeta I can easily identify correctly the physical X and Y units, but I am not able to get the syntax right to get the time-step units (I care more about the time between exposures than the actual exposure time for each frame). I've tried getPlaneDeltaT and other commands, and I either get an error, or a null value. I can use "SizeT" to get the number of time-steps, but haven't been able to extract the time between t-steps.

Thanks for your help!

Re: Get TimeStamp for czi files

PostPosted: Mon Dec 05, 2016 7:43 pm
by sbesson
Hi,

in most cases, the information you are looking for should be available via the Plane DeltaT metadata i.e. the timestamp for each plane, from which you can infer the time between 2 frames.

I ran the following code against a CZI file which populates this information. Note the MetadataRetrieve.getPlaneDeltaT takes 2 arguments: the index of the image and the index of the plane (both zero-based) and returns a time object from which you can extract the value and the unit:

Code: Select all
>> bfCheckJavaPath();

>> bfInitLogging();
>> r=bfGetReader('/path/to/WT_calc_after24h_stitch_2.czi');
Unknown IlluminationType value 'Fluorescence' will be stored as "Other"
>> nSeries = r.getSeriesCount();
>> m = r.getMetadataStore();
>> nImages = m.getImageCount()

nImages =
>> nPlanes = m.getPlaneCount(0)

nPlanes =

    24

>> t1 = m.getPlaneDeltaT(0,0)

t1 =

ome.units.quantity.Time: value[2.675153], unit[s] stored as java.lang.Double

>> t1 = m.getPlaneDeltaT(0,0).value

t1 =

2.675153

>> t2 = m.getPlaneDeltaT(0,2).value

t2 =

455.4420497


Does this return the information you are looking for in the context of your file?

Best,
Sebastien

Re: Get TimeStamp for czi files

PostPosted: Mon Dec 05, 2016 8:16 pm
by nhuebsch
Yes this works! Thanks so much!

I'm able to extract the values needed using

"tx = double(t1) "
or by changing the initial call to read: " t2 = double(m.getPlaneDeltaT(0,2).value)"

Really appreciate the quick reply.

Thanks

Re: Get TimeStamp for czi files

PostPosted: Mon Dec 05, 2016 8:50 pm
by sbesson
No worries, glad to hear it worked.

You are right, the output of the `.value()` call returns a java Double object. To retrieve the value of the primitive type double which can be manipulated by MATLAB, assuming the object is not null, you can either use the method you described:

Code: Select all
t2 = double(m.getPlaneDeltaT(0,2).value());


or alternatively use the Java method:

Code: Select all
t2 = m.getPlaneDeltaT(0,2).value().doubleValue();


Best,
Sébastien