Ejemplo n.º 1
0
def main(name, arguments):
    parser.prog = name
    options, args = parser.parse_args(arguments)
    args = cli_tools.glob_args(args)
    if len(args) == 0:
        raise ValueError('Some contour files must be specified!')
    filenames = [path.path(arg) for arg in args]
    contours = simple_interface.load_contours(filenames, show_progress = options.show_progress)
    if options.first_point is not None:
        options.first_point -= 1
    if options.scale is not None or options.rotate is not None or options.units is not None or options.first_point is not None:
        in_radians = False
        if options.units is not None and options.units.lower() in ('um', 'micron', 'microns'):
            options.units = '\N{MICRO SIGN}m'
        contours = simple_interface.transform_contours(contours, options.scale, options.rotate, in_radians, 
            options.units, options.first_point, options.show_progress, title = 'Modifying Contours')
    if options.weights is not None:
        contours = simple_interface.reweight_landmarks(contours, options.weights, options.show_progress)
        
    
    destination = path.path(options.destination)
    destination.makedirs_p()
    # note that with path objects, the '/' operator means 'join path components.'
    names = [destination / filename.name for filename in filenames]
    simple_interface.save_contours(contours, names, options.show_progress)
Ejemplo n.º 2
0
def main(name, arguments):
    parser.prog = name
    options, args = parser.parse_args(arguments)
    args = cli_tools.glob_args(args)
    if len(args) == 0:
        raise ValueError('Some contour files must be specified!')
    filenames = [path.path(arg) for arg in args]
    contours = simple_interface.load_contours(
        filenames, show_progress=options.show_progress)
    if options.reference is not None:
        reference = contour_class.from_file(options.reference)
        contours = simple_interface.align_contours_to(
            contours,
            reference,
            align_steps=options.alignment_steps,
            allow_reflection=options.allow_reflection,
            show_progress=options.show_progress)
    else:
        contours = simple_interface.align_contours(
            contours,
            options.alignment_steps,
            options.allow_reflection,
            max_iters=options.max_iterations,
            show_progress=options.show_progress)
    destination = path.path(options.destination)
    destination.makedirs_p()
    # note that with path objects, the '/' operator means 'join path components.'
    names = [destination / filename.name for filename in filenames]
    simple_interface.save_contours(contours, names, options.show_progress)
Ejemplo n.º 3
0
def main(name, arguments):
    parser.prog = name
    options, args = parser.parse_args(arguments)
    args = cli_tools.glob_args(args)
    if len(args) == 0:
        raise ValueError('Some contour and image files must be specified!')
    intensity_ranges = []
    for r in options.intensity_ranges:
        try:
            low, high = r
        except:
            low = high = r
        intensity_ranges.append([low, high])
    if options.weights is None or len(options.weights) == 0:
        options.weights = [0.5]
    elif len(options.weights) != 1 and len(options.weights) != len(intensity_ranges):
        raise optparse.OptionValueError("Either one or %d weights are required; %d sepcified."%(len(intensity_ranges), len(options.weights)))
    elif sum(options.weights) > 1:
        raise optparse.OptionValueError("The sum of the weights must be <= 1.")

    matches = match_files.match_contours_and_images(args, options.match_by_name, options.show_progress)
    contours, image_names, unmatched_contours, unmatched_image_names = matches
    filenames = [path.path(contour._filename) for contour in contours]
    contours = simple_interface.add_image_landmarks_to_contours(contours, image_names,
        intensity_ranges, options.weights, options.image_type, options.show_progress)
    destination = path.path(options.destination)
    destination.makedirs_p()
    # note that with path objects, the '/' operator means 'join path components.'
    names = [destination / filename.name for filename in filenames]
    simple_interface.save_contours(contours, names, options.show_progress)
Ejemplo n.º 4
0
def main(name, arguments):
    parser.prog = name
    options, args = parser.parse_args(arguments)
    args = cli_tools.glob_args(args)
    if len(args) == 0:
        raise ValueError('Some contour files must be specified!')
    filenames = [path.path(arg) for arg in args]
    contours = simple_interface.load_contours(filenames, show_progress = options.show_progress)
    destination = path.path(options.destination)
    destination.makedirs_p()
    # note that with path objects, the '/' operator means 'join path components.'
    names = [destination / filename.namebase + '.mat' for filename in filenames]
    simple_interface.save_contour_data_for_matlab(contours, names, options.show_progress)
