def init_config(methods=METHODS):

    config = [a3.Input('Input Image', a3.types.ImageFloat)]

    method_param = a3.Parameter('Method', a3.types.enum)
    for idx, m in enumerate(methods):
        method_param.setIntHint(str(m), idx)
    config.append(method_param)

    #Add inputfield for BlockSize
    param_blocksize = a3.Parameter('BlockSize', a3.types.float)
    param_blocksize.setIntHint('min', 2)
    param_blocksize.setIntHint('max', 800)
    param_blocksize.setIntHint('stepSize', 1),
    config.append(param_blocksize)

    #Add inputfield for Offset
    param_offset = a3.Parameter('Offset', a3.types.float)
    param_offset.setIntHint('min', 0)
    param_offset.setIntHint('max', 800)
    param_offset.setIntHint('stepSize', 1),
    config.append(param_offset)

    config.append(a3.Output('Output Image', a3.types.ImageFloat))

    return config
Exemplo n.º 2
0
def generate_config(methods=meth_list):

    methods.remove('Manual')
    #Set Outputs and inputs
    config = [
        a3.Input('Image', a3.types.GeneralPyType),
        a3.Input('File Path', a3.types.url),
        a3.Input('Output Path', a3.types.url),
        a3.Parameter('Channel', a3.types.int8).setIntHint('default', 1)
        #.setIntHint('max', 8)
        .setIntHint('min', 1),
        #.setIntHint('unusedValue', 1),
    ]

    #Set parameters
    param = a3.Parameter('Method', a3.types.enum)
    for idx, m in enumerate(methods):
        param.setIntHint(str(m), idx)
    config.append(param)

    config.append(
        a3.Parameter('Manual Threshold Value',
                     a3.types.float).setFloatHint('default', float(math.inf)))
    #.setFloatHint('unusedValue', float(math.inf))
    #.setFloatHint('stepSize', 1))
    config.append(a3.Parameter('Slice/Stack Histogram', a3.types.bool))
    config.append(
        a3.Parameter('Save Images',
                     a3.types.bool).setFloatHint('default', False))

    return config
Exemplo n.º 3
0
def generate_config(methods=METHODS):

    #Set Outputs and inputs
    config = [
        a3.Input('File Path', a3.types.url),
        a3.Input('Output Path', a3.types.url),
        a3.Input('Input Image', a3.types.GeneralPyType),
        a3.Output('Thresholded Image', a3.types.GeneralPyType)
    ]

    #Set parameters
    param = a3.Parameter('Method', a3.types.enum)
    for idx, m in enumerate(methods):
        param.setIntHint(str(m), idx)

    config.append(param)
    config.append(
        a3.Parameter('Manual threshold value',
                     a3.types.float).setFloatHint('default', float(math.inf)))
    #.setFloatHint('unusedValue', float(math.inf))
    #.setFloatHint('stepSize', 1))
    config.append(a3.Parameter('Slice/Stack histogram', a3.types.bool))

    switch_list = [
        a3.Parameter('Save Threshold(s)',
                     a3.types.bool).setBoolHint("default", True),
        a3.Parameter('Save Image',
                     a3.types.bool).setBoolHint("default", False)
    ]
    config.extend(switch_list)

    return config
Exemplo n.º 4
0
def generate_config(filters=[TRANSLATE[key] for key in FILTERS]):

    #Set Outputs and inputs
    config = [
        a3.Input('Source Image', a3.types.ImageFloat),
        a3.Input('Mask Image', a3.types.ImageFloat),
        a3.Output('Analyzed Image', a3.types.ImageFloat),
        a3.Output('Analyzed Binary', a3.types.ImageFloat),
        a3.Output('Analyzed Database', a3.types.GeneralPyType)
    ]

    #Set parameters
    for f in filters:
        for m in ['min', 'max']:
            config.append(
                a3.Parameter('{} {}'.format(
                    f, m), a3.types.float).setFloatHint(
                        'default',
                        0 if m == 'min' else float(math.inf)).setFloatHint(
                            'unusedValue',
                            0 if m == 'min' else float(math.inf)))

    switch_list = [
        a3.Parameter('Keep/Remove filtered objects',
                     a3.types.bool).setBoolHint("default", False),
        a3.Parameter('Filter objects on border',
                     a3.types.bool).setBoolHint("default", False),
        a3.Parameter('Volume in pixels/um\u00B3',
                     a3.types.bool).setBoolHint("default", False)
    ]
    config.extend(switch_list)

    return config
