def pop(self, cores, multiplier): global args to_give = {} for i in range(int(cores * multiplier)): filename = self.queue.pop() to_give[i] = {"title":filename, "data": read_output(filename, args.path)} return dill.dumps(to_give)
def main_loop(outputs, master_ip = False, in_data = False, split_range = (False, False)): from plugins.analysis import spikes from plugins.importer import spikesDictToArray #???? Depends on kind of analysis, what to do?? neurons_to_analyze = [4, 5] #FIXME: read from cli #TODO: add loop count idx = 0 total = len(outputs) for f in outputs: if not master_ip: #Locale, read file data, input_conf = read_output(f, args.path, idx, total) else: #Already read file from host data, input_conf = in_data[idx][0], in_data[idx][1] idx += 1 if not data: continue # FIXME: re-enable when dispatch works # if args.save_images: # cprint("Saving image",'info') # ImageIO.ImageFromSpikes( # data["NeMo"][1] # , file_path = "./latest.png" #FIXME: set wright path # , save = True # , show = False #Quite useless if True, right? # ) # if args.images_only: # continue neuron_number = 0 neurons_info = {} all_neurons_spikes_list = spikesDictToArray(data["NeMo"][1]) if len(all_neurons_spikes_list) < max(neurons_to_analyze) -1: neurons_info={} for n in neurons_to_analyze: neurons_info[n] = {} neurons_info[n]["on_time"] = 0 neurons_info[n]["off_time"] = 0 neurons_info[n]["mode"] = 3 #Dead neuron neurons_info[n]["not_burst_freq"] = 0 neurons_info[n]["burst_freq"] = 0 else: for i in all_neurons_spikes_list: #What's the pythonic way to do this? if neuron_number not in neurons_to_analyze: neuron_number +=1 continue raw, thresholded = spikes.neuronSpikesToSquare( i, data["ran_steps"], split_range=split_range) off_time, on_time, osc, periods = spikes.getFreq( (raw, thresholded), data["ran_steps"]) not_burst_freq, burst_freq = spikes.getBurstFreq(raw, thresholded) if not osc: #Not oscillating state = max(off_time, on_time) if state == off_time: mode = 0 #Neuron is stable OFF else: mode = 2 #Neuron is stable ON else: #Neuron IS oscillating mode = 1 #Neuron is both ON and OFF neurons_info[neuron_number] = {} neurons_info[neuron_number]["on_time"] = on_time neurons_info[neuron_number]["off_time"] = off_time neurons_info[neuron_number]["mode"] = mode neurons_info[neuron_number]["not_burst_freq"] = not_burst_freq neurons_info[neuron_number]["burst_freq"] = burst_freq neuron_number += 1 to_write = return_analysis_output(f, neurons_info, input_conf, data["ran_steps"]) general_config, config_hash = f.split("_")[0:2] with open("ANALYSIS_period.csv", 'a') as filewriter: for on, p in enumerate(periods): for l in p.items(): filewriter.write("%s,%s,%s,%s,%s\n" % ( general_config, config_hash, l[0], l[1], on)) if not master_ip: # is_folder("analysis") TODO: better dir organization save = open("ANALYSIS.csv", 'a')#We could open this before save.write(to_write) save.close() #And close it after, to speed up else: response_request(to_write, master_ip, "10665")