Skip to content
This repository has been archived by the owner on Dec 14, 2017. It is now read-only.

Utilities

ASOBOLEV edited this page Feb 28, 2014 · 3 revisions

Support: Email || Guides: Installation | Getting started || Reference: General | Retrieval | Upload | Utilities

In addition to core upload and download methods, the G-Node MATLAB toolbox comes with utility and auxiliary functions that facilitate working with the G-Node data store. All examples presuppose a running session g which can be initiated using the following script:

import gnode.*;
set_up_classpath();

g = init('default');

Search

find_simple(objects, field, search_term)

Combs through objects and returns all objects containing the search terms in the specified field. This utility operates case-insensitively.

objects = get_range(g, 'analogsignal', 1000, 1236);

matching_objects = find_simple(objects, 'name', '[...]');

now returns all objects matching the specified terms in the name field.


find_regex(objects, field, regex)

Combs through objects and returns all objects matching the regular expression in the specified field. This utility operates case-insensitively.

objects = get_range(g, 'analogsignal', 1000, 1236);

matching_objects = find_regex(objects, 'name', '[...]');

now returns all objects matching the specified regex in the name field.

Generating objects

make_dummy(session, object_type, minimal)

Returns a "readymade" structure for creating new objects with all available (valid) fields added but left blank. Key purpose is rapid creation of G-Node data store objects by MATLAB users.

dummy = make_dummy(g, 'analogsignal');

returns a structure containing empty fields for all signal-related properties that are required by the G-Node validator.


from_prototype(session, prototype, field, content, make_signal, units)

Creates a series of objects from a content array and a prototype (generally created via make_dummy). That is, for each cell in the specified content array, this function creates a copy of the prototype and adds the content cell to the specified field of this copy. If dealing with signal data, a Boolean flag can be specified that coerces the function into creating signal structs with an appropriate specified unit.

new_objects = from_prototype(g, dummy, 'name', name_cell_array);

creates an array of objects whose 'name' fields correspond to the passed name array.

new_objects = from_prototype(g, dummy, 'signal', raw_data, true, 'mV');

creates an array of signals including properly structured data fields with unit 'mV'.


validate(session, obj, object_type, strict)

Performs object validation based on currently loaded object contract for the G-Node data store. NB, successful client-side validation does not guarantee successful server-side validation. Object type is guessed where possible; explicit specification should be used wherever feasible.

Two validation types can be toggled: Negative, or permissive, validation only checks if all required fields are present. Positive, or strict, validation checks whether only admissible fields are present. If validation fails, the procedure attempts to deliver information about missing fields (where available).

validate(g, my_object)

returns true iff object type can be guessed and all required fields are present.

validate(g, my_object, 'segment')

returns true iff all required fields are present.

validate(g, my_object, 'segment', true);

returns true iff all and only admissible fields are members of the G-Node data store object.


connect(session, obj1, obj2, flag_remote)

Connects two NEObjects by setting their respective relation fields to each other's NEO ID. This requires knowledge of

  1. their IDs and by extension
  2. their types.

If this information is not given, the procedure throws an error.

Modification is never in place; new objects are returned. If 'true' is passed as the final argument, connect() performs the intended change remotely. This helper checks if the given objects can be connected according to G-Node data object semantics of current session.

[obj1 obj2] = connect(g, block, segment)

connects a block and a segment without deploying the change on the server.

[obj1 obj2] = connect(g, block, segment, true)

performs the same change as above, and immediately adds the connection remotely.

Support: Email || Guides: Installation | Getting started || Reference: General | Retrieval | Upload | Utilities