Esempio n. 1
0
    asig.name += ""
    asig.description += "Deconvoluted activity using the given {} kernel"\
                        .format(args.kernel)
    block.segments[0].analogsignals[0] = asig
    """
    # New method, creating a new block
    # create an ImageSequence with the deconvoluted matrix
    imgseq_deconv = neo.ImageSequence(
        activities,
        units=block.segments[0].analogsignals[0].units,
        sampling_rate=block.segments[0].analogsignals[0].sampling_rate,
        spatial_scale=block.segments[0].imagesequences[0].spatial_scale,
        name=block.segments[0].analogsignals[0].name,
        description=block.segments[0].analogsignals[0].description)

    # create a new Block & Segment and append the ImageSequence
    segm_deconv = neo.Segment()
    segm_deconv.annotations = block.segments[0].annotations
    segm_deconv.annotate(kernel=args.kernel)  #ToDo: parameters annotations
    segm_deconv.imagesequences.append(imgseq_deconv)
    block_deconv = neo.Block()
    block_deconv.segments.append(segm_deconv)
    block_deconv.name = block.name
    block_deconv.description = block.description
    block_deconv.annotations = block.annotations

    # converting into analogsignal
    block_deconv = ImageSequence2AnalogSignal(block_deconv)

    write_neo(args.output, block_deconv)
Esempio n. 2
0
    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)
            save_plot(args.output_img)

    new_asig = asig.duplicate_with_new_data(signal)
    new_asig.array_annotations = asig.array_annotations
    new_asig.name += ""
    new_asig.description += "The mean of each channel was subtracted ({})."\
                        .format(os.path.basename(__file__))
    block.segments[0].analogsignals[0] = new_asig

    write_neo(args.output, block)
Esempio n. 3
0
    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:
            if event.name not in event_names:
                waves_block.segments[0].events.append(event)

        del block

    write_neo(args.output, waves_block)