def process_image_and_series(config, spec, output_ds):

    imageds = ImageDataSet(config.ids_uri)
    wall_stack = imageds.get_stack(
        spec.image_name,
        spec.series_name,
        0,
        config.wall_channel
    )
    logger.info(f"Loaded {spec.series_name} with shape {wall_stack.shape}")
    zoomed_wall_stack = zoom_to_match_scales(wall_stack)
    snfmt = spec.series_name.replace(" ", "_").replace("#", "")

    level = config.params['level']
    logging.info(f"Segmenting with level {level}")
    segmentation = sitk_watershed_segmentation(
        zoomed_wall_stack,
        level=config.params["level"]
    )

    wall_output_relpath = f"{spec.image_name}_{snfmt}_cell_wall.tif"
    seg_output_relpath = f"{spec.image_name}_{snfmt}_segmentation_L{level}.tif"

    wall_output_abspath = output_ds.prepare_staging_abspath_promise(wall_output_relpath)
    seg_output_abspath = output_ds.prepare_staging_abspath_promise(seg_output_relpath)

    segmentation.save(seg_output_abspath)
    zoomed_wall_stack.save(wall_output_abspath)
Exemplo n.º 2
0
def get_stack_by_imname_sname(ids_uri, imname, sname, channel=0):

    ids = ImageDataSet.from_uri(ids_uri)

    raw_stack = ids.get_stack(imname, sname, channel=channel)
    zoomed_stack = zoom_to_match_scales(raw_stack)

    return zoomed_stack
Exemplo n.º 3
0
def get_stack_by_name(ids_uri, root_name, channel=0):

    ids = ImageDataSet.from_uri(ids_uri)
    name_lookup = dict(ids.get_image_series_name_pairs())
    series_name = name_lookup[root_name]

    raw_stack = ids.get_stack(root_name, series_name, channel=channel)
    zoomed_stack = zoom_to_match_scales(raw_stack)

    return zoomed_stack
Exemplo n.º 4
0
def segment_image_from_dataset(imageds,
                               image_name,
                               series_name,
                               wall_channel,
                               output_filename,
                               level=0.664,
                               nsegments=200):

    logging.info("Loading wall stack")
    wall_stack = imageds.get_stack(image_name, series_name, 0, wall_channel)
    logging.info("Adjusting scales")
    zoomed_wall_stack = zoom_to_match_scales(wall_stack)
    logging.info("Segmenting image")
    segmentation = sitk_watershed_segmentation(zoomed_wall_stack, level=level)
    logging.info(f"Filtering segmentation by cell size, max {nsegments} cells")
    filtered_segmentation = filter_segmentation_by_size(
        segmentation, nsegments)
    filtered_segmentation.save(output_filename)
Exemplo n.º 5
0
def main(dataset_uri):

    logging.basicConfig(level=logging.INFO)

    imageds = ImageDataSet(dataset_uri)

    print(imageds.all_possible_stack_tuples())
    image_name = '20200309_lhp1_W10_T14'
    series_name = 'SDB995-5_01'
    wall_channel = 1

    logging.info("Loading wall stack")
    wall_stack = imageds.get_stack(image_name, series_name, 0, wall_channel)
    logging.info("Adjusting scales")
    zoomed_wall_stack = zoom_to_match_scales(wall_stack)

    output_filename = f'{image_name}_{series_name}_wall.tif'
    zoomed_wall_stack.save(output_filename)
Exemplo n.º 6
0
    def load_by_name(self, name):
        base_dirpath = os.path.join(self.segmentations_dirpath, name)

        file_info_fname = "Root_segments.tif.csv"
        segmentation_name = "Root_segments.tif.tif"

        segmentation_fpath = os.path.join(base_dirpath, segmentation_name)

        volume = volread(segmentation_fpath)
        transposed = np.transpose(volume, axes=(1, 2, 0))

        segmentation = transposed.view(Segmentation3D)
        raw_stack = self.get_stack_by_series_name(name)
        measure_stack = zoom_to_match_scales(raw_stack)

        file_info_fpath = os.path.join(base_dirpath, file_info_fname)
        fids_to_rids = self.load_file_data(file_info_fpath)

        return segmentation, measure_stack, fids_to_rids
Exemplo n.º 7
0
def get_zoomed_stack_cached(ids_uri, image_name, series_name, channel):
    stack = get_stack_cached(ids_uri, image_name, series_name, channel)
    return zoom_to_match_scales(stack)