How to change default save directory

Hi Chris,

This seems simple but I can’t seem to find it in the documentation, forum, or just twiddling around in the variables. Here’s the situation, we’re going to setup 4 mworks stations, that will be run in the morning and afternoon on seperate animals (8 in total). What control do we have to set the default save directory? Can I input the save directory in the variables (that would be really nice), or if I set the save directory manually, will it keep that as the new default save directory? Also, when I went to change the directory, it was just a blank bar, so do I have to copy over the entire path?

Thanks!

Travis

Hi Chris,

I’ve been tinkering, and here’s an update:

  1. I was able to move to the cloud directory with …/'s, so I have …/…/…/Box/Data etc.
  2. I’ve learned that Mworks will save this as the new default after I close and reopen the program.
  3. One thing it does not do is automatically provide a filename if I only point it to a directory. Is there anyway to institute this? In other words if I point the Save to …/…/…/Box/Data/Rig_1/ I’d like it to automatically create a new filename everytime it is saved, to avoid human error in typing a new filename for each animal, for each session. I’m trying to get this as user friendly for our Techs as possible :slight_smile:

Hi Travis,

What control do we have to set the default save directory?

You have no control. It’s always $HOME/Documents/MWorks/Data, where $HOME is the home directory of the user running MWServer.

However, you can save in to subdirectories of Documents/MWorks/Data, by starting the name of the data file with a relative path. For example, setting the name of the data file to Rig_1/Monkey_1/Run_1 will result in events being saved to $HOME/Documents/MWorks/Data/Rig_1/Monkey_1/Run_1.mwk.

I was able to move to the cloud directory with …/'s, so I have …/…/…/Box/Data etc.

If that works, it’s only by accident. The intent is for everything to go in Documents/MWorks/Data.

I’ve learned that Mworks will save this as the new default after I close and reopen the program.

It will persist after closing and reopening an experiment. However, if you quit and restart MWClient, it will be forgotten.

One thing it does not do is automatically provide a filename if I only point it to a directory. Is there anyway to institute this?

That isn’t supported at present. However, in MWClient’s preferences, if you check “Automatically open data file when experiment starts”, then the client will automatically create a data file for you. The name has the format username-experiment-date-time, e.g.

cstawarz-my_experiment-20190329-094836.mwk

All that said, what you want to do is certainly very reasonable, and we ought to support it. I suggest two changes:

  1. Add a preference to MWServer that lets you set the data file directory.

    It needs to be a server preference, because data files are stored server side. If unspecified, it would default to the current location. We might even make this configurable on a per-experiment basis.

  2. Extend MWClient’s automatic data file creation to include a user-specified filename template. That template could include the names of experiment variables, e.g.

     ${animal}/${protocol_name}/trial_${trial_number}
    

Does that sound like it would meet your needs?

Cheers,
Chris

Hi Chris,

Thanks for the info! Yes your suggested changes would accomodate exactly
what we’re trying to do!

Travis

Hi Chris,

Has this functionality been added to the Nightly?

Hi Travis,

At the moment, I’m finishing up the next release of MWorks (version 0.9), which I hope to get out by the end of this month. I won’t be starting work on these changes until after the release is done. Assuming the release goes smoothly and stays more or less on schedule, the earliest I’ll get to this is likely sometime in May.

Cheers,
Chris

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