Exemple #1
0
    # set switches and parameters
    parser = argparse.ArgumentParser(
        prog='python mm3_Compile.py',
        description=
        'Identifies and slices out channels into individual TIFF stacks through time.'
    )
    parser.add_argument('-f',
                        '--paramfile',
                        type=str,
                        required=True,
                        help='Yaml file containing parameters.')
    namespace = parser.parse_args()

    # Load the project parameters file
    mm3.information('Loading experiment parameters.')
    if namespace.paramfile:
        param_file_path = namespace.paramfile
    else:
        mm3.warning('No param file specified. Using 100X template.')
        param_file_path = 'yaml_templates/params_SJ110_100X.yaml'
    p = mm3.init_mm3_helpers(param_file_path)  # initialized the helper library

    # define variables here
    source_dir = p['experiment_directory']
    dest_dir = os.path.join(source_dir, 'TIFF')
    file_prefix = p['experiment_name']  # prefix for output images
    file_name_filters = p['metamorphToTIFF']['file_name_filters']

    if not os.path.exists(dest_dir):
        os.makedirs(dest_dir)
Exemple #2
0
    parser = argparse.ArgumentParser(prog='python mm3_Track.py',
                                     description='Track cells and create lineages.')
    parser.add_argument('-f', '--paramfile', type=str,
                        required=True, help='Yaml file containing parameters.')
    parser.add_argument('-o', '--fov', type=str,
                        required=False, help='List of fields of view to analyze. Input "1", "1,2,3", or "1-10", etc.')
    # parser.add_argument('-p', '--peak', type=str,
    #                     required=False, help='List of peak ids to analyze. Input "1", "1,2,3", or "1-10", etc.')
    parser.add_argument('-j', '--nproc', type=int,
                        required=False, help='Number of processors to use.')
    parser.add_argument('-m', '--modelfile', type=str,
                        required=False, help='Path to trained model.')
    namespace = parser.parse_args()

    # Load the project parameters file
    mm3.information('Loading experiment parameters.')
    if namespace.paramfile:
        param_file_path = namespace.paramfile
    else:
        mm3.warning('No param file specified. Using 100X template.')
        param_file_path = 'yaml_templates/params_SJ110_100X.yaml'
    p = mm3.init_mm3_helpers(param_file_path) # initialized the helper library

    if namespace.fov:
        if '-' in namespace.fov:
            user_spec_fovs = range(int(namespace.fov.split("-")[0]),
                                   int(namespace.fov.split("-")[1])+1)
        else:
            user_spec_fovs = [int(val) for val in namespace.fov.split(",")]
    else:
        user_spec_fovs = []
Exemple #3
0
    # set switches and parameters
    parser = argparse.ArgumentParser(prog='python mm3_Compile.py',
                                     description='Identifies and slices out channels into individual TIFF stacks through time.')
    parser.add_argument('-f', '--paramfile',  type=str,
                        required=True, help='Yaml file containing parameters.')
    parser.add_argument('-o', '--fov',  type=str,
                        required=False, help='List of fields of view to analyze. Input "1", "1,2,3", or "1-10", etc.')
    parser.add_argument('-j', '--nproc',  type=int,
                        required=False, help='Number of processors to use.')
    parser.add_argument('-m', '--modelfile', type=str,
                        required=False, help='Path to trained U-net model.')
    namespace = parser.parse_args()

    # Load the project parameters file
    mm3.information('Loading experiment parameters.')
    if namespace.paramfile:
        param_file_path = namespace.paramfile
    else:
        mm3.warning('No param file specified. Using 100X template.')
        param_file_path = 'yaml_templates/params_SJ110_100X.yaml'
    p = mm3.init_mm3_helpers(param_file_path) # initialized the helper library

    if namespace.fov:
        if '-' in namespace.fov:
            user_spec_fovs = range(int(namespace.fov.split("-")[0]),
                                   int(namespace.fov.split("-")[1])+1)
        else:
            user_spec_fovs = [int(val) for val in namespace.fov.split(",")]
    else:
        user_spec_fovs = []
