예제 #1
0
 def save_compare_tifs():
     if verbose:print('####save some stacks for comparison (img and membrane contour')
     
     filehandler.d_load_info['load_dir']= 'base'
     filehandler.d_load_info['f_name'] = '4D_membrane_contour'
     filehandler.d_save_info['f_name'] = 'Compare_3D_membrane_contour' + '_ST' + str(nb_stack)
     slice_tif(ix_slice_time=[nb_stack-1,nb_stack],filehandler=filehandler,verbose=False)
     
     filehandler.d_load_info['f_name'] = 'raw4D'
     filehandler.d_save_info['f_name'] = 'Compare_raw3D' + '_ST' + str(nb_stack)
     slice_tif(ix_slice_time=[nb_stack-1,nb_stack],filehandler=filehandler,verbose=False)
     
     return
예제 #2
0
    def make_image_sequence():
        print('  - making image sequence', flush=True)

        # fh.d_load_info['load_dir'] = IMG_RAW_DIR
        fh.d_load_info['f_name'] = str(
            param_xml.get_file_info(
                field='img_raw_file'))  #  prm['img_raw_file']

        a_raw = fh.load_tif(verbose=False)
        if len(a_raw.shape) == 3:
            z, _, _ = a_raw.shape
            t = 1
        else:
            t, z, _, _ = a_raw.shape

        fh.extend_save_info(extra_dir_1='Image_Sequence',
                            reset_to_snapshot=True)

        for t_i in range(t):
            for z_i in range(z):
                a_slice = slice_tif(a_raw,
                                    ix_slice_time=[t_i, t_i + 1],
                                    ix_slice_z=[z_i, z_i + 1],
                                    verbose=False)
                fh.d_save_info['f_name'] = param_xml.get_file_info(
                    field='img_raw_file').stem + '_t' + str(t_i + 1).zfill(
                        3) + '_z' + str(z_i + 1).zfill(3)
                fh.save_data(a_slice, verbose=False)
                #print('|',end='')

        fh.reset_save_info()

        return
예제 #3
0
	def create_stack():
		if prm['verbose']:print("##create a stack ----------------------------------------------------------------------------timestep{0}".format(nb_stack))
		img = slice_tif(na_tif=a_4D_membrane,ix_slice_time=[nb_stack-1 + prm['offset_input_img'] ,nb_stack + prm['offset_input_img'] ],verbose=False)
		img_bin = np.zeros(img.shape,'bool')
		img_bin[img > 0] = True 
		stack = Stack(img = img_bin,timestep=nb_stack,feat_tracker=feat_tracker,name=fh.d_load_info['f_name'])
		
		return stack
예제 #4
0
 def create_stack():
     if verbose:print("##create a stack ----------------------------------------------------------------------------timestep{0}".format(nb_stack))
     img = slice_tif(na_tif=a_4D_membrane,ix_slice_time=[nb_stack-1,nb_stack],verbose=False)
     img_bin = np.zeros(img.shape,'bool')
     img_bin[img > 0] = True 
     stack = Stack(img = img_bin,timestep=nb_stack,feat_tracker=feat_tracker,name=filehandler.d_load_info['f_name'])
     
     return stack
예제 #5
0
 def load_extra_channel():
     
     if not DIR_EXTRA_CHANNEL:
         return None
     
     filehandler.d_load_info['load_dir'] = DIR_EXTRA_CHANNEL 
     filehandler.d_load_info['f_name'] = FILE_EXTRA_CHANNEL
     filehandler.d_save_info['pre_f_name'] = ''
     return slice_tif(ix_slice_time= [lnb_stack[0] - 1, lnb_stack[-1]], filehandler=filehandler,verbose=False,RGB=True,trim_1D=False)
예제 #6
0
    def add_exterior_mask():
        if not USE_EXTERIOR_OVERLAY:return
        if verbose:print("###add a mask to shield off the exterior")
        
        filehandler.d_load_info['load_dir'] = DIR_EXTERIOR_MASK if DIR_EXTERIOR_MASK else os.path.join(filehandler.get_root_save_location(),'002_preprocessing')
        filehandler.d_load_info['f_name'] = FILE_EXTERIOR_MASK if FILE_EXTERIOR_MASK else 'exterior_mask.tif'

        stack.add_exterior_mask(slice_tif(filehandler=filehandler,ix_slice_time=[nb_stack-1,nb_stack],verbose=False),mask=True)
        
        return
