Exemple #1
0
def main():
    parser = argparse.ArgumentParser(description="make images out of brain imaging data")
    parser.add_argument("--input", dest="image", help="full path to jpg image", type=str, default=None, required=True)
    parser.add_argument("--db", dest="db", help="path to folder for png images for database", type=str, default=None)
    parser.add_argument("--sample", dest="sample", help="sample every SAMPLEth pixel", type=int, default=10)
    parser.add_argument(
        "--N",
        dest="N",
        help="Number of top N brains to sample from when seleting image. Larger N means more variation in brains and color.",
        type=float,
        default=20,
    )
    parser.add_argument("--update", dest="update", help="regenerate png database", default=False, action="store_true")
    parser.add_argument("--background-color", dest="bgcolor", help="background color", type=str, default="black")
    parser.add_argument(
        "--color-lookup",
        dest="lookup",
        help="color lookup (white, black) which currently determined background color.",
        type=str,
        default="white",
    )
    parser.add_argument("--output-folder", dest="output", help="output folder for html file", type=str, default=None)

    try:
        args = parser.parse_args()
    except:
        parser.print_help()
        sys.exit(0)

    # Regenerate database of png images
    if args.update == True:
        if args.db is not None:
            get_data(args.folder)
        else:
            print "Please specify location for png images for database with --db argument"
    else:
        if args.image == None:
            print "Please specify input jpg image with --input argument."

        # Check background color
        if args.lookup not in ["black", "white"]:
            print "Unrecognized lookup table! Setting to white."
            args.lookup = "white"

        generate(
            template=args.image,
            output_folder=args.output,
            color_lookup=args.lookup,
            bgcolor=args.bgcolor,
            top=args.N,
            sample=args.sample,
        )
Exemple #2
0
def main():
    parser = argparse.ArgumentParser(
        description="make images out of brain imaging data")
    parser.add_argument("--input",
                        dest='image',
                        help="full path to jpg image",
                        type=str,
                        default=None,
                        required=True)
    parser.add_argument("--db",
                        dest='db',
                        help="path to folder for png images for database",
                        type=str,
                        default=None)
    parser.add_argument("--sample",
                        dest='sample',
                        help="sample every SAMPLEth pixel",
                        type=int,
                        default=10)
    parser.add_argument(
        "--N",
        dest='N',
        help=
        "Number of top N brains to sample from when seleting image. Larger N means more variation in brains and color.",
        type=float,
        default=20)
    parser.add_argument('--update',
                        dest='update',
                        help="regenerate png database",
                        default=False,
                        action='store_true')
    parser.add_argument("--background-color",
                        dest='bgcolor',
                        help="background color",
                        type=str,
                        default="black")
    parser.add_argument(
        "--color-lookup",
        dest='lookup',
        help=
        "color lookup (white, black) which currently determined background color.",
        type=str,
        default="white")
    parser.add_argument("--output-folder",
                        dest='output',
                        help="output folder for html file",
                        type=str,
                        default=None)

    try:
        args = parser.parse_args()
    except:
        parser.print_help()
        sys.exit(0)

    # Regenerate database of png images
    if args.update == True:
        if args.db is not None:
            get_data(args.folder)
        else:
            print "Please specify location for png images for database with --db argument"
    else:
        if args.image == None:
            print "Please specify input jpg image with --input argument."

        # Check background color
        if args.lookup not in ["black", "white"]:
            print "Unrecognized lookup table! Setting to white."
            args.lookup = "white"

        generate(template=args.image,
                 output_folder=args.output,
                 color_lookup=args.lookup,
                 bgcolor=args.bgcolor,
                 top=args.N,
                 sample=args.sample)
Exemple #3
0
from brainart.mosaic import generate
import shutil
import os
import re

# If you use the command line tool, a mosaic will be generated using
# the database of online images. This script will show how that
# database was generated, and how you can make your own set

download_folder = "/home/vanessa/Documents/Work/NEUROVAULT/mosaic"
png_folder = "%s/png" % (download_folder)
if not os.path.exists(png_folder):
    os.mkdir(png_folder)

# Download NeuroVault collections, non thresholded, MNI, with DOI, group maps
brainmaps = get_data(download_folder)

# For each of the below, images with black backgrounds and white bgs are produced

# brains with multiple colors from matplotlib color maps
png_colormaps = make_colormap_brains(brainmaps, png_folder)

# Single brains (using 500+ hex colors) - this function returns the table
lookup_table_hex = make_hexcolor_brains(brainmaps, png_folder)

# Split into black and white
lookups = dict()
exp = re.compile("white")
white_index = [x for x in lookup_table_hex.index.tolist() if exp.search(x)]
black_index = [x for x in lookup_table_hex.index.tolist() if not exp.search(x)]
lookups["white"] = lookup_table_hex.loc[white_index]
Exemple #4
0
from brainart.mosaic import generate
import shutil
import os
import re

# If you use the command line tool, a mosaic will be generated using
# the database of online images. This script will show how that
# database was generated, and how you can make your own set

download_folder = "/home/vanessa/Documents/Work/NEUROVAULT/mosaic"
png_folder = "%s/png" % (download_folder)
if not os.path.exists(png_folder):
    os.mkdir(png_folder)

# Download NeuroVault collections, non thresholded, MNI, with DOI, group maps
brainmaps = get_data(download_folder)

# For each of the below, images with black backgrounds and white bgs are produced

# brains with multiple colors from matplotlib color maps
png_colormaps = make_colormap_brains(brainmaps, png_folder)

# Single brains (using 500+ hex colors) - this function returns the table
lookup_table_hex = make_hexcolor_brains(brainmaps, png_folder)

# Split into black and white
lookups = dict()
exp = re.compile("white")
white_index = [x for x in lookup_table_hex.index.tolist() if exp.search(x)]
black_index = [x for x in lookup_table_hex.index.tolist() if not exp.search(x)]
lookups["white"] = lookup_table_hex.loc[white_index]