Exemple #4
0
        '--fov',
        type=str,
        required=False,
        help='List of fields of view to analyze. Input "1", "1,2,3", etc. ')
    parser.add_argument(
        '-c',
        '--cellfile',
        type=file,
        required=False,
        help=
        'Path to Cell object dicionary to analyze. Defaults to complete_cells.pkl.'
    )
    namespace = parser.parse_args()

    # Load the project parameters file
    mm3.information('Loading experiment parameters.')
    if namespace.paramfile.name:
        param_file_path = namespace.paramfile.name
    else:
        mm3.warning('No param file specified. Using 100X template.')
        param_file_path = 'yaml_templates/params_SJ110_100X.yaml'
    p = mm3.init_mm3_helpers(param_file_path)  # initialized the helper library

    if namespace.fov:
        user_spec_fovs = [int(val) for val in namespace.fov.split(",")]
    else:
        user_spec_fovs = []

    # load cell file
    mm3.information('Loading cell data.')
    if namespace.cellfile:
Exemple #5
0
                        '--paramfile',
                        type=str,
                        required=True,
                        help='Yaml file containing parameters.')
    parser.add_argument(
        '-o',
        '--fov',
        type=str,
        required=False,
        help=
        'List of fields of view to analyze. Input "1", "1,2,3", or "1-3", etc.'
    )
    namespace = parser.parse_args()

    # Load the project parameters file
    mm3.information('Loading experiment parameters.')
    if namespace.paramfile:
        param_file_path = namespace.paramfile
    else:
        mm3.warning('No param file specified. Using 100X template.')
        param_file_path = 'yaml_templates/params_SJ110_100X.yaml'
    p = mm3.init_mm3_helpers(param_file_path)  # initialized the helper library

    if namespace.fov:
        if '-' in namespace.fov:
            user_spec_fovs = range(int(namespace.fov.split("-")[0]),
                                   int(namespace.fov.split("-")[1]) + 1)
        else:
            user_spec_fovs = [int(val) for val in namespace.fov.split(",")]
    else:
        user_spec_fovs = []
Exemple #6
0
    parser = argparse.ArgumentParser(prog='python mm3_Segment.py',
                                     description='Segment cells and create lineages.')
    parser.add_argument('-f', '--paramfile', type=str,
                        required=True, help='Yaml file containing parameters.')
    parser.add_argument('-i', '--infile', type=str,
                        required=False, help='Use this argument to segment ONLY on image. Name the single file to be segmented.')
    parser.add_argument('-o', '--fov', type=str,
                        required=False, help='List of fields of view to analyze. Input "1", "1,2,3", or "1-10", etc.')
    parser.add_argument('-j', '--nproc', type=int,
                        required=False, help='Number of processors to use.')
    parser.add_argument('-m', '--modelfile', type=str,
                        required=False, help='Path to trained U-net model.')
    namespace = parser.parse_args()

    # Load the project parameters file
    mm3.information('Loading experiment parameters.')
    if namespace.paramfile:
        param_file_path = namespace.paramfile
    else:
        mm3.warning('No param file specified. Using 100X template.')
        param_file_path = 'yaml_templates/params_SJ110_100X.yaml'
    p = mm3.init_mm3_helpers(param_file_path) # initialized the helper library

    if namespace.fov:
        if '-' in namespace.fov:
            user_spec_fovs = range(int(namespace.fov.split("-")[0]),
                                   int(namespace.fov.split("-")[1])+1)
        else:
            user_spec_fovs = [int(val) for val in namespace.fov.split(",")]
    else:
        user_spec_fovs = []
Exemple #7
0
if __name__ == "__main__":
    '''
    This script adds foci location information onto an existing dictionary of cells.
    '''

    # set switches and parameters
    parser = argparse.ArgumentParser(prog='python mm3_Foci.py',
                                     description='Finds foci.')
    parser.add_argument('-f', '--paramfile', type=str,
                        required=True, help='Yaml file containing parameters.')
    parser.add_argument('-c', '--cellfile', type=str,
                        required=False, help='Path to Cell object dicionary to analyze. Defaults to complete_cells.pkl.')
    namespace = parser.parse_args()

    # Load the project parameters file
    mm3.information('Loading experiment parameters.')
    if namespace.paramfile:
        param_file_path = namespace.paramfile
    else:
        mm3.warning('No param file specified. Using 100X template.')
        param_file_path = 'yaml_templates/params_SJ110_100X.yaml'
    p = mm3.init_mm3_helpers(param_file_path) # initialized the helper library

    # load cell file
    mm3.information('Loading cell data.')
    if namespace.cellfile:
        cell_file_path = namespace.cellfile
    else:
        mm3.warning('No cell file specified. Using complete_cells.pkl.')
        cell_file_path = os.path.join(p['cell_dir'], 'complete_cells.pkl')
