Exemplo n.º 1
0
    return ax

if __name__ == '__main__':
    CLI = argparse.ArgumentParser(description=__doc__,
                   formatter_class=argparse.RawDescriptionHelpFormatter)
    CLI.add_argument("--data",    nargs='?', type=str, required=True,
                     help="path to input data in neo format")
    CLI.add_argument("--output",  nargs='?', type=str, required=True,
                     help="path of output file")
    CLI.add_argument("--output_img",  nargs='?', type=none_or_str,
                     help="path of output image", default=None)
    CLI.add_argument("--output_array",  nargs='?', type=none_or_str,
                      help="path of output numpy array", default=None)
    args = CLI.parse_args()

    block = load_neo(args.data)
    asig = block.segments[0].analogsignals[0]
    signal = asig.as_array()
    background = np.nanmean(signal, axis=0)
    signal -= background

    if args.output_img or args.output_array is not None:
        coords = np.array([(x,y) for x,y in
                           zip(asig.array_annotations['x_coords'],
                               asig.array_annotations['y_coords'])],
                          dtype=int)
        frame = shape_frame(background, coords)
        if args.output_array is not None:
            np.save(args.output_array, frame)
        if args.output_img is not None:
            plot_frame(frame)
Exemplo n.º 2
0
                     type=float,
                     default=0,
                     help="start time in seconds")
    CLI.add_argument("--t_stop",
                     nargs='?',
                     type=float,
                     default=10,
                     help="stop time in seconds")
    CLI.add_argument("--channel",
                     nargs='?',
                     type=int,
                     default=0,
                     help="channel to plot")
    args = CLI.parse_args()

    orig_asig = load_neo(args.original_data, 'analogsignal', lazy=True)
    orig_asig = time_slice(orig_asig,
                           t_start=args.t_start,
                           t_stop=args.t_stop,
                           lazy=True,
                           channel_indexes=args.channel)

    proc_asig = load_neo(args.processed_data, 'analogsignal', lazy=True)
    proc_asig = time_slice(proc_asig,
                           t_start=args.t_start,
                           t_stop=args.t_stop,
                           lazy=True,
                           channel_indexes=args.channel)

    plot_traces(orig_asig, proc_asig, args.channel)
Exemplo n.º 3
0
                     default=None,
                     help="metadata of the dataset")
    CLI.add_argument("--array_annotations",
                     nargs='+',
                     type=none_or_str,
                     default=None,
                     help="channel-wise metadata")
    CLI.add_argument("--kwargs",
                     nargs='+',
                     type=none_or_str,
                     default=None,
                     help="additional optional arguments")
    args = CLI.parse_args()

    try:
        block = load_neo(args.data, try_signal_grouping=True)
    except Exception as e:
        print(e)
        block = load_neo(args.data, try_signal_grouping=True)

    asigs = block.segments[0].analogsignals

    if len(asigs) > 1:
        print(f'Merging {len(asigs)} AnalogSignals into one.')
        asig = merge_analogsingals(asigs)
    else:
        asig = asigs[0]

    asig = time_slice(asig, args.t_start, args.t_stop)

    # add metadata
Exemplo n.º 4
0

