comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Micro-manager JSON Import
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Micro-manager JSON Import [message #89264] Sun, 10 August 2014 20:44
jpskin is currently offline  jpskin
Messages: 1
Registered: August 2014
Junior Member
Hi, I recently needed to get the JSON data embedded in Micro-manager.org .tiff files into IDL. I was given some help on Micro-manager forum to get this data and would like to post the script here for others to use. It is a great example of using the JSON_PARSE function.

; docformat = 'rst'
;+
; :Description:
; takes a micro-manager tiff file and prints the
; EM Gain, Preamp Gain and Readout Mode. This assumes
; a Micro-manager file stack is given, will not check, however. Requires
; idl 8.2 in order to use the JSON_PARSE function and put the
; micro-manager JSON data in a hash variable. Any key can be printed once
; read.
;
; :Params:
; file:
; in, .tiff file from micromanager
;
;
; :Author: jpskinner
;-

pro cameraSettings, file
compile_opt idl2

openr, 1, file

; Determine endian status
stat = read_binary(1, data_dims=2)

if string(stat) eq 'MM' then e='big' else e='little'


; Get the offset to the first IFD
point_lun, 1, 4
ifd_loc = read_binary(1, data_dims=1, data_type=13, endian=e)
print, 'First IFD location: ', ifd_loc

;go to tag 17 which should be 51123
point_lun, 1, ifd_loc+2+16*12
tag = read_binary(1, data_dims=1, data_type=12, endian=e)
if tag ne 51123 then begin
print, 'Tag not present in file.'
print, 'Found tag: ', tag
close, 1
return
endif
type = read_binary(1, data_dims=1, data_type=2, endian=e)
n = read_binary(1, data_dims=1, data_type=13, endian=e)
offset = read_binary(1, data_dims=1, data_type=13, endian=e)

; Go to the micro-manager metadata.
point_lun, 1, offset
data = read_binary(1, data_dims=n, endian=e)
close, 1

metaData = json_parse(string(data))

;Print the info desired.
print, 'Gain: ', metaData['Andor iXon-Gain']
print, 'Readout: ', metaData['Andor iXon-ReadoutMode']
print, 'Pre-Amp: ', metaData['Andor iXon-Pre-Amp-Gain']


end
[Message index]
 
Read Message
Previous Topic: How to assign command line arguments to variables in another class
Next Topic: cgBoxPlot - not a useful function!!!

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 13:32:11 PDT 2025

Total time taken to generate the page: 0.00365 seconds