Ejemplo n.º 5
0
def main(name, arguments):
    parser.prog = name
    options, args = parser.parse_args(arguments)
    args = cli_tools.glob_args(args)
    if len(args) == 0:
        raise ValueError('Some contour and image files must be specified!')
    matches = match_files.match_contours_and_images(args,
                                                    options.match_by_name,
                                                    options.show_progress)
    contours, image_names, unmatched_contours, unmatched_image_names = matches
    destination = path.path(options.destination)
    destination.makedirs_p()
    if options.file_type is not None:
        new_names = [
            destination / contour.simple_name() + '.' + options.file_type
            for contour in contours
        ]
    else:
        new_names = [
            destination / contour.simple_name() + image.ext
            for image, contour in zip(image_names, contours)
        ]
    simple_interface.reorient_images(contours,
                                     image_names,
                                     new_names,
                                     pad_factor=options.pad_factor,
                                     mask=options.mask_background,
                                     show_progress=options.show_progress)
Ejemplo n.º 6
0
def get_data(data_files):
  data_ranges = []
  data_names = []
  new_data_files = []
  row_ranges = []
  headers = []
  for df in data_files:
    if type(df) == list:
      df, ranges = df
    else:
      ranges = None
    # read the data file, and don't try to convert column 0 -- the contour names --
    # to anything other than a string.
    data = datafile.DataFile(df, skip_empty = False, type_dict = {0:str})
    header, rows = data.get_header_and_data()
    headers.append(header)
    if ranges is None:
      data_ranges.append(rows)
      data_names.append(path.path(df).namebase)
      new_data_files.append(df)
      if header is None: start = 0
      else: start = 1
      row_ranges.append(range(1+start, len(data.data)+start))
    else:
      for low, high, name in ranges:
        try:
          # recall that low, high give an inclusive, one-indexed range...
          data_ranges.append(data.data[low-1:high])
        except:
          raise ValueError('Cannot get row range (%d, %d) from data file "%s" -- not enough rows?')
        data_names.append(name)
        new_data_files.append(df)
        row_ranges.append(range(low, high+1))
  return headers, data_ranges, data_names, new_data_files, row_ranges
Ejemplo n.º 7
0
def get_data(data_files):
    data_ranges = []
    data_names = []
    new_data_files = []
    row_ranges = []
    headers = []
    for df in data_files:
        if type(df) == list:
            df, ranges = df
        else:
            ranges = None
        # read the data file, and don't try to convert column 0 -- the contour names --
        # to anything other than a string.
        data = datafile.DataFile(df, skip_empty = False, type_dict = {0:str})
        header, rows = data.get_header_and_data()
        headers.append(header)
        if ranges is None:
            data_ranges.append(rows)
            data_names.append(path.path(df).namebase)
            new_data_files.append(df)
            if header is None: start = 0
            else: start = 1
            row_ranges.append(list(range(1+start, len(data.data)+start)))
        else:
            for low, high, name in ranges:
                try:
                    # recall that low, high give an inclusive, one-indexed range...
                    data_ranges.append(data.data[low-1:high])
                except:
                    raise ValueError('Cannot get row range (%d, %d) from data file "%s" -- not enough rows?')
                data_names.append(name)
                new_data_files.append(df)
                row_ranges.append(list(range(low, high+1)))
    return headers, data_ranges, data_names, new_data_files, row_ranges
Ejemplo n.º 8
0
def main(name, arguments):
    parser.prog = name
    options, args = parser.parse_args(arguments)
    args = cli_tools.glob_args(args)
    if len(args) == 0:
        raise ValueError('Some contour files must be specified!')
    filenames = [path.path(arg) for arg in args]
    contours = simple_interface.load_contours(
        filenames, show_progress=options.show_progress)
    destination = path.path(options.destination)
    destination.makedirs_p()
    # note that with path objects, the '/' operator means 'join path components.'
    names = [
        destination / filename.namebase + '.mat' for filename in filenames
    ]
    simple_interface.save_contour_data_for_matlab(contours, names,
                                                  options.show_progress)
