def make(self, key): """ Pseudocode for process: 1) Get the segment id from the key 2) Get the decimated mesh 3) Get the somas info 4) Run the preprocessing 5) Calculate all starter stats 6) Save the file in a certain location 7) Pass stats and file location to insert """ whole_pass_time = time.time() #1) Get the segment id from the key segment_id = key["segment_id"] description = str(key['decimation_version']) + "_25" print(f"\n\n\n---- Working on Neuron {key['segment_id']} ----") global_start = time.time() #2) Get the decimated mesh current_neuron_mesh = du.fetch_segment_id_mesh(segment_id) #3) Get the somas info somas = du.get_soma_mesh_list(segment_id) soma_ver = du.get_soma_mesh_list_ver(segment_id) print(f"somas = {somas}") #3b) Get the glia and nuclei information glia_faces, nuclei_faces = du.get_segment_glia_nuclei_faces( segment_id, return_empty_list=True) #4) Run the preprocessing total_neuron_process_time = time.time() print(f"\n--- Beginning preprocessing of {segment_id}---") recovered_neuron = neuron.Neuron( mesh=current_neuron_mesh, somas=somas, segment_id=segment_id, description=description, suppress_preprocessing_print=False, suppress_output=False, calculate_spines=True, widths_to_calculate=["no_spine_median_mesh_center"], glia_faces=glia_faces, nuclei_faces=nuclei_faces, ) print( f"\n\n\n---- Total preprocessing time = {time.time() - total_neuron_process_time}" ) #5) Don't have to do any of the processing anymore because will do in the neuron object stats_dict = recovered_neuron.neuron_stats() #6) Save the file in a certain location save_time = time.time() ret_file_path = recovered_neuron.save_compressed_neuron( output_folder=str(du.get_decomposition_path()), return_file_path=True, export_mesh=False, suppress_output=True) ret_file_path_str = str(ret_file_path.absolute()) + ".pbz2" print(f"Save time = {time.time() - save_time}") #7) Pass stats and file location to insert new_key = dict(key, ver=soma_ver, process_version=process_version, index=0, multiplicity=1, decomposition=ret_file_path_str, n_vertices=len(current_neuron_mesh.vertices), n_faces=len(current_neuron_mesh.faces), run_time=np.round(time.time() - whole_pass_time, 4)) new_key.update(stats_dict) keys_to_delete = [ "axon_length", "axon_area", "max_soma_volume", "max_soma_n_faces" ] for k_to_delete in keys_to_delete: del new_key[k_to_delete] self.insert1(new_key, allow_direct_insert=True, skip_duplicates=True) print( f"\n\n ------ Total time for {segment_id} = {time.time() - global_start} ------" )
def make(self, key): """ Pseudocode for process: 1) Get the segment id from the key 2) Get the decimated mesh 3) Get the somas info 4) Run the preprocessing 5) Calculate all starter stats 6) Save the file in a certain location 7) Pass stats and file location to insert """ whole_pass_time = time.time() #1) Get the segment id from the key segment_id = key["segment_id"] description = str(key['decimation_version']) + "_25" print(f"\n\n----- Working on {segment_id}-------") global_start = time.time() #2) Get the decimated mesh current_neuron_mesh = du.fetch_segment_id_mesh(segment_id, minnie=minnie) #3) Get the somas info *************************** Need to change this when actually run ******************* somas = du.get_soma_mesh_list(segment_id, minnie=minnie) print(f"somas = {somas}") #4) Run the preprocessing total_neuron_process_time = time.time() print(f"\n--- Beginning preprocessing of {segment_id}---") recovered_neuron = neuron.Neuron( mesh=current_neuron_mesh, somas=somas, segment_id=segment_id, description=description, suppress_preprocessing_print=False, suppress_output=False, calculate_spines=True, widths_to_calculate=["no_spine_median_mesh_center"]) print( f"\n\n\n---- Total preprocessing time = {time.time() - total_neuron_process_time}" ) #5) Don't have to do any of the processing anymore because will do in the neuron object stats_dict = recovered_neuron.neuron_stats() #6) Save the file in a certain location save_time = time.time() ret_file_path = recovered_neuron.save_compressed_neuron( output_folder=str(du.get_decomposition_path()), return_file_path=True, export_mesh=False, suppress_output=True) ret_file_path_str = str(ret_file_path.absolute()) + ".pbz2" print(f"Save time = {time.time() - save_time}") #7) Pass stats and file location to insert new_key = dict(key, decomposition=ret_file_path_str, n_vertices=len(current_neuron_mesh.vertices), n_faces=len(current_neuron_mesh.faces), run_time=np.round(time.time() - whole_pass_time, 4)) new_key.update(stats_dict) self.insert1(new_key, allow_direct_insert=True, skip_duplicates=True) print( f"\n\n ------ Total time for {segment_id} = {time.time() - global_start} ------" )