Map Manager 3 can save two different types of files

  • Text - Default
  • HDF5 - Experimental

Text

Python

Map Manager saves files as plain text. Thus, it is relatively easy to extend the function of Map Manager by writing Python (or Matlab) code to load, parse, and analyze these text files. This is a very rapid and effective route to extending the functions of Map Manager with new analysis particular to your own data and ideas. Please have a look at an example iPython notebook. If you are interested in more information, please email Robert Cudmore.

It is suggested that you use the Anaconda python distribution as it comes with many useful packages pre-installed. Download Anaconda it here.

HDF5

HDF5 is an open source cross platform binary file format. It can be read from Matlab, Python, Igor Pro and from a command line.

As of Sept 2015, Map Manager is not saving files in the HDF5 format. If you are interested in turning on this feature, please email Robert Cudmore.

Python

It is suggested that you use the Anaconda python distribution as it comes with many useful packages pre-installed including hdf5 for python. Download Anaconda it here.

import h5py
import numpy as np

# open h5 file
f = h5py.File('a5n.hdf5', 'r')

# get list of top level groups (these are mm3 maps)
for g in f:
    print g
    
# assign myMap to top level map
for myMap in f: print myMap

# get list of objects within a map
# these objects include {objmap, stackdb, int, line, linedb}
# keys() returns a list [0], [1], [2], ...
for key in f[myMap].keys():
    print key
    
# datasets within group 'a104'
for ds in f[myMap].values():
    print ds
    

# get an object
objectIndex = 4
f[myMap].values()[objectIndex][:][:]

# get the value of a spine from an object
objectIndex = 4
spineIndex = 10
f[myMap].values()[objectIndex][spineIndex]

# attributes of a dataset
objectIndex= 4
for a in f[myMap].values()[objectIndex].attrs:
    print a

# this is trying to pull form an intensity object
# for some reaosn i can't transpose the rows
f[myMap].values()[9].values()[0][0][:]

# spine 0, spineLen2 (spineLen2 is in column 1)
f[myMap].values()[9].values()[0][0][1]

# spine 1, spineLen2
f[myMap].values()[9].values()[0][1][1]

In [64]: f[myMap].values()9.values() Out[64]: [<HDF5 dataset “a5n_s0_Int1”: shape (385, 41), type “<f4”>, <HDF5 dataset “a5n_s0_Int2”: shape (385, 41), type “<f4”>, <HDF5 dataset “a5n_s0_db2”: shape (385, 44), type “|O8”>, <HDF5 dataset “a5n_s0_l”: shape (3903, 19), type “<f4”>, <HDF5 dataset “a5n_s1_Int1”: shape (378, 41), type “<f4”>, <HDF5 dataset “a5n_s1_Int2”: shape (378, 41), type “<f4”>, <HDF5 dataset “a5n_s1_db2”: shape (378, 44), type “|O8”>, <HDF5 dataset “a5n_s1_l”: shape (3871, 19), type “<f4”>, <HDF5 dataset “a5n_s2_Int1”: shape (369, 41), type “<f4”>, <HDF5 dataset “a5n_s2_Int2”: shape (369, 41), type “<f4”>, <HDF5 dataset “a5n_s2_db2”: shape (369, 44), type “|O8”>, <HDF5 dataset “a5n_s2_l”: shape (3742, 19), type “<f4”>, <HDF5 dataset “a5n_s3_Int1”: shape (364, 41), type “<f4”>, <HDF5 dataset “a5n_s3_Int2”: shape (364, 41), type “<f4”>, <HDF5 dataset “a5n_s3_db2”: shape (364, 44), type “|O8”>, <HDF5 dataset “a5n_s3_l”: shape (3837, 19), type “<f4”>]

i got 385 from shape (how do i do this with code?)

In [82]: for a in range(385): print f[myMap].values()9.values()[0]a

this is working

mya=np.arange(385, dtype=np.float32)
for a in range(385):
    mya[a] = f[myMap].values()[9].values()[0][a][1]

import matplotlib.pyplot as plt
plt.plot(mya, 'ro')
plt.xlabel('Spine Index')
plt.ylabel('Spine Length 2D (um)')
plt.show()

Use the Python hdf5Manager

For now this is not very useful for my hdf5 files but is a proof of concept.

  1. Download hdf5 manager here.

  2. Run it

    python h5_manager.py

  3. Getting h5_manager to work

     # install pyqt4 in anaconda
     conda install pyqt
     # update anaconda (h5_manager was failing to import matplotlib)
     conda update --prefix /Users/cudmore/anaconda anaconda
     # run h5_manager
     python h5_manager.py