예제 #7
0
	def get_extra_channel():
		
		fh.d_load_info['f_name'] = str(param_xml.get_file_info(field='img_raw_file'))
		fh.d_save_info['pre_f_name'] = ''
		try:
			a_extra_channel = convert_16bit_to_RGB(fh.load_tif(),clip_not_scale=True)
		except:
			return None

		if len(a_extra_channel.shape)==4:  #turn stack into timelapse
			z, y, x, rgba = a_extra_channel.shape
			a_extra_channel = a_extra_channel.reshape((1, z, y, x, rgba))

		if len(prm['l_stack_raw']) == 0:
			a_slice_tif =  slice_tif(na_tif=a_extra_channel,ix_slice_time= [prm['l_stack_nb'][0] - 1, prm['l_stack_nb'][-1]],verbose=False,RGB=True,trim_1D=False)
		else:
			a_slice_tif =  slice_tif(na_tif=a_extra_channel,ix_slice_time= [i-1 for i in prm['l_stack_raw']],verbose=False,RGB=True,trim_1D=False)

		make_brighter=True #causes memory crash for big timelapses,so go stack by stack
		if make_brighter:
			for ix, i in enumerate(a_slice_tif):
				a_slice_tif[ix, :] = adjust_gamma(i, gamma=0.5)

		return a_slice_tif
예제 #8
0
	def add_exterior_mask():
		if not prm['use_exterior_overlay']:return
		if prm['verbose']:print("###add a mask to shield off the exterior")
		# fh.d_load_info['load_dir'] = prm['DIR_EXTERIOR_MASK'] if prm['DIR_EXTERIOR_MASK'] else os.path.join(fh.get_root_save_location(),'002_preprocessing')

		if prm['exterior_mask_file']:
			fh.d_load_info['f_name']  = prm['exterior_mask_file']
		else:
			fh.d_load_info['f_name'] = os.path.join(fh.get_root_save_location(),'002_preprocessing','exterior_mask.tif')

		if os.path.exists(fh.d_load_info['f_name']):
			stack.add_exterior_mask(slice_tif(filehandler=fh,ix_slice_time=[nb_stack-1 + prm['offset_exterior_mask'] ,nb_stack + prm['offset_exterior_mask'] ],verbose=False),mask=True)
		else:
			print('No exterior mask used.  File does not exist: ',fh.d_load_info['f_name'])
		
		return
예제 #9
0
    def get_extra_channel():
        
        if DIR_EXTRA_CHANNEL:
            filehandler.d_load_info['load_dir'] = DIR_EXTRA_CHANNEL 
            filehandler.d_load_info['f_name'] = FILE_EXTRA_CHANNEL
            filehandler.d_save_info['pre_f_name'] = ''
            a_extra_channel = filehandler.load_tif()
        else:
            filehandler.d_load_info['load_dir'] = IMG_RAW_DIR
            filehandler.d_load_info['f_name'] = IMG_RAW_FILE
            filehandler.d_save_info['pre_f_name'] = ''
            a_extra_channel = convert_16bit_to_RGB(filehandler.load_tif(storage_name='IMG_RAW_FILE'),clip_not_scale=True)

        if len(a_extra_channel.shape)==4:  #turn stack into timelapse
                z,y,x,rgba = a_extra_channel.shape
                a_extra_channel = a_extra_channel.reshape((1,z,y,x,rgba)) 
        
        return slice_tif(na_tif=a_extra_channel,ix_slice_time= [lnb_stack[0] - 1, lnb_stack[-1]],verbose=False,RGB=True,trim_1D=False)
예제 #10
0
    def make_image_sequence():
        print('  - making image sequence')
        
        # filehandler.d_load_info['load_dir'] = IMG_RAW_DIR
        filehandler.d_load_info['f_name'] = str(img_raw_file)
        a_raw = filehandler.load_tif()
        if len(a_raw.shape)==3:
            z,_,_ = a_raw.shape
            t=1
        else:
            t,z,_,_ = a_raw.shape
        
        filehandler.extend_save_info(extra_dir_1='Image_Sequence',reset_to_snapshot=True)
        
        for t_i in range(t):
            for z_i in range(z):
                a_slice = slice_tif(a_raw,ix_slice_time=[t_i,t_i+1],ix_slice_z=[z_i,z_i+1],verbose=False)
                filehandler.d_save_info['f_name'] = img_raw_file.stem + '_t' +  str(t_i+1).zfill(3) + '_z' + str(z_i+1).zfill(3)
                filehandler.save_data(a_slice,verbose=False)
                print('|',end='')

        filehandler.reset_save_info()
        
        return