Example #1
0
def cli(paths, mode, name_regex, pixel_size, dry_run, strict, name, mmap, lazy,
        no_show):
    """
    PeepingTom command line interface.

    Opens files in napari and lands in an interactive ipython shell
    with peepingtom imported as `pt` and the initialised Peeper available as `p`.

    PATHS: any number of files or globs [default='./*']

    \b
    MODE choices:
      - lone: each datablock in a separate volume
      - zip_by_type: one of each datablock type per volume
      - bunch: all datablocks in a single volume

    \b
    EXAMPLES:
    Open a .star file as particles:
        peep particles.star
    Open particles and images from a directory:
        peep /dir/with/star_and_mrc_files/
    Match files such as MyProtein_10.star and MyProtein_001.mrc,
    and name the respective DataBlocks Protein_10 and Protein_001:
        peep /path/to/dir/MyProtein* -n 'Protein_\d+'
    """  # noqa: W605
    if not paths:
        paths = ['./*']

    if dry_run:
        files = pt.io_.find_files(paths)
        print('Files found:')
        print(*(str(file) for file in files), sep='\n')
        sys.exit()

    peeper = pt.read(
        *paths,  # noqa: F841
        name=name,
        mode=mode,
        name_regex=name_regex,
        pixel_size=pixel_size,
        strict=strict,
        mmap=mmap,
        lazy=lazy,
    )

    # set up ipython shell nicely
    banner = '''=== PeepingTom ===
initialised variables:
    - peeper
    - viewer
    '''
    sh = InteractiveShellEmbed(banner2=banner)
    sh.enable_gui('qt')
    sh.push('peeper')
    if not no_show:
        sh.run_cell('peeper.show()', silent=True)
    viewer = peeper.napari_viewer  # noqa: F841
    sh.push('viewer')
    sh()
def main(args):
    red = RedFlyingBaron.from_paths(args, verbose=True)
    shell = InteractiveShellEmbed(banner1="", banner2="")
    shell.push(["red", "RedFlyingBaron"])
    print "\nRedFlyingBaron instance is available under the name 'red':"
    print red
    shell.set_next_input("red")
    shell()
Example #3
0
def cli(paths, mode, name_regex, pixel_size, dry_run, strict, name, lazy,
        no_show):
    """
    Blik command line interface.

    Opens files in napari and lands in an interactive ipython shell
    with blik imported and the initialised DataSet available as `dataset`.

    PATHS: any number of files or globs [default='./*']

    \b
    MODE choices:
      - lone: each datablock in a separate volume
      - zip_by_type: one of each datablock type per volume
      - bunch: all datablocks in a single volume

    \b
    EXAMPLES:
    Open a .star file as particles:
        blik particles.star
    Open particles and images from a directory:
        blik /dir/with/star_and_mrc_files/
    Match files such as MyProtein_10.star and MyProtein_001.mrc,
    and name the respective DataBlocks Protein_10 and Protein_001:
        blik /path/to/dir/MyProtein* -n 'Protein_\d+'
    """  # noqa: W605
    if not paths:
        paths = ['./*']

    if dry_run:
        from blik.io_.reading.main import find_files
        files = [str(file) for file in find_files(paths)]
        if files:
            click.echo('Files found:\n' + '\n'.join(files))
        else:
            click.echo('No files found.')
        click.get_current_context().exit()

    import blik
    from IPython.terminal.embed import InteractiveShellEmbed

    dataset = blik.read(
        *paths,  # noqa: F841
        name=name,
        mode=mode,
        name_regex=name_regex,
        pixel_size=pixel_size,
        strict=strict,
        lazy=lazy,
    )

    # set up ipython shell nicely
    banner = '''=== Blik ===
initialised variables:
    - dataset
    - viewer
    '''
    sh = InteractiveShellEmbed(banner2=banner)
    sh.enable_gui('qt')
    sh.push('dataset')
    if not no_show:
        sh.run_cell('dataset.show()', silent=True)
    viewer = dataset.napari_viewer  # noqa: F841
    sh.push('viewer')
    sh()