Ejemplo n.º 9
0
def main(name, arguments):
    parser.prog = name
    options, args = parser.parse_args(arguments)
    args = cli_tools.glob_args(args)
    if len(args) == 0:
        raise ValueError('Some image files must be specified!')
    filenames = [path.path(arg) for arg in args]
    contours_groups = simple_interface.extract_contours(
        filenames, options.contour_value, options.min_area, options.max_area,
        options.show_progress)
    contours = []
    names = []
    destination = path.path(options.destination)
    destination.makedirs_p()
    for contour_group, image_name in zip(contours_groups, filenames):
        num_contours = len(contour_group)
        if num_contours == 1:
            contours.append(contour_group[0])
            # note that with path objects, the '/' operator means 'join path components.'
            names.append(destination / image_name.namebase + '.contour')
            contour_group[0]._filename = image_name.namebase
        else:
            width = len(str(num_contours))
            for i, contour in enumerate(contour_group):
                contours.append(contour)
                names.append(destination / image_name.namebase +
                             '-%.*d.contour' % (width, i + 1))
                contour._filename = image_name.namebase + '-%.*d' % (width,
                                                                     i + 1)
    if options.scale is not None:
        # if not rescaling, contours are already denominated in pixels, so do nothing.
        units = options.units
        if units.lower() in ('um', 'micron', 'microns'):
            units = '\N{MICRO SIGN}m'
        contours = simple_interface.transform_contours(
            contours,
            scale_factor=options.scale,
            units=units,
            show_progress=options.show_progress,
            title='Rescaling Contours')
    if options.resample:
        contours = simple_interface.resample_contours(contours,
                                                      options.resample_points,
                                                      options.smoothing_factor,
                                                      options.show_progress)
    simple_interface.save_contours(contours, names, options.show_progress)
Ejemplo n.º 10
0
def read_files(files, data_column):
    names = []
    data_out = []
    for df in files:
        names.append(path.path(df).namebase)
        data = datafile.DataFile(df, skip_empty=False, type_dict={0: str})
        header, rows = data.get_header_and_data()
        data_out.append(numpy.array([row[data_column] for row in rows]))
    return names, data_out
Ejemplo n.º 11
0
def main(name, arguments):
  parser.prog = name
  options, args = parser.parse_args(arguments)
  args = cli_tools.glob_args(args)
  if len(args) == 0:
    raise ValueError('Some contour files must be specified!')
  filenames = [path.path(arg) for arg in args]
  contours = simple_interface.load_contours(filenames, show_progress = options.show_progress)
  if options.endpoints is None:
    endpoints = options.endpoint_method
  else:
    endpoints = options.endpoints
  contours = simple_interface.find_centerlines(contours, options.axis_points, endpoints, options.show_progress)
  destination = path.path(options.destination)
  if not destination.exists():
    destination.makedirs()
  # note that with path objects, the '/' operator means 'join path components.'
  names = [destination / filename.name for filename in filenames]
  simple_interface.save_contours(contours, names, options.show_progress)
Ejemplo n.º 12
0
def main(name, arguments):
    parser.prog = name
    options, args = parser.parse_args(arguments)
    args = cli_tools.glob_args(args)
    if len(args) == 0:
        raise ValueError('Some contour files must be specified!')
    filenames = [path.path(arg) for arg in args]
    contours = simple_interface.load_contours(filenames, show_progress = options.show_progress)
    if options.reference is not None:
        reference = contour_class.from_file(options.reference)
        contours = simple_interface.align_contours_to(contours, reference, align_steps=options.alignment_steps,
            allow_reflection=options.allow_reflection, show_progress=options.show_progress)
    else:
        contours = simple_interface.align_contours(contours, options.alignment_steps, options.allow_reflection,
            max_iters=options.max_iterations, show_progress = options.show_progress)
    destination = path.path(options.destination)
    destination.makedirs_p()
    # note that with path objects, the '/' operator means 'join path components.'
    names = [destination / filename.name for filename in filenames]
    simple_interface.save_contours(contours, names, options.show_progress)
