Beispiel #1
0
def processor_placeholder(pars):  
    import os          
    import calblitz as cb
    from  glob import glob
    folder_in,f_rate=pars
    fname_mov=os.path.join(os.path.split(folder_in)[0], os.path.split(folder_in)[-1] + 'MOV.hdf5')
    print fname_mov    
    files=sorted(glob(os.path.join(os.path.split(folder_in)[0],'images/*.tif')))
    print files
    #% LOAD MOVIE HERE USE YOUR METHOD, Movie is frames x dim2 x dim2
    m=cb.load_movie_chain(files,fr=f_rate)      
    m.file_name=[os.path.basename(ttt) for ttt in m.file_name]
    m.save(fname_mov)  
    del m   
    return fname_mov
def processor_placeholder(pars):
    import os
    import calblitz as cb
    from glob import glob
    folder_in, f_rate = pars
    fname_mov = os.path.join(os.path.split(folder_in)[
                             0], os.path.split(folder_in)[-1] + 'MOV.hdf5')
    print(fname_mov)
    files = sorted(
        glob(os.path.join(os.path.split(folder_in)[0], 'images/*.tif')))
    print(files)
    #% LOAD MOVIE HERE USE YOUR METHOD, Movie is frames x dim2 x dim2
    m = cb.load_movie_chain(files, fr=f_rate)
    m.file_name = [os.path.basename(ttt) for ttt in m.file_name]
    m.save(fname_mov)
    del m
    return fname_mov
Beispiel #3
0
        cse.utilities.stop_server()
        cse.utilities.start_server()
        c = Client()

    print 'Using ' + str(len(c)) + ' processes'
    dview = c[:len(c)]
#%% FOR LOADING ALL TIFF FILES IN A FILE AND SAVING THEM ON A SINGLE MEMORY MAPPABLE FILE
#fnames=[]
#fnames=glob.glob('*.tif')
#fnames.sort()
fnames = ['file_name.tif'
          ]  # you ahev to eliminate the first element, it cannot be loaded!
print fnames
fnames = fnames
#%%
m = cb.load_movie_chain(fnames, fr=30)
#%%
m.play(backend='opencv', gain=3., fr=50)
#%%
apply_smooth = False  # set to true if SNR too low. Slower but might work better. In my hand ot worked out just fine!
m_mc = cb.motion_correct_parallel([m],
                                  fr=30,
                                  template=None,
                                  margins_out=0,
                                  max_shift_w=25,
                                  max_shift_h=25,
                                  remove_blanks=True,
                                  apply_smooth=apply_smooth,
                                  dview=None,
                                  save_hdf5=False)
m_mc = m_mc[0]
    resize_factors=[.2, .1666666666],
    diameter_bilateral_blur=4)

#%%
client_.close()
cse.utilities.stop_server(is_slurm=True)

#%%

#%%
fold = os.path.split(os.path.split(fnames[0])[-2])[-1]
os.mkdir(fold)
#%%
files = glob.glob(fnames[0][:-20] + '*BL_compress_.tif')
files.sort()
print(files)
#%%
m = cb.load_movie_chain(files, fr=3)
m.play(backend='opencv', gain=10, fr=40)
#%%
m.save(files[0][:-20] + '_All_BL.tif')
#%%
files = glob.glob(fnames[0][:-20] + '*[0-9]._compress_.tif')
files.sort()
print(files)
#%%
m = cb.load_movie_chain(files, fr=3)
m.play(backend='opencv', gain=3, fr=40)
#%%
m.save(files[0][:-20] + '_All.tif')
file_res=cb.utils.pre_preprocess_movie_labeling(client_[::2], fnames, median_filter_size=(2,1,1), 
                                  resize_factors=[.2,.1666666666],diameter_bilateral_blur=4)

#%%
client_.close()
cse.utilities.stop_server(is_slurm=True)

#%%

#%%
fold=os.path.split(os.path.split(fnames[0])[-2])[-1]
os.mkdir(fold)
#%%
files=glob.glob(fnames[0][:-20]+'*BL_compress_.tif')
files.sort()
print(files)
#%%
m=cb.load_movie_chain(files,fr=3)
m.play(backend='opencv',gain=10,fr=40)
#%%
m.save(files[0][:-20]+'_All_BL.tif')
#%%
files=glob.glob(fnames[0][:-20]+'*[0-9]._compress_.tif')
files.sort()
print(files)
#%%
m=cb.load_movie_chain(files,fr=3)
m.play(backend='opencv',gain=3,fr=40)
#%%
m.save(files[0][:-20]+'_All.tif')
vl=vals[1]
params=[]
for vl in vals:
    tmp1=['{0}'.format(kk.zfill(2)) for kk in  vl[0].split('-')]
    tmp1[-1]=tmp1[-1][-2:]
    fn=('_').join(tmp1)
    
    fls=glob.glob(os.path.join(img_folder,fn,vl[6]+'*.tif'))
    fls.sort(key = lambda x: int(x[-6:-4].replace('s','')))
    if len(fls)==0:
        print('NOT FOUND: ')
        print(vl)
    else:    
        
        params.append(vl)
        m=cb.load_movie_chain(fls,fr=vl[8])        
        print('Saving '+fn+'_'+vl[6]+'_mov.hdf5')
        m.save(fn+'_'+vl[6]+'_mov.hdf5')        
        np.savez(fn+'_'+vl[6]+'_mov.npz',pars=vl)