Exemple #8
0
        '-o',
        '--fov',
        type=str,
        required=False,
        help=
        'List of fields of view to analyze. Input "1", "1,2,3", or "1-10", etc.'
    )
    parser.add_argument('-j',
                        '--nproc',
                        type=int,
                        required=False,
                        help='Number of processors to use.')
    namespace = parser.parse_args()

    # Load the project parameters file
    mm3.information('Loading experiment parameters.')
    if namespace.paramfile:
        param_file_path = namespace.paramfile
    else:
        mm3.warning('No param file specified. Using 100X template.')
        param_file_path = 'yaml_templates/params_SJ110_100X.yaml'
    p = mm3.init_mm3_helpers(param_file_path)  # initialized the helper library

    if namespace.fov:
        if '-' in namespace.fov:
            user_spec_fovs = range(int(namespace.fov.split("-")[0]),
                                   int(namespace.fov.split("-")[1]) + 1)
        else:
            user_spec_fovs = [int(val) for val in namespace.fov.split(",")]
    else:
        user_spec_fovs = []
Exemple #9
0
def track_loop(fov_id,
               peak_id,
               params,
               tracks,
               model_dict,
               cell_number=6,
               phase_file_name=None,
               seg_file_name=None):

    if phase_file_name is None:

        seg_stack = mm3.load_stack(fov_id, peak_id, color=params['seg_img'])
        phase_stack = mm3.load_stack(fov_id,
                                     peak_id,
                                     color=params['phase_plane'])

    else:

        seg_stack = io.imread(seg_file_name)
        phase_stack = io.imread(phase_file_name)

    # run predictions for each tracking class
    # consider only the top six cells for a given trap when doing tracking
    frame_number = seg_stack.shape[0]

    # sometimes a phase contrast image is missed and has no signal.
    # This is a workaround for that problem
    no_signal_frames = []
    for k, img in enumerate(phase_stack):
        # if the mean phase image signal is less than 200, add its index to list
        if np.mean(img) < 200:
            no_signal_frames.append(k)

    # loop through segmentation stack and replace frame from missed phase image
    #   with the prior frame.
    for k, label_img in enumerate(seg_stack):
        if k in no_signal_frames:
            seg_stack[k, ...] = seg_stack[k - 1, ...]

    regions_by_time = [
        measure.regionprops(label_image=img) for img in seg_stack
    ]

    # have generator yield info for top six cells in all frames
    prediction_generator = mm3.PredictTrackDataGenerator(
        regions_by_time, batch_size=frame_number, dim=(cell_number, 5, 9))
    cell_info = prediction_generator.__getitem__(0)

    predictions_dict = {}
    # run data through each classification model
    for key, mod in model_dict.items():

        # Run predictions and add to dictionary
        if key in [
                'zero_cell_model', 'one_cell_model', 'two_cell_model',
                'geq_three_cell_model'
        ]:
            continue

        mm3.information(
            'Predicting probability of {} events in FOV {}, trap {}.'.format(
                '_'.join(key.split('_')[:-1]), fov_id, peak_id))
        predictions_dict['{}_predictions'.format(key)] = mod.predict(cell_info)

    G, graph_df = mm3.initialize_track_graph(
        peak_id=peak_id,
        fov_id=fov_id,
        experiment_name=params['experiment_name'],
        predictions_dict=predictions_dict,
        regions_by_time=regions_by_time,
        born_threshold=0.85,
        appear_threshold=0.85)

    tracks.update(mm3.create_lineages_from_graph(G, graph_df, fov_id, peak_id))
Exemple #10
0
                        type=str,
                        required=False,
                        help='Path to trained born model.')
    parser.add_argument('--specfile',
                        type=str,
                        required=False,
                        help='Path to specs file.')
    parser.add_argument('--timefile',
                        type=str,
                        required=False,
                        help='Path to file containing time table.')

    namespace = parser.parse_args()

    # Load the project parameters file
    mm3.information('Loading experiment parameters.')
    if namespace.paramfile:
        param_file_path = namespace.paramfile
    else:
        mm3.warning('No param file specified. Using 100X template.')
        param_file_path = 'yaml_templates/params_SJ110_100X.yaml'
    p = mm3.init_mm3_helpers(param_file_path)  # initialized the helper library

    if namespace.fov:
        if '-' in namespace.fov:
            user_spec_fovs = range(int(namespace.fov.split("-")[0]),
                                   int(namespace.fov.split("-")[1]) + 1)
        else:
            user_spec_fovs = [int(val) for val in namespace.fov.split(",")]
    else:
        user_spec_fovs = []
