def after_align(self):  #这个用来在对齐后平均。
     print('Generationg averaged graphs...')
     self.aligned_tif_name = []
     global_aligned_tif_name = []
     for i in range(len(
             self.aligned_frame_folder)):  #把每个run里的tif_name存到各自文件夹里
         self.aligned_tif_name.append(
             pp.tif_name(self.aligned_frame_folder[i]))
         global_aligned_tif_name.extend(self.aligned_tif_name[i])
         temp_aligned_tif_name = self.save_folder[
             i] + r'\\aligned_tif_name.pkl'
         pp.save_variable(self.aligned_tif_name[i], temp_aligned_tif_name)
         run_average = self.frame_average(self.aligned_tif_name[i])
         pp.save_variable(run_average,
                          self.save_folder[i] + r'\\Run_Average_graph.pkl')
         self.save_graph('After_Align_Run' + self.run_lists[i], run_average,
                         self.save_folder[i])
     #接下来保存全局平均,也存在每个文件里
     global_average_graph = self.frame_average(global_aligned_tif_name)
     for i in range(len(self.save_folder)):
         self.save_graph('After_Align_Global', global_average_graph,
                         self.save_folder[i])
         pp.save_variable(
             global_average_graph,
             self.save_folder[i] + r'\\Global_Average_graph.pkl')
 def path_cycle(self):  #遍历目录,把来组不同run的数据都
     self.run_tif_name = []
     self.global_tif_name = []  #这个是全局的tif,把所有的都放到了一起之后的。
     self.save_folder = []
     self.aligned_frame_folder = []
     for i in range(len(self.data_folder)):
         self.run_tif_name.append(pp.tif_name(
             self.data_folder[i]))  #这里是append,注意保留了不同folder的结构
         self.global_tif_name.extend(pp.tif_name(
             self.data_folder[i]))  #这个是extend,放到一起了
         print('There are ', len(self.run_tif_name[i]), 'tifs in condition',
               self.run_lists[i])
         temp_result, temp_frame = self.folder_generation(
             self.data_folder[i])
         self.save_folder.append(temp_result)
         self.aligned_frame_folder.append(temp_frame)
Beispiel #3
0
        self.pool.join()
        print('Calculation Done, Plotting...\n')
        self.plot_initialize()
        self.pool_set()
        self.pool.map(self.plot_spike_train, range(0, self.cell_Num))
        self.pool.close()
        self.pool.join()

    #%%


if __name__ == '__main__':

    save_folder = r'E:\ZR\Data_Temp\191026_L69_LM\1-010\results'
    start_time = time.time()
    print('Spike_Train Calculating...\n')
    cell_group = pp.read_variable(save_folder +
                                  r'\\Cell_Groups_Morphology.pkl')  #画细胞的来源
    aligned_frame_name = pp.tif_name(save_folder + r'\\Aligned_Frames')
    graph_after_align = pp.read_variable(
        save_folder + r'\Run_Average_graph.pkl')  #注意这个是df/f的基准帧
    cell_find_type = 'Morphology'
    st = Spike_Train(cell_group, aligned_frame_name, graph_after_align,
                     save_folder, 5, cell_find_type)
    st.main()
    spike_train = st.spike_train
    pp.save_variable(spike_train,
                     save_folder + r'\spike_train_' + cell_find_type + '.pkl')
    print('Calculation Done!\n')
    finish_time = time.time()
    print('Task Time Cost:' + str(finish_time - start_time) + 's')