if __name__ == '__main__':
    CLI = argparse.ArgumentParser()
    CLI.add_argument("--data", nargs='?', type=str)
    CLI.add_argument("--frame_folder", nargs='?', type=str)
    CLI.add_argument("--frame_name", nargs='?', type=str)
    CLI.add_argument("--frame_format", nargs='?', type=str)
    CLI.add_argument("--frame_rate", nargs='?', type=none_or_float)
    CLI.add_argument("--colormap", nargs='?', type=str)
    CLI.add_argument("--event", nargs='?', type=none_or_str, default=None)
    CLI.add_argument("--markercolor", nargs='?', type=str, default='k')

    args = CLI.parse_args()

    blk = load_neo(args.data)
    blk = AnalogSignal2ImageSequence(blk)

    # get data
    imgseq = blk.segments[0].imagesequences[0]
    times = blk.segments[0].analogsignals[0].times  # to be replaced
    t_start = blk.segments[0].analogsignals[0].t_start  # to be replaced
    t_stop = blk.segments[0].analogsignals[0].t_stop  # to be replaced
    dim_t, dim_x, dim_y = imgseq.shape

    optical_flow = get_opticalflow(blk.segments[0].imagesequences)

    if args.event is not None:
        up_coords = get_events(blk.segments[0].events,
                               frame_times=times,
                               event_name=args.event)
                     help="lower bound of frequency band in Hz")
    CLI.add_argument("--lowpass_freq",
                     nargs='?',
                     type=none_or_float,
                     default='None',
                     help="upper bound of frequency band in Hz")
    CLI.add_argument("--psd_freq_res",
                     nargs='?',
                     type=float,
                     default=5,
                     help="frequency resolution of the power spectrum in Hz")
    CLI.add_argument("--psd_overlap",
                     nargs='?',
                     type=float,
                     default=0.5,
                     help="overlap parameter for Welch's algorithm [0-1]")
    args = CLI.parse_args()

    asig = load_neo(args.data, 'analogsignal')

    freqs, psd = welch_psd(asig,
                           freq_res=args.psd_freq_res * pq.Hz,
                           overlap=args.psd_overlap)

    plot_psd(freqs=freqs,
             psd=psd,
             highpass_freq=args.highpass_freq,
             lowpass_freq=args.lowpass_freq)

    save_plot(args.output)
Exemplo n.º 6
0
import neo
from utils import load_neo, write_neo, AnalogSignal2ImageSequence


if __name__ == '__main__':
    CLI = argparse.ArgumentParser(description=__doc__,
                   formatter_class=argparse.RawDescriptionHelpFormatter)
    CLI.add_argument("--waves", nargs='?', type=str, required=True,
                     help="path to input data in neo format")
    CLI.add_argument("--properties", nargs='?', type=lambda v: v.split(','), default=None,
                     help="paths to input data in neo format")
    CLI.add_argument("--output", nargs='?', type=str, required=True,
                     help="path of output file")

    args = CLI.parse_args()
    waves_block = load_neo(args.waves)

    asig_names = [asig.name for asig in waves_block.segments[0].analogsignals]
    event_names = [event.name for event in waves_block.segments[0].events]

    if args.properties is None:
        args.properties = []

    for property in args.properties:
        block = load_neo(property)

        for asig in block.segments[0].analogsignals:
            if asig.name not in asig_names:
                waves_block.segments[0].analogsignals.append(asig)

        for event in block.segments[0].events:
                     type=str,
                     required=True,
                     help="path to input data in neo format")
    CLI.add_argument("--node_data",
                     nargs='?',
                     type=str,
                     required=True,
                     help="path to input data in neo format")
    CLI.add_argument("--output",
                     nargs='?',
                     type=str,
                     required=True,
                     help="path of output file")

    args = CLI.parse_args()
    trigger_block = load_neo(args.trigger_data)
    node_block = load_neo(args.node_data)

    block = AnalogSignal2ImageSequence(node_block)

    wavefront_evt = [
        evt for evt in trigger_block.segments[0].events
        if evt.name == "Wavefronts"
    ]
    if wavefront_evt:
        wavefront_evt = wavefront_evt[0]
    else:
        raise ValueError("Input does not contain an event with name " \
                       + "'Wavefronts'!")

    block.segments[0].events.append(wavefront_evt)
Exemplo n.º 8
0
    CLI.add_argument("--t_start",
                     nargs='?',
                     type=float,
                     default=0,
                     help="start time in seconds")
    CLI.add_argument("--t_stop",
                     nargs='?',
                     type=float,
                     default=10,
                     help="stop time in seconds")
    CLI.add_argument("--channels",
                     nargs='+',
                     type=none_or_int,
                     default=0,
                     help="list of channels to plot")
    args = CLI.parse_args()

    asig = load_neo(args.data, 'analogsignal', lazy=True)

    channels = parse_plot_channels(args.channels, args.data)

    asig = time_slice(asig,
                      t_start=args.t_start,
                      t_stop=args.t_stop,
                      lazy=True,
                      channel_indexes=channels)

    fig = plot_traces(asig, channels)

    save_plot(args.output)