Ejemplo n.º 13
0
def main(name, arguments):
    parser.prog = name
    options, args = parser.parse_args(arguments)
    args = cli_tools.glob_args(args)
    if len(args) == 0:
        raise ValueError('Some contour and image files must be specified!')
    intensity_ranges = []
    for r in options.intensity_ranges:
        try:
            low, high = r
        except:
            low = high = r
        intensity_ranges.append([low, high])
    if options.weights is None or len(options.weights) == 0:
        options.weights = [0.5]
    elif len(options.weights) != 1 and len(
            options.weights) != len(intensity_ranges):
        raise optparse.OptionValueError(
            "Either one or %d weights are required; %d sepcified." %
            (len(intensity_ranges), len(options.weights)))
    elif sum(options.weights) > 1:
        raise optparse.OptionValueError("The sum of the weights must be <= 1.")

    matches = match_files.match_contours_and_images(args,
                                                    options.match_by_name,
                                                    options.show_progress)
    contours, image_names, unmatched_contours, unmatched_image_names = matches
    filenames = [path.path(contour._filename) for contour in contours]
    contours = simple_interface.add_image_landmarks_to_contours(
        contours, image_names, intensity_ranges, options.weights,
        options.image_type, options.show_progress)
    destination = path.path(options.destination)
    if not destination.exists():
        destination.makedirs()
    # note that with path objects, the '/' operator means 'join path components.'
    names = [destination / filename.name for filename in filenames]
    simple_interface.save_contours(contours, names, options.show_progress)
Ejemplo n.º 14
0
def main(name, arguments):
    parser.prog = name
    options, args = parser.parse_args(arguments)
    args = cli_tools.glob_args(args)
    if len(args) == 0:
        raise ValueError('Some contour files must be specified!')
    filenames = [path.path(arg) for arg in args]
    contours = simple_interface.load_contours(
        filenames, show_progress=options.show_progress)
    if options.first_point is not None:
        options.first_point -= 1
    if options.scale is not None or options.rotate is not None or options.units is not None or options.first_point is not None:
        in_radians = False
        if options.units is not None and options.units.lower() in ('um',
                                                                   'micron',
                                                                   'microns'):
            options.units = u'\N{MICRO SIGN}m'
        contours = simple_interface.transform_contours(
            contours,
            options.scale,
            options.rotate,
            in_radians,
            options.units,
            options.first_point,
            options.show_progress,
            title='Modifying Contours')
    if options.weights is not None:
        contours = simple_interface.reweight_landmarks(contours,
                                                       options.weights,
                                                       options.show_progress)

    destination = path.path(options.destination)
    if not destination.exists():
        destination.makedirs()
    # note that with path objects, the '/' operator means 'join path components.'
    names = [destination / filename.name for filename in filenames]
    simple_interface.save_contours(contours, names, options.show_progress)
Ejemplo n.º 15
0
def main(name, arguments):
    parser.prog = name
    options, args = parser.parse_args(arguments)
    args = cli_tools.glob_args(args)
    if len(args) == 0:
        raise ValueError('Some image files must be specified!')
    filenames = [path.path(arg) for arg in args]
    contours_groups = simple_interface.extract_contours(filenames, options.contour_value, 
        options.min_area, options.max_area, options.show_progress)
    contours = []
    names = []
    destination = path.path(options.destination)
    destination.makedirs_p()
    for contour_group, image_name in zip(contours_groups, filenames):
        num_contours = len(contour_group)
        if num_contours == 1:
            contours.append(contour_group[0])
            # note that with path objects, the '/' operator means 'join path components.'
            names.append(destination / image_name.namebase + '.contour')
            contour_group[0]._filename = image_name.namebase
        else:
            width = len(str(num_contours))
            for i, contour in enumerate(contour_group):
                contours.append(contour)
                names.append(destination / image_name.namebase + '-%.*d.contour'%(width, i+1))
                contour._filename = image_name.namebase + '-%.*d'%(width, i+1)
    if options.scale is not None:
        # if not rescaling, contours are already denominated in pixels, so do nothing.
        units = options.units
        if units.lower() in ('um', 'micron', 'microns'):
            units = '\N{MICRO SIGN}m'
        contours = simple_interface.transform_contours(contours, scale_factor=options.scale, 
            units=units, show_progress=options.show_progress, title='Rescaling Contours')
    if options.resample:
        contours = simple_interface.resample_contours(contours, options.resample_points, options.smoothing_factor, options.show_progress)
    simple_interface.save_contours(contours, names, options.show_progress)