#        img=m.local_correlations()            
#        pl.imshow(img>.3)
#        pl.pause(1)
#        pl.cla()
#            print fl
#        print '*'
#%%
fls=glob.glob('*.hdf5') 
#%%
c[:].map_sync(place_holder,fls) 
#%%      
def place_holder(fl):
Beispiel #7
0
        tmp1[-1]=tmp1[-1][-2:]
        fn=('_').join(tmp1)
        
        fls=glob.glob(os.path.join(img_folder,fn,vl[-4]+'*.tif'))
        fls.sort(key = lambda x: int(x[-6:-4].replace('s','').replace('c','')))
        print vl
        if len(fls)==0:
            
            print('NOT FOUND: ')
            print(vl)
    
        else:    
            diameters.append(np.int(vl[-1]))
            params.append(vl)
            
            m=cb.load_movie_chain(fls,fr=vl[-2])        
            print('Saving '+fn+'_'+vl[-4]+'_mov.hdf5')
            m.save(fn+'_'+vl[-4]+'_mov.hdf5')        
            file_names_hdf5.append(fn+'_'+vl[-4]+'_mov.hdf5')
            np.savez(fn+'_'+vl[-4]+'_mov.npz',pars=vl)
    
    
    #        img=m.local_correlations()            
    #        pl.imshow(img>.3)
    #        pl.pause(1)
    #        pl.cla()
    #            print fl
    #        print '*'
#%%
prs=list(zip(file_names_hdf5,diameters))
#%%
Beispiel #8
0
from utilities import *
from scipy.sparse import coo_matrix
import calblitz as cb
try: 
    pl.ion()
    %load_ext autoreload
    %autoreload 2
except:
    print "Probably not a Ipython interactive environment" 

#%% many movies
import glob
file_list=glob.glob('CHR L10 503 539 -82_2X_LOBV or VI_08*.tif')
for f in file_list:
    print f
m=cb.load_movie_chain(file_list,fr=15.625,subindices=range(3,54,3))
#%% q
m=cb.load('M_FLUO.tif',fr=8); 

#%%
m=cb.load('M_FLUO.tif',fr=8); 
#
T,h,w=np.shape(m)
m1=m[:,:h/2,:]  
m2=m[:,h/2:,:]
m=m2;


#%%
m,shifts,xcorrs,template=m.motion_correct(max_shift_w=5,max_shift_h=5, num_frames_template=None, template = None,method='opencv')
max_h,max_w=np.ceil(np.nanmax(shifts,axis=0))
Beispiel #9
0
    else:
        cse.utilities.stop_server()
        cse.utilities.start_server()        
        c=Client()

    print 'Using '+ str(len(c)) + ' processes'
    dview=c[:len(c)]
#%% FOR LOADING ALL TIFF FILES IN A FILE AND SAVING THEM ON A SINGLE MEMORY MAPPABLE FILE
#fnames=[]
#fnames=glob.glob('*.tif')
#fnames.sort()
fnames=['file_name.tif'] # you ahev to eliminate the first element, it cannot be loaded!
print fnames  
fnames=fnames
#%%
m=cb.load_movie_chain(fnames,fr=30)
#%%
m.play(backend='opencv',gain=3.,fr=50)
#%%
apply_smooth=False # set to true if SNR too low. Slower but might work better. In my hand ot worked out just fine!
m_mc=cb.motion_correct_parallel([m], fr=30, template=None, margins_out=0, max_shift_w=25, max_shift_h=25, remove_blanks=True, apply_smooth=apply_smooth, dview=None, save_hdf5=False)
m_mc=m_mc[0]
#%%
m_mc.resize(1,1,.2).play(backend='opencv',gain=5.,fr=10)
#%%
m_mc.save('all_mov.hdf5')
#%% in what follows there is some redundancy only due to the fact that this is meant to run oin parallel for many datasets... it can be done much faster.
#idx_x=slice(12,500,None)
#idx_y=slice(12,500,None)
#idx_xy=(idx_x,idx_y)
final_frate=30