Skip to content

Instantly share code, notes, and snippets.

@hirokai
Created December 5, 2014 19:02
Show Gist options
  • Save hirokai/cc313f890a982f53ec4f to your computer and use it in GitHub Desktop.
Save hirokai/cc313f890a982f53ec4f to your computer and use it in GitHub Desktop.
Parsing MicroManager metadata.txt to extract time lapse info
#!/usr/bin/env ruby
# Collecting elapsed time from all frames and positions.
require 'csv'
positions = [["4-Pos_000_000", "4-Pos_000_001", "4-Pos_000_002", "4-Pos_000_003"], ["4-Pos_001_000", "4-Pos_001_001", "4-Pos_001_002", "4-Pos_001_003"],
["4-Pos_002_000", "4-Pos_002_001", "4-Pos_002_002", "4-Pos_002_003"], ["4-Pos_003_000", "4-Pos_003_001", "4-Pos_003_002", "4-Pos_003_003"]]
CSV.open("02B frames.csv", "wb") do |csv|
csv << ['Frame','Position','Time [sec]']
for pos in positions.flatten
path = '/Volumes/Macintosh HD/Google Drive/Groves/Scope 7/20141204 T cells short time fix with live imaging/02 FC1/tirf_561_1/'+pos+'/metadata.txt'
ts = IO.readlines(path).collect{|l| l =~ /ElapsedTime-ms":\s*(\d+)/; $1}.compact
ts.map{|s| (s.to_f/100).round.to_f/10}.sort.each_with_index{|t,i|
csv << [(i+1),pos,t]
}
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment