How to change default save directory

Hi Travis,

The current MWorks nightly build includes several new features that, while different from what I initially envisioned, should enable the sort of data-file management you want. Here’s what’s new:

  1. Data files can now be created at fully arbitrary paths.

    If the name of a data file includes no path component or only a relative path (i.e. there’s no leading /), then the file is created relative to the standard data-file directory. (This is how things worked before.) If the filename includes an absolute path (i.e. it begins with /), then the standard path is not prepended, and the file is created in exactly the location specified. (This is new.)

    Hence, if you want to put your data files in /Volume/my_data/my_exp, then just preface the filename with that path when opening the file in MWClient (or when defining a data file device, described below).

  2. MWorks experiments can now include a data file device.

    The details are in the user manual, but the upshot is that by including a data file device in your experiment, a data file will automatically open each time the experiment is started. The filename is evaluated just before the file is created, so it can make use of variable and/or expression interpolation (also new in the current nightly) to produce a unique file name and path for each run.

  3. MWorks’ expression parser now includes a date function, which returns a date/time string in a user-specified format.

    This is very handy for including a date/time stamp in your data file names.

While there’s a lot of new functionality here, the usage is pretty simple. If you want to create a new data file for each run of an experiment, on a particular volume, organized by subject and protocol, with a time stamp, you can do so by including a single line in your experiment file, something like:

data_file ("/Volumes/exp_data/travis/$subject/$protocol/$(date('%Y%m%d-%H%M%S'))")

where subject and protocol are variables in your experiment. Equivalently, in XML:

<iodevice type="data_file" filename="/Volumes/exp_data/travis/$subject/$protocol/$(date('%Y%m%d-%H%M%S'))" />

Doing so gives you full control over how your data files are named and where they’re stored, and also eliminates the need for whoever’s running the experiment to manually open a data file at the start of each run.

Hopefully, these changes will meet your needs. If you have any questions or other feedback, please let me know!

Cheers,
Chris