kushalkolar / MESmerize

Platform for Calcium Imaging analysis. DEPRECATED.
GNU General Public License v3.0
61 stars 14 forks source link

[INSTALLATION HELP] opening .h5 instead of .tiff #105

Closed s-j-k closed 2 years ago

s-j-k commented 2 years ago

Hello folks,

if you are using .h5's, Modules>Load Images only has an option for .tiff's, you can work around this by doing the following:


import h5py as h5py

#see h5py documentation, 'r' is for read
aa=h5py.File(datapath,'r')   

# find the name of the dataset object
list(aa.keys())  

 #call the dataset object 
dset=aa['data']  
#convert from h5 dataset to numpy array
a=dset[()] 
a.shape #in t,x,y
type(a) # make sure it's a numpyarray
meta = \
    {
         "origin": "Tutorial example",
         "fps":    10.0,
         "date":    "20220602_cd036_000",
         "scanner_pos":  [0,1,2,3,4,5,6]
    }

# Create ImgData instance
imgdata = ImgData(a.T, meta)  # use a.T to get [x, y, t] (time last)

# Create a work environment instance
work_env = ViewerWorkEnv(imgdata)

# Set the current Viewer Work Environment from this new instance
vi.viewer.workEnv = work_env

# Update the viewer with the new work environment
# this MUST be run whenever you replace the viewer work environment (the previous line)
update_workEnv()