Ejemplo n.º 16
0
def main(name, arguments):
    parser.prog = name
    options, args = parser.parse_args(arguments)
    args = cli_tools.glob_args(args)
    if len(args) == 0:
        raise ValueError('Some contour and image files must be specified!')
    matches = match_files.match_contours_and_images(args, options.match_by_name, options.show_progress)
    contours, image_names, unmatched_contours, unmatched_image_names = matches
    destination = path.path(options.destination)
    destination.makedirs_p()
    if options.file_type is not None:
        new_names = [destination / contour.simple_name() + '.' + options.file_type for contour in contours]
    else:
        new_names = [destination / contour.simple_name() + image.ext for image, contour in zip(image_names, contours)]
    simple_interface.reorient_images(contours, image_names, new_names, pad_factor=options.pad_factor, 
        mask=options.mask_background, show_progress=options.show_progress)
Ejemplo n.º 17
0
def _get_contours_and_images(filenames, show_progress = True):
    contours = []
    image_names = []
    if show_progress:
        filenames = terminal_tools.progress_list(filenames, 'Loading Contours and Images')
    for filename in filenames:
        filename = path.path(filename)
        if not filename.exists():
            raise ValueError('File "%s" does not exist.'%filename)
        try:
            freeimage.read_metadata(filename)
            image_names.append(filename)
        except IOError as e:
            # print e
            # print Image.ID
            try:
                contours.append(contour_class.from_file(filename))
            except IOError as e:
                # print e
                raise ValueError('Could not open file "%s" as an image or a contour.'%filename)
    return contours, image_names
Ejemplo n.º 18
0
def _get_contours_and_images(filenames, show_progress=True):
    contours = []
    image_names = []
    if show_progress:
        filenames = terminal_tools.progress_list(
            filenames, 'Loading Contours and Images')
    for filename in filenames:
        filename = path.path(filename)
        if not filename.exists():
            raise ValueError('File "%s" does not exist.' % filename)
        try:
            Image.open(filename)
            image_names.append(filename)
        except IOError, e:
            # print e
            # print Image.ID
            try:
                contours.append(contour_class.from_file(filename))
            except IOError, e:
                # print e
                raise ValueError(
                    'Could not open file "%s" as an image or a contour.' %
                    filename)
subfont = 12
supfont = 16

xo = numpy.arange(0,240,0.3)
x = numpy.arange(0,241,30)
xti = numpy.arange(0,241,30)

#t = 0.2855
#bins = numpy.arange(0,29.95,t)
brain_regions = ['Lo2','Lo4']

color = ['#9900cc','#00cc66','#808080'] 

parent_dir = 'C:/Users/vymak_i7/Desktop/New_ER/Screen/Tm3/gratings/lobula/'
parent_path = path('C:/Users/vymak_i7/Desktop/New_ER/Screen/Tm3/gratings/lobula/')
header,rows = datafile.DataFile(parent_path/'directories.csv').get_header_and_data()
parent_mdir = parent_dir+'/measurements/'

dir_list = [parent_dir+'/'+row[1] for row in rows]
path_list = [parent_path/row[1] for row in rows]


for br in brain_regions[:]:
    
    out = []
    out2 = []

    #import gratings ER and RGECO data and separate headers and rows from each dataset
    header,rows = datafile.DataFile(parent_mdir+'all_responses-'+br+'-ER210.csv').get_header_and_data()
    out = numpy.asarray(rows)
ytmaxer = 0.61
ytier = 0.2

T = numpy.arange(0,5,t)

header_out = ['sample','br','ROI','x','y','epoch']
header_out.extend(list(T))
#print header_out

indices = [[0,50],[50,100],[100,150],[150,200]]
ENUM=[1,2,3,4]
colors = ['#8F02C5','#02C54F','#0F37FF','#F8A51B'] #purple, green, blue, orange
brain_regions = ['M1','M5','M9-M10']

parent_dir = 'C:/Users/vymak_i7/Desktop/New_ER/Screen/Mi1/moving_light_bars/'
parent_path = path('C:/Users/vymak_i7/Desktop/New_ER/Screen/Mi1/moving_light_bars/')
mdir = parent_dir+'/measurements/10s/'
header,rows = datafile.DataFile(parent_path/'10s_directories.csv').get_header_and_data()

