def main(): # First, get the dossier infofile = raw_input(str("Specify the path to the json file with animal information: ")) infofile = os.path.abspath(infofile) if not os.path.isfile(infofile): print("Invalid info file! Try again?") exit(1) batch_mode = raw_input(str("Use all entries in the info file? [y/n] ")).lower() if batch_mode == 'n': name_list = raw_input(str("Specify the names of the animals, space separated. (e.g., 'NSS_01 SS_01') ")).split() elif batch_mode == 'y': name_list = None else: print("Invalid answer.") exit(1) variable_names = raw_input(str("Which variables do you want to use? (e.g., 'Y Velocity Curvature') ")).split() num_exps = input(str("Specify the number of comparisons you want to run for each individual: ")) start_time = input(str("Specify the start time of the overall segment in which you want to run the comparisons: ")) end_time = input(str("Specify the end time of the overall segment in which you want to run the comparisons: ")) norm_mode = raw_input(str("Which time segment do you want to normalize over: the predetermined baseline or the specific segment [b/s]: ")) if norm_mode == 'b': norm_mode = 'baseline' elif norm_mode == 's': norm_mode = 'spec' else: print("Invalid norm mode") exit(1) intervals = raw_input(str("Do you want to specify a set of interval lengths to use? [y/n] ")) if intervals == 'y': interval_lengths = raw_input(str("Which interval lengths would you like to use? (e.g., '0.5 1.0 1.25 2.4') ")).split() interval_lengths = [float(l) for l in interval_lengths] elif intervals == 'n': interval_lengths = None else: print("That wasn't quite one of the options...") exit(1) output = raw_input(str("Do you want to write the results into a file? [y/n] ")) if output == 'y': outdir = raw_input(str("Specify the output directory: ")) outdir = os.path.abspath(outdir) outfilename = raw_input(str("Specify the output file name: ")) elif output != 'n': print("That wasn't quite one of the options...") exit(1) animals = locomotion.getAnimalObjs(infofile,name_list) for a in animals: locomotion.trajectory.getCurveData(a) if output == 'y': locomotion.trajectory.runIndividualVariabilityTests(animals, variable_names, norm_mode, num_exps, interval_lengths, outdir, outfilename, start_time, end_time) else: locomotion.trajectory.runIndividualVariabilityTests(animals, variable_names, norm_mode, num_exps, interval_lengths, None, None, start_time, end_time)
def runRobustnessTest(test_key, variables, norm_mode, start_min, end_min): NUM_TESTS = len(testData[test_key]["framerates"]) * len( testData[test_key]["densities"]) results = np.zeros([NUM_CURVES, NUM_TESTS]) for curve_no in range(NUM_CURVES): curve_str = str(curve_no).zfill(ZFILL_LEN) json_path = PATH_TO_RES_DIRECTORY + "/{}/CRV_{}.json".format( test_key, curve_str) # Load all animals animals = locomotion.getAnimalObjs(json_path) for a in animals: locomotion.trajectory.getCurveData(a) # Run BDD against control animal (index 0) control = animals[0] for a_no, a in enumerate(animals[1:]): bdd = locomotion.trajectory.computeOneBDD(a, control, variables, start_min, end_min, start_min, end_min, norm_mode) results[curve_no][a_no] = bdd output = PATH_TO_RES_DIRECTORY + "/{}/Results_BDD.csv".format(test_key) pd.DataFrame(results).to_csv(output, index=False)
def main(): # First, get the dossier infofile = raw_input(str("Specify the path to the json file with animal information: ")) infofile = os.path.abspath(infofile) if not os.path.isfile(infofile): print("Invalid info file! Try again?") exit(1) batch_mode = raw_input(str("Use all entries in the info file? [y/n] ")).lower() if batch_mode == 'n': name_list = raw_input(str("Specify the names of the animals, space separated. (e.g., 'NSS_01 SS_01') ")).split() elif batch_mode == 'y': name_list = None else: print("Invalid answer.") exit(1) variable_names = raw_input(str("Which variables do you want to use? (e.g., 'Y Velocity Curvature') ")).split() start_time = input(str("Specify the start time of the segment you want to compare: ")) end_time = input(str("Specify the end time of the segment you want to compare: ")) norm_mode = raw_input(str("Which time segment do you want to normalize over: the predetermined baseline or the segment specified above [b/s]: ")) if norm_mode == 'b': norm_mode = 'baseline' elif norm_mode == 's': norm_mode = 'spec' else: print("Invalid norm mode") exit(1) output = raw_input(str("Do you want to write the results into a file? [y/n] ")) if output == 'y': outdir = raw_input(str("Specify the output directory: ")) outdir = os.path.abspath(outdir) outfilename = raw_input(str("Specify the output file name: ")) sort_table = raw_input(str("Do you want to sort the output? [y/n] ")) if sort_table == 'y': sort_table = True elif sort_table == 'n': sort_table = False else: print("Invalid input.") exit(1) square_table = raw_input(str("Do you want the distance table to be square instead of upper triangular? [y/n] ")) if square_table == 'y': square_table = True elif square_table == 'n': square_table = False else: print("Invalid input.") exit(1) color_min = input(str("What should be the minimum value for the distance table color scale? ")) color_max = input(str("What should be the maximum value for the distance table color scale? ")) #check 0<=0min<max<=1 elif output != 'n': print("That wasn't quite one of the options...") exit(1) animals = locomotion.getAnimalObjs(infofile,name_list) for a in animals: locomotion.trajectory.getCurveData(a) D = locomotion.trajectory.computeAllBDD(animals, variable_names, start_time, end_time, norm_mode) if output == 'y': locomotion.write.postProcess(animals, D, outdir, outfilename, sort_table, square_table, color_min, color_max)
def main(): # First, get the dossier infofile = raw_input( str("Specify the path to the json file with animal information: ")) infofile = os.path.abspath(infofile) if not os.path.isfile(infofile): print("Invalid info file! Try again?") exit(1) batch_mode = raw_input( str("Use all entries in the info file? [y/n] ")).lower() if batch_mode == 'n': name_list = raw_input( str("Specify the names of the animals, space separated. (e.g., 'NSS_01 SS_01') " )).split() elif batch_mode == 'y': name_list = None else: print("Invalid answer.") exit(1) start_time = input( str("Specify the start time of the segment you want to compare: ")) end_time = input( str("Specify the end time of the segment you want to compare: ")) grid_size = input( str("Specify the grid size for the heatmap (in the same units as the x- and y- dimensions): " )) output = raw_input( str("Do you want to write the results into a file? [y/n] ")) if output == 'y': outdir = raw_input(str("Specify the output directory: ")) outdir = os.path.abspath(outdir) outfilename = raw_input(str("Specify the output file name: ")) sort_table = raw_input(str("Do you want to sort the output? [y/n] ")) if sort_table == 'y': sort_table = True elif sort_table == 'n': sort_table = False else: print("Invalid input.") exit(1) square_table = raw_input( str("Do you want the distance table to be square instead of upper triangular? [y/n] " )) if square_table == 'y': square_table = True elif square_table == 'n': square_table = False else: print("Invalid input.") exit(1) color_min = input( str("What should be the minimum value for the distance table color scale?" )) color_max = input( str("What should be the maximum value for the distance table color scale?" )) elif output != 'n': print("That wasn't quite one of the options...") exit(1) animals = locomotion.getAnimalObjs(infofile, name_list) for a in animals: x_dim, y_dim = a.getDims() if not float(x_dim / grid_size).is_integer() or not float( y_dim / grid_size).is_integer(): print("The grid size must divide each of the dimensions evenly.") exit(1) for a in animals: locomotion.heatmap.getSurfaceData(a, grid_size, start_time, end_time) D = locomotion.heatmap.computeAllCSD(animals) if output == 'y': locomotion.write.postProcess(animals, D, outdir, outfilename, sort_table, square_table, color_min, color_max)