def final_deconv(TMP_FOLDER, standardized_path, standardized_params, fname_templates): logger = logging.getLogger(__name__) if not os.path.exists(TMP_FOLDER): os.makedirs(TMP_FOLDER) ''' ********************************************** ************** DECONVOLUTION ***************** ********************************************** ''' # run deconvolution logger.info('FINAL DECONV') (fname_templates, fname_spike_train, fname_templates_up, fname_spike_train_up, fname_shifts) = deconvolve.run( fname_templates, os.path.join(TMP_FOLDER, 'deconv'), standardized_path, standardized_params['dtype']) # compute residual logger.info('RESIDUAL COMPUTATION') fname_residual, residual_dtype = residual.run( fname_shifts, fname_templates_up, fname_spike_train_up, os.path.join(TMP_FOLDER, 'residual'), standardized_path, standardized_params['dtype'], dtype_out='float32') #logger.info('FINAL MERGE') fname_templates, fname_spike_train = merge.run( os.path.join(TMP_FOLDER, 'post_deconv_merge'), False, fname_spike_train, fname_templates, fname_spike_train_up, fname_templates_up, standardized_path, standardized_params['dtype'], fname_residual, residual_dtype) return (fname_templates, fname_spike_train, fname_templates_up, fname_spike_train_up, fname_residual, residual_dtype)
def final_deconv(TMP_FOLDER, standardized_path, standardized_dtype, fname_templates): logger = logging.getLogger(__name__) if not os.path.exists(TMP_FOLDER): os.makedirs(TMP_FOLDER) ''' ********************************************** ************** DECONVOLUTION ***************** ********************************************** ''' # run deconvolution logger.info('FINAL DECONV') (fname_templates, fname_spike_train, fname_templates_up, fname_spike_train_up, fname_shifts) = deconvolve.run(fname_templates, os.path.join(TMP_FOLDER, 'deconv'), standardized_path, standardized_dtype) # compute residual logger.info('RESIDUAL COMPUTATION') fname_residual, residual_dtype = residual.run(fname_shifts, fname_templates, fname_spike_train, os.path.join( TMP_FOLDER, 'residual'), standardized_path, standardized_dtype, dtype_out='float32') logger.info('SOFT NOISE ASSIGNMENT') fname_soft_assignment = noise.run( fname_templates, fname_spike_train, fname_shifts, os.path.join(TMP_FOLDER, 'soft_assignment'), fname_residual, residual_dtype) logger.info('FINAL MERGE') (fname_templates, fname_spike_train, fname_soft_assignment) = merge.run( os.path.join(TMP_FOLDER, 'post_deconv_merge'), fname_spike_train, fname_templates, fname_soft_assignment, fname_residual, residual_dtype) return (fname_templates, fname_spike_train, fname_soft_assignment)
def single_block(TMP_FOLDER, standardized_path, standardized_params, fname_templates, run_chunk_sec): logger = logging.getLogger(__name__) if not os.path.exists(TMP_FOLDER): os.makedirs(TMP_FOLDER) # run deconvolution logger.info('DECONV' + str(run_chunk_sec)) (fname_templates, fname_spike_train, fname_templates_up, fname_spike_train_up, fname_shifts) = deconvolve.run(fname_templates, os.path.join(TMP_FOLDER, 'deconv'), standardized_path, standardized_params['dtype'], run_chunk_sec=run_chunk_sec) # compute residual logger.info('RESIDUAL COMPUTATION') fname_residual, residual_dtype = residual.run(fname_shifts, fname_templates_up, fname_spike_train_up, os.path.join( TMP_FOLDER, 'residual'), standardized_path, standardized_params['dtype'], dtype_out='float32', run_chunk_sec=run_chunk_sec) logger.info('BLOCK1 MERGE') fname_templates_up, fname_spike_train_up = merge.run( os.path.join(TMP_FOLDER, 'post_deconv_merge'), False, fname_spike_train, fname_templates, fname_spike_train_up, fname_templates_up, standardized_path, standardized_params['dtype'], fname_residual, residual_dtype) fname_templates = fname_templates_up fname_spike_train = fname_spike_train_up return (fname_templates, fname_spike_train, fname_templates_up, fname_spike_train_up, fname_residual, residual_dtype)
def iterative_block(TMP_FOLDER, standardized_path, standardized_dtype, fname_templates, run_chunk_sec): logger = logging.getLogger(__name__) if not os.path.exists(TMP_FOLDER): os.makedirs(TMP_FOLDER) # run deconvolution logger.info('DECONV') (fname_templates, fname_spike_train, fname_templates_up, fname_spike_train_up, fname_shifts) = deconvolve.run(fname_templates, os.path.join(TMP_FOLDER, 'deconv'), standardized_path, standardized_dtype, run_chunk_sec=run_chunk_sec) # compute residual logger.info('RESIDUAL COMPUTATION') fname_residual, residual_dtype = residual.run(fname_shifts, fname_templates, fname_spike_train, os.path.join( TMP_FOLDER, 'residual'), standardized_path, standardized_dtype, dtype_out='float32', run_chunk_sec=run_chunk_sec) #logger.info('KILL NOISE') #fname_spike_train2 = noise.run( # fname_templates, # fname_spike_train, # fname_shifts, # os.path.join(TMP_FOLDER, # 'noise_kill'), # fname_residual, # residual_dtype) if False: logger.info('SOFT NOISE ASSIGNMENT') fname_soft_assignment = noise.run( fname_templates, fname_spike_train, fname_shifts, os.path.join(TMP_FOLDER, 'soft_assignment'), fname_residual, residual_dtype) logger.info('BLOCK1 MERGE') _, _, _ = merge.run(os.path.join(TMP_FOLDER, 'post_deconv_merge'), fname_spike_train, fname_templates, fname_soft_assignment, fname_residual, residual_dtype) # cluster logger.info('RECLUSTERING') fname_templates, fname_spike_train = cluster.run( os.path.join(TMP_FOLDER, 'cluster'), standardized_path, standardized_dtype, fname_residual=fname_residual, residual_dtype=residual_dtype, fname_spike_index=None, fname_templates=fname_templates, fname_spike_train=fname_spike_train, raw_data=False, full_run=True) methods = ['off_center', 'high_mad', 'duplicate_l2', 'duplicate'] fname_templates, fname_spike_train = postprocess.run( methods, fname_templates, fname_spike_train, os.path.join(TMP_FOLDER, 'cluster_post_process'), standardized_path, standardized_dtype) return fname_templates, fname_spike_train
def iterative_block(TMP_FOLDER, standardized_path, standardized_params, fname_templates, run_chunk_sec): logger = logging.getLogger(__name__) if not os.path.exists(TMP_FOLDER): os.makedirs(TMP_FOLDER) # run deconvolution logger.info('DECONV') (fname_templates, fname_spike_train, fname_templates_up, fname_spike_train_up, fname_shifts) = deconvolve.run( fname_templates, os.path.join(TMP_FOLDER, 'deconv'), standardized_path, standardized_params['dtype'], run_chunk_sec=run_chunk_sec) # compute residual logger.info('RESIDUAL COMPUTATION') fname_residual, residual_dtype = residual.run( fname_shifts, fname_templates_up, fname_spike_train_up, os.path.join(TMP_FOLDER, 'residual'), standardized_path, standardized_params['dtype'], dtype_out='float32', run_chunk_sec=run_chunk_sec) logger.info('BLOCK1 MERGE') fname_templates_up, fname_spike_train_up = merge.run( os.path.join(TMP_FOLDER, 'post_deconv_merge'), False, fname_spike_train, fname_templates, fname_spike_train_up, fname_templates_up, standardized_path, standardized_params['dtype'], fname_residual, residual_dtype) fname_templates = fname_templates_up fname_spike_train = fname_spike_train_up # cluster logger.info('RECLUSTERING') raw_data = False full_run = True fname_templates, fname_spike_train = cluster.run( fname_spike_train, standardized_path, standardized_params['dtype'], os.path.join(TMP_FOLDER, 'cluster'), raw_data, full_run, fname_residual=fname_residual, residual_dtype=residual_dtype, fname_templates_up=fname_templates_up, fname_spike_train_up=fname_spike_train_up) methods = ['duplicate', 'high_mad', 'collision'] fname_templates, fname_spike_train = postprocess.run( methods, fname_templates, fname_spike_train, os.path.join(TMP_FOLDER, 'cluster_post_process'), standardized_path, standardized_params['dtype']) return fname_templates, fname_spike_train
def pre_final_deconv(TMP_FOLDER, standardized_path, standardized_dtype, fname_templates, run_chunk_sec): logger = logging.getLogger(__name__) if not os.path.exists(TMP_FOLDER): os.makedirs(TMP_FOLDER) ''' ********************************************** ************** DECONVOLUTION ***************** ********************************************** ''' # run deconvolution logger.info('DECONV') (fname_templates, fname_spike_train, fname_templates_up, fname_spike_train_up, fname_shifts) = deconvolve.run( fname_templates, os.path.join(TMP_FOLDER, 'deconv'), standardized_path, standardized_dtype, run_chunk_sec=run_chunk_sec) # compute residual logger.info('RESIDUAL COMPUTATION') fname_residual, residual_dtype = residual.run( fname_shifts, fname_templates, fname_spike_train, os.path.join(TMP_FOLDER, 'residual'), standardized_path, standardized_dtype, dtype_out='float32', run_chunk_sec=run_chunk_sec) logger.info('SOFT NOISE ASSIGNMENT') fname_soft_assignment = noise.run( fname_templates, fname_spike_train, fname_shifts, os.path.join(TMP_FOLDER, 'soft_assignment'), fname_residual, residual_dtype) logger.info('POST DECONV MERGE') (fname_templates, fname_spike_train, fname_soft_assignment) = merge.run( os.path.join(TMP_FOLDER, 'post_deconv_merge'), fname_spike_train, fname_templates, fname_soft_assignment, fname_residual, residual_dtype) logger.info('Remove Low Firing Rate Units') methods = ['low_fr'] fname_templates, fname_spike_train = postprocess.run( methods, os.path.join(TMP_FOLDER, 'post_deconv_post_process'), standardized_path, standardized_dtype, fname_templates, fname_spike_train, fname_soft_assignment) return (fname_templates, fname_spike_train)