Skip to content

Collect Custom Data

Jack Brookes edited this page Sep 2, 2021 · 9 revisions

DIY data collection

In general this is not necessary, most of the time the data you need to output should be stored in the trial.result object, or captured with a tracker component. However, in some cases you may need to save data associated with a session or a trial. For example, data from a survey, or any other form of data collection.

You can use the the Save* methods for your Session or Trial. These methods automatically handle the data, and store it in an appropriate location. In the case of trial-level data, using trial.Save* methods, a reference to the output data location will also be saved in the trial_results data output.

For example, storing the text abcdefg to a file called my_text for the current trial:

session.CurrentTrial.SaveText("abcdefg", "my_text");

And for the current session:

session.SaveText("abcdefg", "my_text");

The methods you can use on Session or Trial are:

  • trial/session.SaveText(string, "my_text")
  • trial/session.SaveDataTable(UXFDataTable, "my_data_table") (To do this you will need to construct your own UXFDataTable object - see here.
  • trial/session.HandleJSONSerializableObject(List<object>, "my_json_like_object") (Saves a list of dictionaries, string, float, int, or bool)
  • trial/session.HandleJSONSerializableObject(Dictionary<string, object>, "my_json_like_object") (Saves a list of dictionaries with string keys, and string, float, int, or bool values)
  • trial/session.SaveDataTable(byte[], "my_bytes.wav") (Saves some raw bytes, I use this for recording microphone data as a WAV file).

๐Ÿง  Core topics

โ“ More help


๐Ÿ‘ฉโ€๐Ÿ’ป Programming reference

Unit tests

Clone this wiki locally