Exemplo n.º 5
0
def generate_config(methods=METHODS):

    config = [
        a3.Input('Input Image', a3.types.ImageFloat),
        a3.Output('Output Image', a3.types.ImageFloat)
    ]

    param = a3.Parameter('Method', a3.types.enum)
    for idx, m in enumerate(methods):
        param.setIntHint(str(m), idx)

    config.append(param)

    config.append(a3.Parameter('Stack Histogram', a3.types.bool))

    return config
Exemplo n.º 6
0
def generate_config(filters=FILTERS):

    #Set Outputs and inputs
    config = [
        a3.Input('File Path', a3.types.url),
        a3.Input('Output Path', a3.types.url),
        a3.Input('ChA Image', a3.types.GeneralPyType),
        a3.Input('ChA DataBase', a3.types.GeneralPyType),
        a3.Input('ChB Image', a3.types.GeneralPyType),
        a3.Input('ChB DataBase', a3.types.GeneralPyType),
        a3.Output('Overlapping Image', a3.types.GeneralPyType),
        a3.Output('Overlapping Binary', a3.types.GeneralPyType),
        a3.Output('Overlapping DataBase', a3.types.GeneralPyType),
        a3.Output('Overlapping Path', a3.types.url)
    ]

    #Set parameters
    for f in filters:

        for m in ['min', 'max']:

            config.append(
                a3.Parameter('{} {}'.format(
                    TRANSLATE[f], m), a3.types.float).setFloatHint(
                        'default',
                        0 if m == 'min' else DEFAULT_VALUE[f]).setFloatHint(
                            'default', 0
                            if m == 'min' else DEFAULT_VALUE[f]).setFloatHint(
                                'unusedValue',
                                0 if m == 'min' else DEFAULT_VALUE[f]))

    switch_list = [
        a3.Parameter('Keep/Remove filtered objects',
                     a3.types.bool).setBoolHint("default", False),
        a3.Parameter('Volume in pixels/um\u00B3',
                     a3.types.bool).setBoolHint("default", False),
        a3.Parameter('Save to xlsx/text', a3.types.bool)
    ]
    config.extend(switch_list)

    return config
Exemplo n.º 7
0
def generate_config(methods=METHODS):

    #Set Outputs and inputs
    config = [
        a3.Input('Input Image', a3.types.ImageFloat),
        a3.Output('Thresholded Image', a3.types.ImageFloat)
    ]

    #Set parameters
    param = a3.Parameter('Method', a3.types.enum)
    for idx, m in enumerate(methods):
        param.setIntHint(str(m), idx)

    config.append(param)
    config.append(
        a3.Parameter('Manual threshold value',
                     a3.types.float).setFloatHint('default', float(math.inf)))
    #.setFloatHint('unusedValue', float(math.inf))
    #.setFloatHint('stepSize', 1))
    config.append(a3.Parameter('Slice/Stack histogram', a3.types.bool))

    return config
Exemplo n.º 8
0
def generate_config():

    config = [
        a3.Input('Input Image', a3.types.ImageFloat),
        a3.Output('Output Image', a3.types.ImageFloat)
    ]

    #Add inputfield for Upper threshold
    param_upper = a3.Parameter('Upper', a3.types.float)
    #param_upper.setIntHint('min', 0)
    #param_upper.setIntHint('max', 65535)
    param_upper.setIntHint('stepSize', 1),
    config.append(param_upper)

    #Add inputfield for Lower threshold
    param_lower = a3.Parameter('Lower', a3.types.float)
    #param_lower.setIntHint('min', 0)
    #param_lower.setIntHint('max', 65535)
    param_lower.setIntHint('stepSize', 1),
    config.append(param_lower)

    return config
