lama/qc/collate_qc.py
def make_grid(root: Path, outdir, qc_type='red_cyan', height='auto'):
    """

    Parameters
    ----------
    root
        A Lama registrtion root for a line (or the baselines) containing multiple specimens
    outpath
        Where to put the final image. Filetype is from extension (can use .png and .pdf at least)
    height:
        the css height property for the img (Use 'auto' or px. Percentage sclaing messes things up

    """
    # Create series of images specimen-based view

    # d = DataIterator(root)

    # spec: SpecimenDataPaths

    single_file = True

    oris = [HtmlGrid('axial', single_file=single_file),
            HtmlGrid('coronal', single_file=single_file),
            HtmlGrid('sagittal', single_file=single_file)]

    for i, spec in enumerate(get_specimen_dirs(root)):
        try:
            spec.setup()
        except FileNotFoundError as e:
            print(f'Skipping {spec.specimen_id}\n{e}')
            continue

        if qc_type == 'red_cyan':
            rc_qc_dir = spec.qc_red_cyan_dirs
        elif qc_type == 'grey':
            rc_qc_dir = spec.qc_grey_dirs
        elif qc_type == 'labels':
            rc_qc_dir = spec.qc_inverted_labels

        for grid in oris:
            spec.specimen_id
            spec_title = f'{spec.line_id}: {spec.specimen_id}'
            grid.next_row(title=spec_title)

            # s = list((rc_qc_dir / grid.title).iterdir())
            for img_path in natsorted((rc_qc_dir / grid.title).iterdir(), key=lambda x: x.stem):
                img_path = img_path.resolve()
                outdir = outdir.resolve()

                if single_file: # abspath
                    path_to_use = img_path
                else: # Relative path
                    path_to_use = Path(os.path.relpath(img_path, outdir))

                img_caption = f'{truncate_str(img_path.stem, 30)}'
                tooltip = f'{spec.line_id}:{spec.specimen_id}:{img_path.stem}'
                grid.next_image(path_to_use, img_caption, tooltip)

        for grid in oris:
            ori_out = outdir / f'{grid.title}.html'
            grid.save(ori_out, height)


    Parameters
    ----------
    root
        A Lama registrtion root for a line (or the baselines) containing multiple specimens
    outpath
        Where to put the final image. Filetype is from extension (can use .png and .pdf at least)
    height:
        the css height property for the img (Use 'auto' or px. Percentage sclaing messes things up

    
Parameters
root
A Lama registrtion root for a line (or the baselines) containing multiple specimens
outpath
Where to put the final image. Filetype is from extension (can use .png and .pdf at least)
height:
the css height property for the img (Use 'auto' or px. Percentage sclaing messes things up
Parameters root A Lama registrtion root for a line ( or the baselines ) containing multiple specimens outpath Where to put the final image . Filetype is from extension ( can use . png and . pdf at least ) height : the css height property for the img ( Use ' auto ' or px . Percentage sclaing messes things up
def make_grid(root: Path, outdir, qc_type='red_cyan', height='auto'):
    single_file = True
    oris = [HtmlGrid('axial', single_file=single_file),
            HtmlGrid('coronal', single_file=single_file),
            HtmlGrid('sagittal', single_file=single_file)]
    for i, spec in enumerate(get_specimen_dirs(root)):
        try:
            spec.setup()
        except FileNotFoundError as e:
            print(f'Skipping {spec.specimen_id}\n{e}')
            continue
        if qc_type == 'red_cyan':
            rc_qc_dir = spec.qc_red_cyan_dirs
        elif qc_type == 'grey':
            rc_qc_dir = spec.qc_grey_dirs
        elif qc_type == 'labels':
            rc_qc_dir = spec.qc_inverted_labels
        for grid in oris:
            spec.specimen_id
            spec_title = f'{spec.line_id}: {spec.specimen_id}'
            grid.next_row(title=spec_title)
            for img_path in natsorted((rc_qc_dir / grid.title).iterdir(), key=lambda x: x.stem):
                img_path = img_path.resolve()
                outdir = outdir.resolve()
                if single_file: 
                    path_to_use = img_path
                else: 
                    path_to_use = Path(os.path.relpath(img_path, outdir))
                img_caption = f'{truncate_str(img_path.stem, 30)}'
                tooltip = f'{spec.line_id}:{spec.specimen_id}:{img_path.stem}'
                grid.next_image(path_to_use, img_caption, tooltip)
        for grid in oris:
            ori_out = outdir / f'{grid.title}.html'
            grid.save(ori_out, height)
def make_grid ( root : Path , outdir , qc_type = 'red_cyan' , height = 'auto' ) : single_file = True oris = [ HtmlGrid ( 'axial' , single_file = single_file ) , HtmlGrid ( 'coronal' , single_file = single_file ) , HtmlGrid ( 'sagittal' , single_file = single_file ) ] for i , spec in enumerate ( get_specimen_dirs ( root ) ) : try : spec . setup ( ) except FileNotFoundError as e : print ( f'Skipping {spec.specimen_id}\n{e}' ) continue if qc_type == 'red_cyan' : rc_qc_dir = spec . qc_red_cyan_dirs elif qc_type == 'grey' : rc_qc_dir = spec . qc_grey_dirs elif qc_type == 'labels' : rc_qc_dir = spec . qc_inverted_labels for grid in oris : spec . specimen_id spec_title = f'{spec.line_id}: {spec.specimen_id}' grid . next_row ( title = spec_title ) for img_path in natsorted ( ( rc_qc_dir / grid . title ) . iterdir ( ) , key = lambda x : x . stem ) : img_path = img_path . resolve ( ) outdir = outdir . resolve ( ) if single_file : path_to_use = img_path else : path_to_use = Path ( os . path . relpath ( img_path , outdir ) ) img_caption = f'{truncate_str(img_path.stem, 30)}' tooltip = f'{spec.line_id}:{spec.specimen_id}:{img_path.stem}' grid . next_image ( path_to_use , img_caption , tooltip ) for grid in oris : ori_out = outdir / f'{grid.title}.html' grid . save ( ori_out , height )
Parameters
root
A Lama registrtion root for a line (or the baselines) containing multiple specimens
outpath
Where to put the final image.
Parameters root A Lama registrtion root for a line ( or the baselines ) containing multiple specimens outpath Where to put the final image .
"""

    Parameters
    ----------
    root
        A Lama registrtion root for a line (or the baselines) containing multiple specimens
    outpath
        Where to put the final image. Filetype is from extension (can use .png and .pdf at least)
    height:
        the css height property for the img (Use 'auto' or px. Percentage sclaing messes things up

    """ # Create series of images specimen-based view # d = DataIterator(root) # spec: SpecimenDataPaths # s = list((rc_qc_dir / grid.title).iterdir()) # abspath # Relative path
root
Path
outdir
qc_type
height