Exemple #11
0
    parser = argparse.ArgumentParser(prog='python mm3_TrackFoci.py',
                                     description='Track fluorescent foci.')
    parser.add_argument('-f', '--paramfile', type=str,
                        required=True, help='Yaml file containing parameters.')
    parser.add_argument('-o', '--fov', type=str,
                        required=False, help='List of fields of view to analyze. Input "1", "1,2,3", or "1-10", etc.')
    parser.add_argument('-j', '--nproc', type=int,
                        required=False, help='Number of processors to use.')
    parser.add_argument('-c', '--channel', type=int,
                        required=False, default=2,
                        help='Which channel, as an integer, contains your fluorescent foci data? \
                            Accepts integers. Default is 2.')
    namespace = parser.parse_args()

    # Load the project parameters file
    mm3.information('Loading experiment parameters.')
    if namespace.paramfile:
        param_file_path = namespace.paramfile
    else:
        mm3.warning('No param file specified. Using 100X template.')
        param_file_path = 'yaml_templates/params_SJ110_100X.yaml'
    p = mm3.init_mm3_helpers(param_file_path) # initialized the helper library

    if namespace.fov:
        if '-' in namespace.fov:
            user_spec_fovs = range(int(namespace.fov.split("-")[0]),
                                   int(namespace.fov.split("-")[1])+1)
        else:
            user_spec_fovs = [int(val) for val in namespace.fov.split(",")]
    else:
        user_spec_fovs = []
    # set switches and parameters
    parser = argparse.ArgumentParser(
        prog='python combine_tracks_from_chtc.py',
        description=
        'CHTC saves a separate track file for each fov/peak. Here we combine them.'
    )
    parser.add_argument('-f',
                        '--paramfile',
                        type=str,
                        required=True,
                        help='Yaml file containing parameters.')

    namespace = parser.parse_args()

    # Load the project parameters file
    mm3.information('Loading experiment parameters.')
    if namespace.paramfile:
        param_file_path = namespace.paramfile
    else:
        mm3.warning('No param file specified. Using 100X template.')
        param_file_path = 'yaml_templates/params_SJ110_100X.yaml'
    p = mm3.init_mm3_helpers(param_file_path)  # initialized the helper library

    # Get file names
    fnames = glob.glob(
        os.path.join(p['cell_dir'],
                     "{}*_tracks.pkl".format(p['experiment_name'])))

    ### Now prune and save the data.
    mm3.information("Reading cell data from each file and combining into one.")
Exemple #13
0
    # set switches and parameters
    parser = argparse.ArgumentParser(prog='python mm3_Segment.py',
                                     description='Segment cells and create lineages.')
    parser.add_argument('-f', '--paramfile',  type=str,
                        required=True, help='Yaml file containing parameters.')
    parser.add_argument('-o', '--fov',  type=str,
                        required=False, help='List of fields of view to analyze. Input "1", "1,2,3", or "1-10", etc.')
    parser.add_argument('-j', '--nproc',  type=int,
                        required=False, help='Number of processors to use.')
    parser.add_argument('-s', '--segmentsource', type=str,
                        required=False, help='Segmented images to use for tracking. "seg_otsu", "seg_unet", etc.')
    namespace = parser.parse_args()

    # Load the project parameters file
    mm3.information('Loading experiment parameters.')
    if namespace.paramfile:
        param_file_path = namespace.paramfile
    else:
        mm3.warning('No param file specified. Using 100X template.')
        param_file_path = 'yaml_templates/params_SJ110_100X.yaml'
    p = mm3.init_mm3_helpers(param_file_path) # initialized the helper library

    if namespace.fov:
        if '-' in namespace.fov:
            user_spec_fovs = range(int(namespace.fov.split("-")[0]),
                                   int(namespace.fov.split("-")[1])+1)
        else:
            user_spec_fovs = [int(val) for val in namespace.fov.split(",")]
    else:
        user_spec_fovs = []