dir_list = [parent_dir+'/'+row[1] for row in rows]
path_list = [parent_path/row[1] for row in rows]


for br in brain_regions:
    
    OUT_DFF=[] #RGECO

    for directory,p,row in zip(dir_list[:],path_list[:],rows):
        
        print(directory)
        if not os.path.exists(directory+'/plots/time'):
Ejemplo n.º 21
0
import numpy
from celltool.utility.path import path
import celltool.utility.datafile as datafile
import matplotlib.image as mpimg
from PIL import Image
import glob
import os

t = 0.1
bins = numpy.arange(0, 4, t)
"""Sets up some paths..."""
parent_dir = 'C:/Users/vymak_i7/Desktop/New_ER/Screen/Tm3/flashes/lobula/'
parent_path = path(
    'C:/Users/vymak_i7/Desktop/New_ER/Screen/Tm3/flashes/lobula/')
"""I'll explain this in person, ignore through line 54."""
header, rows = datafile.DataFile(parent_path /
                                 'directories.csv').get_header_and_data()

dir_list = [parent_dir + '/' + row[1] for row in rows]
path_list = [parent_path / row[1] for row in rows]

for directory, p in zip(dir_list[:], path_list[:]):

    print(directory)

    plot_dir = directory + '/plots/'
    print(plot_dir)

    image_dir1 = directory + '/RGECO'
    print(image_dir1)
    """This IDs and sorts image file names for one channel."""
Ejemplo n.º 22
0
        d.name for d in directory.dirs() if (d / '__init__.py').exists()
    ]
    return plugins


def _monkeypatch_command(plugin_mod, plugin_name):
    import celltool.command_line.celltool_commands
    celltool.command_line.celltool_commands.celltool_commands.append(
        plugin_name)
    setattr(celltool.command_line, plugin_name, plugin_mod)
    sys.modules['celltool.command_line.' + plugin_name] = plugin_mod


py2exe_plugins = None
if hasattr(sys, "frozen") and sys.frozen == 'console_exe':
    py2exe_plugins = path.path(sys.executable).parent.abspath() / 'Plugins'
    _plugins = find_plugins(py2exe_plugins)
    sys.path.append(py2exe_plugins)
else:
    _plugins = find_plugins(path.path(__file__).parent)

celltool_plugins = None
try:
    celltool_plugins = os.environ['CELLTOOL_PLUGINS']
    _plugins += find_plugins(path.path(celltool_plugins))
    sys.path.append(celltool_plugins)
except:
    pass

for plugin in _plugins:
    plugin_mod = __import__(plugin, globals(), locals())
Ejemplo n.º 23
0
import os
from celltool.utility.path import path
import celltool.utility.datafile as datafile

stim='/moving_dark_bar/'

"""Copy filenames from raw image files to analysis folders"""
# directory = 'D:/Image_files/Mi9_strongER210+RGECO/'+stim
# parent_dir = path(directory)

# dirs = sorted(os.listdir(parent_dir))

t_dir = 'C:/Users/vymak_i7/Desktop/New_ER/Screen/Mi9_strong/'+stim
target_dir = path(t_dir)

#1) CREATE FILES FROM IMAGE_FILES TO NEW_ER/SCREEN FOLDERS
# for file in dirs[:]: 
    
#     targetname=file
#     os.mkdir(os.path.join(t_dir,targetname))
    
# # """2) Create directories.csv file"""
target_list = sorted(os.listdir(target_dir))
header = ['fly','directory']
dir_list = []

for file in target_list: 
    i=1
    if 'fly' in file:
        
        
Ejemplo n.º 24
0
import numpy
from celltool.utility.path import path
import celltool.utility.datafile as datafile
import matplotlib.pyplot as plt

threshold = 1

"""Set up path"""
parent_dir = path('C:/Users/vymak_i7/Desktop/New_ER/Screen/Mi9/moving_dark_bar/')

"""Import list of directories"""
header,rows = datafile.DataFile(parent_dir/'directories.csv').get_header_and_data()
dir_list = [parent_dir/row[1] for row in rows]

#new_dl for indexing samples to fix
# new_dl = []
# indexes=[13,18]
# for i in indexes: 
#     new_dl.append(dir_list[i])