Exemplo n.º 9
0
from pathlib import Path
import a3dc_module_interface as a3
from modules.a3dc_modules.a3dc.utils import os_open
from modules.a3dc_modules.a3dc.utils import error


def module_main(ctx):
    try:
        extensions = ['.txt', '.xlsx']
        path = a3.inputs['Path'].path

        if a3.inputs['Show'] and Path(path).suffix in extensions:
            os_open(path)

    except Exception as e:
        raise error("Error occured while executing '" + str(ctx.type()) +
                    "' module '" + str(ctx.name()) + "' !",
                    exception=e)


a3.def_process_module(
    [a3.Input('Path', a3.types.url),
     a3.Parameter('Show', a3.types.bool)], module_main)
Exemplo n.º 10
0
        #img.metadata['Path']=filename

        #Create Output
        #Extract channel from image array
        a3.outputs['Channel 1'] = img.get_dimension(a3.inputs['Channel'],
                                                    'C').to_multidimimage()
        #to_multidimimage(Image(array.astype(np.float),copy.deepcopy(img.metadata)))

        #Finalization
        tstop = time.clock()
        print('Processing finished in ' + str((tstop - tstart)) + ' seconds! ')
        print('Image loaded successfully!')
        print(SEPARATOR)

    except Exception as e:
        raise error("Error occured while executing '" + str(ctx.type()) +
                    "' module '" + str(ctx.name()) + "' !",
                    exception=e)


config = [
    a3.Parameter('Channel',
                 a3.types.int8).setFloatHint('default',
                                             0).setFloatHint('unusedValue', 0),
    a3.Input('Image', a3.types.GeneralPyType),
    a3.Input('MetaData', a3.types.GeneralPyType),
    a3.Output('Channel', a3.types.ImageFloat)
]

a3.def_process_module(config, module_main)
Exemplo n.º 11
0
        a3.outputs['first selected channel'] = input_channels[sel_1]
    else:
        raise RuntimeError('invalid value for \'first selected channel\': {}'
                           .format(sel_1))

    if 0 <= sel_2 < 4:
        a3.outputs['second selected channel'] = input_channels[sel_2]
    else:
        raise RuntimeError('invalid value for \'second selected channel\': {}'
                           .format(sel_1))


config = [a3.Input('channel 1', a3.types.ImageFloat),
          a3.Input('channel 2', a3.types.ImageFloat),
          a3.Input('channel 3', a3.types.ImageFloat),
          a3.Input('channel 4', a3.types.ImageFloat),
          a3.Parameter('first selected channel', a3.types.enum)
            .setIntHint("channel 1", 0)
            .setIntHint("channel 2", 1)
            .setIntHint("channel 3", 2)
            .setIntHint("channel 4", 3),
          a3.Parameter('second selected channel', a3.types.enum)
            .setIntHint("channel 1", 0)
            .setIntHint("channel 2", 1)
            .setIntHint("channel 3", 2)
            .setIntHint("channel 4", 3),
          a3.Output('first channel', a3.types.ImageFloat),
          a3.Output('second channel', a3.types.ImageFloat)]

a3.def_process_module(config, module_main)
Exemplo n.º 12
0
import a3dc_module_interface as a3
from modules.a3dc_modules.a3dc.utils import error
import os


def module_main(ctx):

    if os.path.isfile(a3.inputs['File'].path):
        a3.outputs['File'] = a3.inputs['File']
    else:
        error(
            "Error occured while executing '" + str(ctx.type()) +
            "' module '" + str(ctx.name()) + "' !",
            OSError('Path is not a file!'))


config = [
    a3.Parameter('File', a3.types.url).setBoolHint('folder', False),
    a3.Output('File', a3.types.url)
]

