def track_single_file(phase_file_name, seg_file_name, params, namespace): mm3.information("Tracking cells in {}.".format(seg_file_name)) # load model to pass to algorithm mm3.information("Loading model...") params['tracking']['migrate_model'] = namespace.migrate_modelfile params['tracking']['child_model'] = namespace.child_modelfile params['tracking']['appear_model'] = namespace.appear_modelfile params['tracking']['die_model'] = namespace.die_modelfile params['tracking']['disappear_model'] = namespace.disappear_modelfile params['tracking']['born_model'] = namespace.born_modelfile model_dict = mm3.get_tracking_model_dict() fov_id, peak_id = extract_fov_and_peak_ids(phase_file_name) tracks = {} track_loop(fov_id, peak_id, params, tracks, model_dict, phase_file_name=phase_file_name, seg_file_name=seg_file_name) track_file_name = "{}_xy{:0=3}_p{:0=4}_tracks.pkl".format( params['experiment_name'], fov_id, peak_id) with open(track_file_name, 'wb') as cell_file: pickle.dump(tracks, cell_file) sys.exit("Completed tracking cells in stack {}.".format(seg_file_name))
fov_id_list = sorted([fov_id for fov_id in specs.keys()]) # remove fovs if the user specified so if user_spec_fovs: fov_id_list[:] = [fov for fov in fov_id_list if fov in user_spec_fovs] mm3.information("Processing %d FOVs." % len(fov_id_list)) mm3.information("Creating cell lineages.") mm3.information("Reading track models. This could take a few minutes.") # read in models as dictionary # keys are 'migrate_model', 'child_model', 'appear_model', 'die_model', 'disappear_model', etc. # NOTE on 2019-07-15: For now, some of the models are ignored by the tracking algorithm, as they don't yet perform well if namespace.command == 'cells': model_dict = mm3.get_tracking_model_dict() elif namespace.command == 'foci': model_dict = mm3.get_focus_tracking_model_dict() # do lineage creation per fov, per trap tracks = {} for i, fov_id in enumerate(fov_id_list): # tracks[fov_id] = {} # update will add the output from make_lineages_function, which is a # dict of Cell entries, into Cells ana_peak_ids = [ peak_id for peak_id in specs[fov_id].keys() if specs[fov_id][peak_id] == 1 ] if user_spec_peaks: ana_peak_ids[:] = [