def One_Key_Frame_Graphs( data_folder, sub_dic, show_clip=3, alinged_sub_folder=r'\Results\Final_Aligned_Frames', Stim_Align_sub_folder=r'\Results\Stim_Frame_Align.pkl'): result_folder = data_folder + r'\Results' graph_save_folder = result_folder + r'\Only_Frame_SubGraphs' OS_Tools.mkdir(result_folder) OS_Tools.mkdir(graph_save_folder) stim_path = data_folder + Stim_Align_sub_folder stim_dic = OS_Tools.Load_Variable(stim_path) all_tif_name = OS_Tools.Get_File_Name(data_folder + alinged_sub_folder) graph_num = len(sub_dic) all_sub_graph_names = list(sub_dic.keys()) for i in range(graph_num): current_name = all_sub_graph_names[i] current_a = Frame_ID_Extractor(stim_dic, sub_dic[current_name][0]) current_b = Frame_ID_Extractor(stim_dic, sub_dic[current_name][1]) current_sub_graph, current_t_graph, current_info_dic = Single_Subgraph_Generator( all_tif_name, current_a, current_b) current_sub_graph = Graph_Tools.Clip_And_Normalize( current_sub_graph, show_clip) current_t_graph = Graph_Tools.Clip_And_Normalize( current_t_graph, show_clip) # Save graphs Graph_Tools.Show_Graph(current_sub_graph, current_name + '_Sub_Graph', graph_save_folder) Graph_Tools.Show_Graph(current_t_graph, current_name + '_t_Graph', graph_save_folder) OS_Tools.Save_Variable(graph_save_folder, current_name + r'_Sub_Info', current_info_dic, '.info') return True
def One_Key_Stim_Maps(data_folder, cell_folder, sub_dic, have_blank=None, alinged_sub_folder=r'\Results\Aligned_Frames', Stim_Align_sub_folder=r'\Results\Stim_Frame_Align.pkl'): ''' 1 key generate stim map. Befor using this, you need to : 1.align graphs 2.give cell file path. 3.Finish stim frame align. ''' result_folder = data_folder + r'\Results' stim_path = data_folder + Stim_Align_sub_folder cell_path = OS_Tools.Get_File_Name(cell_folder, '.cell')[0] cell_dic = OS_Tools.Load_Variable(cell_path) # Then generate spiketrain stim_train = OS_Tools.Load_Variable(stim_path)['Original_Stim_Train'] all_tif_name = OS_Tools.Get_File_Name(data_folder + alinged_sub_folder) cell_information = cell_dic['All_Cell_Information'] if have_blank != None: warnings.warn( 'Have blank is detected automatically, this API is useless now.', FutureWarning) have_blank = (0 in stim_train) if have_blank == True: F_train, dF_F_train = Spike_Train_Generator(all_tif_name, cell_information, Base_F_type='nearest_0', stim_train=stim_train) else: print('No blank, use previous ISI to calculate trains') F_train, dF_F_train = Spike_Train_Generator(all_tif_name, cell_information, Base_F_type='before_ISI', stim_train=stim_train) # Then save F and dF/F trains OS_Tools.Save_Variable(result_folder, 'F_Trains', F_train) OS_Tools.Save_Variable(result_folder, 'dF_F_Trains', dF_F_train) # At last, calculate Maps. Standard_Stim_Processor(data_folder, stim_path, sub_dic, cell_method=cell_path, spike_train_path=result_folder + r'\dF_F_Trains.pkl')
def Cell_Find(run_folder): output_folder = run_folder+r'\Results' aligned_frame_folder = output_folder+r'\Aligned_Frames' all_tif_name = OS_Tools.Get_File_Name(aligned_frame_folder) Stim_Frame_Dic = OS_Tools.Load_Variable(output_folder,'Stim_Frame_Align.pkl') on_off_graph,Finded_Cells = On_Off_Cell_Finder(all_tif_name, Stim_Frame_Dic,shape_boulder=[20,20,20,35],filter_method = 'Gaussian',LP_Para = ((5,5),1.5)) cell_folder = output_folder+r'\Cells' OS_Tools.Save_Variable(cell_folder, 'Finded_Cells', Finded_Cells,'.cell') Graph_tools.Show_Graph(on_off_graph, 'on-off_graph', cell_folder) all_keys = list(Finded_Cells.keys()) all_keys.remove('All_Cell_Information') for i in range(len(all_keys)): Graph_tools.Show_Graph(Finded_Cells[all_keys[i]], all_keys[i], cell_folder) return True
run_list = [ r'G:\Test_Data\2P\201111_L76_LM\1-002', r'G:\Test_Data\2P\201111_L76_LM\1-003', r'G:\Test_Data\2P\201111_L76_LM\1-009' ] for i in range(3): Cell_Find(run_list[i]) #%% Calculate spike train of all finded cells. from My_Wheels.Spike_Train_Generator import Spike_Train_Generator run_list = [ r'G:\Test_Data\2P\201111_L76_LM\1-002', r'G:\Test_Data\2P\201111_L76_LM\1-003', r'G:\Test_Data\2P\201111_L76_LM\1-009' ] for i in range(3): cell_dic = OS_Tools.Load_Variable(run_list[i]+r'\Results\Cells\Finded_Cells.cell') all_tif_name = OS_Tools.Get_File_Name(run_list[i]+r'\Results\Aligned_Frames') stim_train = OS_Tools.Load_Variable(run_list[i]+r'\Results\Stim_Frame_Align.pkl')['Original_Stim_Train'] F_train,dF_F_train = Spike_Train_Generator(all_tif_name, cell_dic['All_Cell_Information']) OS_Tools.Save_Variable(run_list[i]+r'\Results\Cells', 'F_train', F_train) OS_Tools.Save_Variable(run_list[i]+r'\Results\Cells', 'dF_F_train', dF_F_train) #%% Calculate subgraph one by one. from My_Wheels.Standard_Parameters.Sub_Graph_Dics import Sub_Dic_Generator from My_Wheels.Standard_Stim_Processor import Standard_Stim_Processor G8_Subdic = Sub_Dic_Generator('G8+90') Standard_Stim_Processor(r'G:\Test_Data\2P\201111_L76_LM\1-002', stim_folder = r'G:\Test_Data\2P\201111_L76_LM\1-002\Results\Stim_Frame_Align.pkl', sub_dic = G8_Subdic, tuning_graph=False, cell_method = r'G:\Test_Data\2P\201111_L76_LM\1-002\Results\Cells\Finded_Cells.cell',
#%% Then calculate the stim train of each stim series. from My_Wheels.Stim_Frame_Align import Stim_Frame_Align all_stim_folder = [ r'G:\Test_Data\2P\201211_L76_2P\201211_L76_2P_stimuli\Run10_2P_G8', r'G:\Test_Data\2P\201211_L76_2P\201211_L76_2P_stimuli\Run12_2P_OD8_auto', r'G:\Test_Data\2P\201211_L76_2P\201211_L76_2P_stimuli\Run14_2P_RGLum4', ] for i in range(3): _,current_stim_dic = Stim_Frame_Align(all_stim_folder[i]) OS_Tools.Save_Variable(all_stim_folder[i], 'Stim_Frame_Align', current_stim_dic) #%% Then calculate spike train of different runs. from My_Wheels.Spike_Train_Generator import Spike_Train_Generator #Cycle basic stim map. this maps have for i,index in enumerate([1,2,4]): current_aligned_tif_name = OS_Tools.Get_File_Name(all_run_folder[index]+r'\Results\Aligned_Frames') current_stim = OS_Tools.Load_Variable(all_stim_folder[i],file_name='Stim_Frame_Align.pkl')['Original_Stim_Train'] current_cell_info = OS_Tools.Load_Variable(all_run_folder[index]+r'\Results\Global_Morpho\Global_Morpho.cell')['All_Cell_Information'] F_train,dF_F_train = Spike_Train_Generator(current_aligned_tif_name, current_cell_info,Base_F_type= 'nearest_0',stim_train = current_stim) OS_Tools.Save_Variable(all_run_folder[index]+r'\Results', 'F_train', F_train) OS_Tools.Save_Variable(all_run_folder[index]+r'\Results', 'dF_F_train', dF_F_train) #%% Then calculate standard stim map. from My_Wheels.Standard_Stim_Processor import Standard_Stim_Processor from My_Wheels.Standard_Parameters.Sub_Graph_Dics import Sub_Dic_Generator Standard_Stim_Processor(r'G:\Test_Data\2P\201211_L76_2P\1-010', r'G:\Test_Data\2P\201211_L76_2P\1-010\Results\Stim_Frame_Align.pkl', Sub_Dic_Generator('G8+90'), cell_method = r'G:\Test_Data\2P\201211_L76_2P\1-010\Results\Global_Morpho\Global_Morpho.cell', spike_train_path=r'G:\Test_Data\2P\201211_L76_2P\1-010\Results\dF_F_train.pkl' ) Standard_Stim_Processor(r'G:\Test_Data\2P\201211_L76_2P\1-012',
All0_Graph[:,:,2] += ROI_boulder_prev All0_Graph_Annotate = np.clip(All0_Graph,0,255).astype('u1') Graph_Tools.Show_Graph(All0_Graph_Annotate, 'All-0_Annotate', save_folder) #%% Last, RG-Lum RG_Graph = cv2.imread(r'I:\Test_Data\2P\201211_L76_2P\1-014\Results\Subtraction_Graphs\RG-Lum_SubGraph.tif').astype('f8') RG_Graph[:,:,2] += ROI_boulder_prev RG_Graph_Annotate = np.clip(RG_Graph,0,255).astype('u1') Graph_Tools.Show_Graph(RG_Graph_Annotate, 'RG_Annotate', save_folder) #%% Next job, video compare. import My_Wheels.Video_Writer as Video_Writer roi_spon_folder = r'I:\Test_Data\2P\201222_L76_2P\1-001\Results\Aligned_Frames' Video_Writer.Video_From_File(roi_spon_folder,(325,324),fps = 30,cut_boulder = [0,0,0,0]) full_frame_folder = r'I:\Test_Data\2P\201211_L76_2P\1-001\Results\Aligned_Frames' Video_Writer.Video_From_File(full_frame_folder,(492,492),fps = 15,cut_boulder = [10,10,10,10]) #%% Then find a exp cell of ROI and full graph. roi_cell_dic = OS_Tools.Load_Variable(r'I:\Test_Data\2P\201222_L76_2P\1-008\Results\Global_Morpho','Global_Morpho.cell') ROI_G8_F_Train = OS_Tools.Load_Variable(r'I:\Test_Data\2P\201222_L76_2P\1-010\Results\F_Trains.pkl') ROI_G8_Stim_Dic = OS_Tools.Load_Variable(r'I:\Test_Data\2P\201222_L76_2P\1-010\Results\Stim_Frame_Align.pkl') full_cell_dic = OS_Tools.Load_Variable(r'I:\Test_Data\2P\201211_L76_2P\1-010\Results\Global_Morpho\Global_Morpho.cell') full_G8_F_Train = OS_Tools.Load_Variable(r'I:\Test_Data\2P\201211_L76_2P\1-010\Results\F_train.pkl') full_Stim_Dic = OS_Tools.Load_Variable(r'I:\Test_Data\2P\201211_L76_2P\1-010\Results\Stim_Frame_Align.pkl') #%% Run01 Bright and Low aligned_folder = r'I:\Test_Data\2P\201222_L76_2P\1-001\Results\Aligned_Frames' save_path = r'I:\Test_Data\2P\201222_L76_2P\1-001\Results' bright_graph,_ = Selector.Intensity_Selector(aligned_folder,list_write= False) bright_graph = np.clip(bright_graph.astype('f8')*32,0,65535).astype('u2') Graph_Tools.Show_Graph(bright_graph, 'Brightest_Graph', save_path) low_graph,_ = Selector.Intensity_Selector(aligned_folder,list_write= False,mode = 'smallest') low_graph = np.clip(low_graph.astype('f8')*32,0,65535).astype('u2')
# -*- coding: utf-8 -*- """ Created on Mon Jul 12 10:34:23 2021 @author: ZR """ from Standard_Aligner import Standard_Aligner Sa = Standard_Aligner(r'K:\Test_Data\2P\210708_L76_2P', list(range(1, 21)), final_base='1-017') Sa.One_Key_Aligner() from My_Wheels.Stim_Frame_Align import One_Key_Stim_Align One_Key_Stim_Align(r'K:\Test_Data\2P\210708_L76_2P\210709_L76_2P_stimuli') from My_Wheels.Standard_Stim_Processor import One_Key_Frame_Graphs from My_Wheels.Standard_Parameters.Sub_Graph_Dics import Sub_Dic_Generator OD_Para = Sub_Dic_Generator('OD_2P') One_Key_Frame_Graphs(r'K:\Test_Data\2P\210708_L76_2P\1-015', OD_Para) G8_Para = Sub_Dic_Generator('G8+90') One_Key_Frame_Graphs(r'K:\Test_Data\2P\210708_L76_2P\1-018', G8_Para) RG_Para = Sub_Dic_Generator('RGLum4') One_Key_Frame_Graphs(r'K:\Test_Data\2P\210708_L76_2P\1-020', RG_Para) import My_Wheels.OS_Tools_Kit as ot all_cell_dic = ot.Load_Variable( r'K:\Test_Data\2P\210629_L76_2P\L76_210629A_All_Cells.ac')
def Standard_Cell_Processor( animal_name, date, day_folder, cell_file_path, #average_graph_path, # not necessary. run_id_lists, location='A', # For runs have Stim_Frame_Align_name='_All_Stim_Frame_Infos.sfa', #Stim_Frame_Align_subfolder = r'\Results\Stim_Frame_Align.pkl',# API changed. align_subfolder=r'\Results\Aligned_Frames', response_head_extend=3, response_tail_extend=3, base_frame=[0, 1, 2], filter_para=(0.02, False)): # Folder and name initialization print('Just make sure average and cell find is already done.') cell_dic = ot.Load_Variable(cell_file_path) cell_info = cell_dic['All_Cell_Information'] cell_name_prefix = animal_name + '_' + str(date) + location + '_' all_cell_num = len(cell_info) all_run_subfolders = lt.List_Annex([day_folder], lt.Run_Name_Producer_2P(run_id_lists)) save_folder = day_folder all_Stim_Frame_Align = ot.Load_Variable(day_folder + r'\\' + Stim_Frame_Align_name) # Set cell data formats. all_cell_list = [] for i in range(all_cell_num): current_cell_name = cell_name_prefix + ot.Bit_Filler(i, 4) current_cell_dic = {} current_cell_dic['Name'] = current_cell_name current_cell_dic['Cell_Info'] = cell_info[i] # Cycle all runs for F and dF trains. current_cell_dic['dF_F_train'] = {} current_cell_dic['F_train'] = {} current_cell_dic['Raw_CR_trains'] = {} current_cell_dic['CR_trains'] = {} all_cell_list.append(current_cell_dic) # Then cycle all runs, fill in for i in range(len(all_run_subfolders)): current_runid = 'Run' + (all_run_subfolders[i][-3:] ) # Use origin run id to avoid bugs. current_all_tif_name = ot.Get_File_Name( all_run_subfolders[i] + align_subfolder, '.tif') current_Stim_Frame_Align = all_Stim_Frame_Align[current_runid] if current_Stim_Frame_Align == None or len( current_Stim_Frame_Align ) == 302: # meaning this run is spon or RF25. current_run_Fs, current_run_dF_Fs = Spike_Train_Generator( current_all_tif_name, cell_info, 'most_unactive', None) else: current_run_stim_train = current_Stim_Frame_Align[ 'Original_Stim_Train'] if 0 in current_run_stim_train: # having 0 current_run_Fs, current_run_dF_Fs = Spike_Train_Generator( current_all_tif_name, cell_info, Base_F_type='nearest_0', stim_train=current_run_stim_train) else: current_run_Fs, current_run_dF_Fs = Spike_Train_Generator( current_all_tif_name, cell_info, Base_F_type='before_ISI', stim_train=current_run_stim_train) # Then put trains above into each cell files. for j in range(all_cell_num): all_cell_list[j]['dF_F_train'][current_runid] = current_run_dF_Fs[ j] all_cell_list[j]['F_train'][current_runid] = current_run_Fs[j] # Then, we generate Condition Reaction Train for each cell and each condition. if current_Stim_Frame_Align == None: all_cell_list[j]['CR_trains'][current_runid] = None all_cell_list[j]['Raw_CR_trains'][current_runid] = None else: for j in range(all_cell_num): all_cell_list[j]['CR_trains'][current_runid], all_cell_list[j][ 'Raw_CR_trains'][ current_runid] = Single_Condition_Train_Generator( current_run_Fs[j], current_Stim_Frame_Align, response_head_extend, response_tail_extend, base_frame, filter_para) # Till now, all cell data of all runs is saved in 'all_cell_list'. # Last part, saving files. All cells in one file, dtype = dic. all_cell_dic = {} for i in range(all_cell_num): all_cell_dic[all_cell_list[i]['Name']] = all_cell_list[i] ot.Save_Variable(save_folder, '_' + animal_name + '_' + date + location + '_All_Cells', all_cell_dic, '.ac') return True
#%%Get F and dF trains here. cell_folder = r'H:\Test_Data\2P\210112_L76_2P\1-007\Results\All_Stim' from Standard_Parameters.Sub_Graph_Dics import Sub_Dic_Generator from Standard_Stim_Processor import One_Key_Stim_Maps # Run07,OD OD_Para = Sub_Dic_Generator('OD_2P') One_Key_Stim_Maps(r'E:\Test_Data\2P\210112_L76_2P\1-007', cell_folder, OD_Para) # Run08_G8 G8_Para = Sub_Dic_Generator('G8+90') One_Key_Stim_Maps(r'E:\Test_Data\2P\210112_L76_2P\1-008', cell_folder, G8_Para) One_Key_Stim_Maps(r'E:\Test_Data\2P\210112_L76_2P\1-009', cell_folder, G8_Para) One_Key_Stim_Maps(r'E:\Test_Data\2P\210112_L76_2P\1-011', cell_folder, G8_Para) RG_Para = Sub_Dic_Generator('RGLum4') One_Key_Stim_Maps(r'E:\Test_Data\2P\210112_L76_2P\1-014', cell_folder, RG_Para) One_Key_Stim_Maps(r'E:\Test_Data\2P\210112_L76_2P\1-015', cell_folder, RG_Para) C7D8_Para = Sub_Dic_Generator('Color7Dir8') One_Key_Stim_Maps(r'H:\Test_Data\2P\210112_L76_2P\1-013', cell_folder, C7D8_Para,have_blank = False) S3D8_Para = Sub_Dic_Generator('Shape3Dir8') One_Key_Stim_Maps(r'H:\Test_Data\2P\210112_L76_2P\1-016', cell_folder, S3D8_Para,have_blank = False) #%% Then calculate spon cell response. cell_dic = OS_Tools.Load_Variable(r'H:\Test_Data\2P\210112_L76_2P\1-007\Results\All_Stim\All_Stim.cell') all_cell_mask = cell_dic['Cell_Graph'][:,:,0] from My_Wheels.Average_Intensity_Calculator import AI_Calculator frame_series = AI_Calculator(r'H:\Test_Data\2P\210112_L76_2P\1-001\Results\Aligned_Frames') cell_series = AI_Calculator(r'H:\Test_Data\2P\210112_L76_2P\1-001\Results\Aligned_Frames',masks = all_cell_mask) #%% Then calculate
def Standard_Stim_Processor(data_folder, stim_folder, sub_dic, alinged_sub_folder=r'\Results\Aligned_Frames', show_clip=3, tuning_graph=False, cell_method='Default', filter_method='Gaussian', LP_Para=((5, 5), 1.5), HP_Para=False, spike_train_path='Default', spike_train_filter_para=(False, False), spike_train_filter_method=False): ''' Generate subtraction graph, cell graph and tuning graphs if requred. Parameters ---------- data_folder : (str) Run folder. stim_folder : (str) Stim file folder or Frame_Stim_Align File folder. Pre align is advised. sub_dic : (Dic) Subtraction dicionary. This can be generated from My_Wheels.Standard_Parameters show_clip : (float), optional Clip of graph show. The default is 3. tuning_graph : (bool), optional Whether we generate tuning graph of each cells. The default is False. cell_method : (str), optional Cell find method. You can input cell file path here. The default is 'Default'. filter_method : (str), optional False to skip filter. Kernel function of graph filtering. The default is 'Gaussian'. LP_Para : (turple), optional False to skip. Low pass filter of graph. The default is ((5,5),1.5). HP_Para : (turple), optional False to skip. High pass filter of graph. Big HP can be very slow!. The default is False. spike_train_path : (str), optional Path of spike train.'Default' will generate spike train directly. The default is 'Default'. spike_train_filter_para : (turple), optional Signal filter bandpass propotion of spike train. Please be sure if you need this. The default is (False,False). spike_train_filter_method : (str), optional False to skip. Method of signal filtering. The default is False. Returns ------- None. ''' # Path Cycle. from Cell_Find_From_Graph import On_Off_Cell_Finder work_folder = data_folder + r'\Results' OS_Tools.mkdir(work_folder) aligned_frame_folder = data_folder + alinged_sub_folder OS_Tools.mkdir(aligned_frame_folder) # Step1, align graphs. If already aligned, just read if not os.listdir(aligned_frame_folder): # if this is a new folder print('Aligned data not found. Aligning here..') Translation_Alignment([data_folder]) aligned_all_tif_name = np.array( OS_Tools.Get_File_Name(aligned_frame_folder) ) # Use numpy array, this is easier for slice. # Step2, get stim fram align matrix. If already aligned, just read in aligned dictionary. file_detector = len(stim_folder.split('.')) if file_detector == 1: # Which means input is a folder print('Frame Stim not Aligned, aligning here...') from My_Wheels.Stim_Frame_Align import Stim_Frame_Align _, Frame_Stim_Dic = Stim_Frame_Align(stim_folder) else: # Input is a file Frame_Stim_Dic = OS_Tools.Load_Variable(stim_folder) # Step3, get cell information if cell_method == 'Default': # meaning we will use On-Off graph to find cell. print('Cell information not found. Finding here..') cell_dic = On_Off_Cell_Finder(aligned_all_tif_name, Frame_Stim_Dic, filter_method=filter_method, LP_Para=LP_Para, HP_Para=HP_Para) else: cell_dic = OS_Tools.Load_Variable(cell_method) # Step4, calculate spike_train. if spike_train_path != 'Default': dF_F_train = OS_Tools.Load_Variable(spike_train_path) else: # meaning we need to calculate spike train from the very begining. _, dF_F_train = Spike_Train_Generator( aligned_all_tif_name, cell_dic['All_Cell_Information'], Base_F_type='nearest_0', stim_train=Frame_Stim_Dic['Original_Stim_Train'], LP_Para=LP_Para, HP_Para=HP_Para, filter_method=filter_method) #Step5, filt spike trains. if spike_train_filter_method != False: # Meaning we need to do train filter. for i in range(len(dF_F_train)): dF_F_train[i] = My_Filter.Signal_Filter(dF_F_train, spike_train_filter_method, spike_train_filter_para) # Step6, get each frame graph and cell graph. all_graph_keys = list(sub_dic.keys()) for i in range(len(sub_dic)): output_folder = work_folder + r'\Subtraction_Graphs' current_key = all_graph_keys[i] current_sub_list = sub_dic[current_key] A_conds = current_sub_list[0] # condition of A graph B_conds = current_sub_list[1] # condition of B graph A_IDs = [] B_IDs = [] for i in range(len(A_conds)): A_IDs.extend(Frame_Stim_Dic[A_conds[i]]) for i in range(len(B_conds)): B_IDs.extend(Frame_Stim_Dic[B_conds[i]]) # Get frame maps. current_sub_graph, current_t_graph, current_F_info = Single_Subgraph_Generator( aligned_all_tif_name, A_IDs, B_IDs, filter_method, LP_Para, HP_Para) current_sub_graph = Graph_Tools.Clip_And_Normalize( current_sub_graph, show_clip) Graph_Tools.Show_Graph(current_sub_graph, current_key + '_SubGraph', output_folder) current_t_graph = Graph_Tools.Clip_And_Normalize( current_t_graph, show_clip) Graph_Tools.Show_Graph(current_t_graph, current_key + '_T_Graph', output_folder) OS_Tools.Save_Variable(output_folder, current_key + '_Sub_Info', current_F_info, extend_name='.info') # Get cell maps cell_info = cell_dic['All_Cell_Information'] current_cell_sub_graph, current_cell_t_graph, current_cell_info = Single_Cellgraph_Generator( dF_F_train, cell_info, show_clip, A_IDs, B_IDs) Graph_Tools.Show_Graph(current_cell_sub_graph, current_key + '_Cell_SubGraph', output_folder) Graph_Tools.Show_Graph(current_cell_t_graph, current_key + '_Cell_T_Graph', output_folder) OS_Tools.Save_Variable(output_folder, current_key + '_Cell_Info', current_cell_info, extend_name='.info') #Step7, calculate cell tuning graph. if tuning_graph == True: print('Not finished yet.')
Cell_Find_And_Plot(r'G:\Test_Data\2P\201121_L76_LM\1-001\Results', 'Run_Average_After_Align.tif', 'Morpho', find_thres=1.5) #%% Calculate Spike Train of Run01 Morpho cell into each run. from My_Wheels.Spike_Train_Generator import Spike_Train_Generator all_run_folder = [ r'G:\Test_Data\2P\201121_L76_LM\1-002', r'G:\Test_Data\2P\201121_L76_LM\1-003', r'G:\Test_Data\2P\201121_L76_LM\1-004' ] for i in range(3): all_tif_name = OS_Tools.Get_File_Name(all_run_folder[i] + r'\Results\Aligned_Frames') cell_information = OS_Tools.Load_Variable( all_run_folder[i] + r'\Results\Morpho\Morpho.cell')['All_Cell_Information'] stim_train = OS_Tools.Load_Variable( all_run_folder[i] + r'\Results\Stim_Fram_Align.pkl')['Original_Stim_Train'] F_train, dF_F_train = Spike_Train_Generator(all_tif_name, cell_information, Base_F_type='nearest_0', stim_train=stim_train) OS_Tools.Save_Variable(all_run_folder[i] + r'\Results\Morpho', 'F_train', F_train) OS_Tools.Save_Variable(all_run_folder[i] + r'\Results\Morpho', 'dF_F_train', dF_F_train) #%% Then Get graph of each run. from My_Wheels.Standard_Stim_Processor import Standard_Stim_Processor from My_Wheels.Standard_Parameters.Sub_Graph_Dics import Sub_Dic_Generator