a3.def_process_module(config, module_main)
Exemplo n.º 13
0
    print('such string: {}'.format(a3.inputs['such string 🐕']))
    print('so filename: {}'.format(a3.inputs['so filename'].path))
    print('wow integer: {}'.format(a3.inputs['wow integer']))
    print('much float: {}'.format(a3.inputs['much float']))
    print('very bool: {}'.format(a3.inputs['very bool']))
    print('so enum: {}'.format(a3.inputs['so enum']))
    print('int16 in [-7, 9674]: {}'.format(a3.inputs['int16 in [-7, 9674]']))
    print('uint16 in [42, 72000]: {}'.format(
        a3.inputs['uint16 in [42, 72000]']))
    print('uint32 in [42, 72000]: {}'.format(
        a3.inputs['uint32 in [42, 72000]']))
    print('Bye 🐕')


config = [
    a3.Parameter('such string 🐕', a3.types.string),
    a3.Parameter('wow', a3.types.int8),
    a3.Parameter('so filename', a3.types.url),
    a3.Parameter('wow integer', a3.types.int8).setIntHint('min', 2).setIntHint(
        'unusedValue', 42).setIntHint('max', 64),
    a3.Parameter('much float',
                 a3.types.float).setFloatHint('min', -0.5).setFloatHint(
                     'unusedValue', -0.2)
    # .setFloatHint('max', 1.72)
    .setFloatHint('stepSize', 0.1),
    a3.Parameter('very bool', a3.types.bool),
    a3.Parameter('so enum', a3.types.enum).setIntHint("option1", 0).setIntHint(
        "option2", 1).setIntHint("option3", 42),
    a3.Parameter('int16 in [-7, 9674]',
                 a3.types.int16).setIntHint('min', -7).setIntHint('max', 9674),
    a3.Parameter('uint16 in [42, 72000]',
Exemplo n.º 14
0
    'name': 'float',
    'type': a3.types.float,
    'min': -2.34,
    'max': 45.9435,
    'default': 7.32,
    'unusedValue': 2.9483,
    'setter': a3.Parameter.setFloatHint
}]

config = []
for a in params:
    for b in product([0, 1], repeat=4):
        min_str = 'min:' + str(a['min']) if b[0] else ''
        max_str = 'max:' + str(a['max']) if b[1] else ''
        def_str = 'default:' + str(a['default']) if b[2] else ''
        unused_str = 'unusedValue:' + str(a['unusedValue']) if b[3] else ''
        name = '{} {} {} {} {}'.format(a['name'], min_str, max_str, def_str,
                                       unused_str)
        x = a3.Parameter(name, a['type'])
        if b[0]:
            a['setter'](x, 'min', a['min'])
        if b[1]:
            a['setter'](x, 'max', a['max'])
        if b[2]:
            a['setter'](x, 'default', a['default'])
        if b[3]:
            a['setter'](x, 'unusedValue', a['unusedValue'])
        config.append(x)

a3.def_process_module(config, module_main)
Exemplo n.º 15
0
    x, y, z = np.meshgrid(x_, y_, z_, indexing='ij')
    sp1 = np.maximum(
        0, 32 - np.sqrt(
            np.square(x - c1[0]) + np.square(y - c1[1]) +
            np.square(z - c1[2])))
    sp2 = np.maximum(
        0, 32 - np.sqrt(
            np.square(x - c2[0]) + np.square(y - c2[1]) +
            np.square(z - c2[2])))

    a3.outputs['sphere 1'] = a3.MultiDimImageFloat_from_ndarray(sp1)
    a3.outputs['sphere 2'] = a3.MultiDimImageFloat_from_ndarray(sp2)


config = [
    a3.Parameter('width', a3.types.uint16).setIntHint('min', 1).setIntHint(
        'max', 2048).setIntHint('default', 64),
    a3.Parameter('height', a3.types.uint16).setIntHint('min', 1).setIntHint(
        'max', 2048).setIntHint('default', 64),
    a3.Parameter('depth', a3.types.uint16).setIntHint('min', 1).setIntHint(
        'max', 2048).setIntHint('default', 16),
    a3.Parameter('sphere 1 x', a3.types.uint16).setIntHint(
        'min', 1).setIntHint('max', 2048).setIntHint('default', 24),
    a3.Parameter('sphere 2 y', a3.types.uint16).setIntHint(
        'min', 1).setIntHint('max', 2048).setIntHint('default', 48),
    a3.Output('sphere 1', a3.types.ImageFloat),
    a3.Output('sphere 2', a3.types.ImageFloat)
]

a3.def_process_module(config, module_main)
Exemplo n.º 16
0
import numpy as np


def module_main(ctx):
    w = a3.inputs['width']
    h = a3.inputs['height']
    d = a3.inputs['depth']
    seed = a3.inputs['seed']
    nlabels = a3.inputs['number of labels']
    np.random.seed(seed)

    vol = np.random.randint(nlabels, size=(w, h, d)).astype(np.uint32)

    a3.outputs['labels'] = a3.MultiDimImageUInt32_from_ndarray(vol)
    print('your labeled volume is ready!🎲')


config = [
    a3.Parameter('width', a3.types.uint16).setIntHint('min', 1).setIntHint(
        'max', 2048).setIntHint('default', 64),
    a3.Parameter('height', a3.types.uint16).setIntHint('min', 1).setIntHint(
        'max', 2048).setIntHint('default', 64),
    a3.Parameter('depth', a3.types.uint16).setIntHint('min', 1).setIntHint(
        'max', 2048).setIntHint('default', 16),
    a3.Parameter('seed', a3.types.uint16).setIntHint('default', 42),
    a3.Parameter('number of labels', a3.types.uint16).setIntHint('default', 5),
    a3.Output('labels', a3.types.ImageUInt32)
]

a3.def_process_module(config, module_main)
Exemplo n.º 17
0
    level = a3.inputs['level']
    # TODO: this is a naive way, we should not copy the data with
    # MultiDimImageFloat_to_ndarray and MultiDimImageFloat_from_ndarray
    # but do the leveling in-place
    input_image = a3.MultiDimImageFloat_to_ndarray(a3.inputs['input'])

    if a3.inputs['input'].meta.has('type'):
        print('type', a3.inputs['input'].meta.get('type'))

    if a3.inputs['input'].meta.has('normalized'):
        print('normalized', a3.inputs['input'].meta.get('normalized'))

    if a3.inputs['input'].meta.has('path'):
        print('path', a3.inputs['input'].meta.get('path'))

    if a3.inputs['input'].meta.has('channel'):
        print('channel', a3.inputs['input'].meta.get('channel'))

    print(str(a3.inputs['input'].meta))

    bin_image = (input_image >= level) * 1.0
    a3.outputs['binary volume'] = a3.MultiDimImageFloat_from_ndarray(bin_image)
    print('binarization complete 🍰')


config = [a3.Input('input', a3.types.ImageFloat),
    a3.Parameter('level', a3.types.float),
    a3.Output('binary volume', a3.types.ImageFloat)]

a3.def_process_module(config, module_main)
Exemplo n.º 18
0
# -*- coding: utf-8 -*-
"""
Created on Fri Sep 14 09:02:31 2018

@author: pongor.csaba
"""

import a3dc_module_interface as a3


def module_main(ctx):

    a3.outputs['float output'] = a3.inputs['much float']

    print('much float: {}'.format(a3.inputs['much float']))


config = [
    a3.Parameter('much float',
                 a3.types.float).setIntHint('min', -5).setIntHint(
                     'unusedValue', 1000),
    a3.Parameter('very bool', a3.types.bool).setBoolHint('s', False),
    # .setFloatHint('max', 1.72)
    #.setFloatHint('stepSize', 0.1),
    a3.Output('float output', a3.types.float)
]

a3.def_process_module(config, module_main)
Exemplo n.º 19
0
    if os.path.isfile(path):
        file_list.remove(path)
        file_list.insert(0, path)

    if len(file_list) == 0:
        raise Warning('path {} is empty'.format(base_dir))

    index = ctx.run_id()
    if index < len(file_list) - 1:
        ctx.set_require_next_run(True)
    else:
        ctx.set_require_next_run(False)

    url = a3.Url()
    url.path = file_list[index]

    #Print current filename and index
    _, curr_filename = os.path.split(url.path)
    print('Currently processing:', curr_filename)

    #Set output
    a3.outputs['file'] = url

    print(SEPARATOR)


config = [a3.Parameter('path', a3.types.url), a3.Output('file', a3.types.url)]

def_process_module(config, module_main)
Exemplo n.º 20
0
import a3dc_module_interface as a3

def module_main(ctx):
    
    a3.outputs['Directory']=a3.inputs['Directory']
    #if os.path.isdir(a3.inputs['Directory'].path):
        #a3.outputs['Directory']=a3.inputs['Directory']
    #else:
        #error("Error occured while executing '"+str(ctx.type())+"' module '"+str(ctx.name())+"' !", OSError('Path is not a directory!'))
    
config = [
    a3.Parameter('Directory', a3.types.url).setBoolHint('folder', True),
    a3.Output('Directory',  a3.types.url)]

a3.def_process_module(config, module_main)
Exemplo n.º 21
0
        #Read Parameters
        params = read_params()
        save_database(params['Database'],
                      params['Path'],
                      params['Filename'],
                      to_text=params['Save to text'])

        #Finalization
        print('Object analysis was run successfully!')
        print(SEPARATOR)

    except IOError as e:
        print("Warning: Failed to write to file!!", file=sys.stderr)
        print(str(e), file=sys.stderr)

    except Exception as e:
        error("Error occured while executing '" + str(ctx.type()) +
              "' module '" + str(ctx.name()) + "' !",
              exception=e)


#Set Outputs and inputs
config = [
    a3.Input('DataBase', a3.types.GeneralPyType),
    a3.Parameter('Filename', a3.types.string),
    a3.Parameter('Path', a3.types.url).setBoolHint('folder', True),
    a3.Parameter('Save to text', a3.types.bool)
]

a3.def_process_module(config, module_main)
Exemplo n.º 22
0
        #Create Output 1
        ch_1_Nb = a3.inputs['Channel'] - 1
        ch_1 = img.get_dimension(ch_1_Nb, 'C')
        ch_1.metadata['Path'] = filename
        ch_1.reorder('ZYXCT')
        a3.outputs['Channel'] = ch_1

        #Finalization
        tstop = time.clock()
        print('Processing finished in ' + str((tstop - tstart)) + ' seconds! ')
        print('Image loaded successfully!')
        print(SEPARATOR)

    except Exception as e:
        raise error("Error occured while executing '" + str(ctx.type()) +
                    "' module '" + str(ctx.name()) + "' !",
                    exception=e)


config = [
    a3.Input('FileName', a3.types.url),
    a3.Parameter('Channel', a3.types.int8).setIntHint('default', 1)
    #.setIntHint('max', 8)
    .setIntHint('min', 1),
    #.setIntHint('unusedValue', 1),
    a3.Output('Channel', a3.types.GeneralPyType)
]

a3.def_process_module(config, module_main)
Exemplo n.º 23
0
import a3dc_module_interface as a3
from modules.a3dc_modules.a3dc.utils import error
import os


def module_main(ctx):

    if os.path.exists(a3.inputs['Path'].path):
        a3.outputs['Path'] = a3.inputs['Path']
    else:
        error("Error occured while executing '" + str(ctx.type()) +
              "' module '" + str(ctx.name()) + "'! Invalid path!!")


config = [a3.Parameter('Path', a3.types.url), a3.Output('Path', a3.types.url)]

a3.def_process_module(config, module_main)