"""Read stimulus file, count imaging frames, and save output stimulus file for all directories"""
for directory in dir_list[:]: #change list to dir_list or new_dl
    
    print(directory)
    
    """Import original stimulus file to a numpy array; you'll have to change the name of the file for your particular stimulus"""
    stim_file = directory.files('moving*.csv')[0]
    header,rows = datafile.DataFile(stim_file).get_header_and_data()
    R = numpy.asarray(rows)
    
    """Set up the output array (just adds another column to the original stimulus array."""
Ejemplo n.º 25
0
ytmax = 0.61
yti = 0.2

T = numpy.arange(0, 20, t)  #(0,5,t) for flashes; (0,31,t) for gratings

header_out = ['sample', 'brain_region', 'ROI', 'x', 'y', 'epoch']
header_out.extend(list(T))
#print header_out

color = '#02C54F'
alphas = [1, 0.6]
brain_regions = ['M1', 'M5', 'M9-M10']

parent_dir = 'C:/Users/vymak_i7/Desktop/New_ER/Screen/Mi1/10s_flashes/'
parent_m_dir = parent_dir + '/measurements/'
parent_path = path('C:/Users/vymak_i7/Desktop/New_ER/Screen/Mi1/10s_flashes/')
header, rows = datafile.DataFile(parent_path /
                                 'directories.csv').get_header_and_data()

dir_list = [parent_dir + '/' + row[1] for row in rows]
path_list = [parent_path / row[1] for row in rows]

for br in brain_regions[:]:
    O_DFF = []
    for directory, p, row in zip(dir_list[:], path_list[:], rows[:]):
        OUT_DFF = []
        print(directory)

        image_dir = directory + '/binned_images-ER210'
        plot_dir = directory + '/plots/'
        m_dir = directory + '/measurements/'
Ejemplo n.º 26
0
    if not directory.exists():
        return []
    plugin_files = [p.namebase for p in directory.files('*.py')]
    plugins = [p for p in plugin_files if p not in ('__init__', 'setup')]
    plugins += [d.name for d in directory.dirs() if (d / '__init__.py').exists()]
    return plugins
    
def _monkeypatch_command(plugin_mod, plugin_name):
    import celltool.command_line.celltool_commands
    celltool.command_line.celltool_commands.celltool_commands.append(plugin_name)
    setattr(celltool.command_line, plugin_name, plugin_mod)
    sys.modules['celltool.command_line.'+plugin_name] = plugin_mod

py2exe_plugins = None
if    hasattr(sys,"frozen") and sys.frozen == 'console_exe':
    py2exe_plugins = path.path(sys.executable).parent.abspath() / 'Plugins'
    _plugins = find_plugins(py2exe_plugins)
    sys.path.append(py2exe_plugins)
else:
    _plugins = find_plugins(path.path(__file__).parent)

celltool_plugins = None
try:
    celltool_plugins = os.environ['CELLTOOL_PLUGINS']
    _plugins += find_plugins(path.path(celltool_plugins))
    sys.path.append(celltool_plugins)
except:
    pass

for plugin in _plugins:
    plugin_mod = __import__(plugin, globals(), locals())
Ejemplo n.º 27
0
import os
import shutil
from celltool.utility.path import path
import celltool.utility.datafile as datafile

stim = '10s_flashes'
"""Set up path"""
directory = 'C:/Users/vymak_i7/Desktop/New_ER/Screen/Tm3/medulla/' + stim
parent_dir = path(directory)
directories = os.listdir(parent_dir)

t_dir = 'C:/Users/vymak_i7/Desktop/New_ER/Screen/Tm3/medulla/google_drive/'
target_dir = path(t_dir)
dirs = os.listdir(target_dir)

header, rows = datafile.DataFile(parent_dir /
                                 'directories.csv').get_header_and_data()

path_list = [parent_dir / row[1] for row in rows]

##0) to rename files (optional)
# for row in directories[1:19]:

#     prev=os.path.join(directory+row,'mask-M3-M4.tif')
#     new = os.path.join(directory+row,'mask-M2-M5.tif')
#     os.rename(prev,new)

# 1) CREATE DIRECTORIES FOR GOOGLE DRIVE FOLDER
# i=1
# for row in rows[:]: