In the matlabScripts directory, @sripada has put a number of handy tools for generating paths from "templates" (which are sort of formulas for concatenation of variables and constants). However, it currently has to be called in an eval statement, which is kind of awkward, so we should rewrite this so that calls like this
curRunDirectory = GenPath(SubjDirTemplate)
will work. SubjDirTemplate might look like '[Exp]/[curSubjDir]/TASK/func/[curRunDir]'
It presumes that the variables Exp, curSubjDir, and curRunDir exist. Here is some sample content
Exp = '/net/data4/MAS'
curSubjDir = '5004'
curRunDir = 'run_01'
With all this in place, the assignment should work, and we'll get
curRunDirectory with a value of '/net/data4/MAS/5004/TASK/func/run_01'
GenPath would need to
- Parse the template
- Generate a concatenation/assignment command
- Evaluate it in the parent environment (otherwise we'd need to pass it Exp and curSubjDir). This should be easy enough with evalin
There are some other options we've discussed adding, like
- Checkpath - Check whether the path generated exists, and if not, return a friendly error message with the failed path
- Makepath - Recursively create any directories necessary for this path to exist. Potentially messy if somebody screws up their template
Standards
I think @mangstad, @sripada, and I came up with some standards for how to prefix variables that will change within loops (e.g. SubjDir would be the cell array holding all the subject directories, curSubjDir would be the current value in the loop), but I don't remember them. Care to chip in guys?
In the matlabScripts directory, @sripada has put a number of handy tools for generating paths from "templates" (which are sort of formulas for concatenation of variables and constants). However, it currently has to be called in an eval statement, which is kind of awkward, so we should rewrite this so that calls like this
will work. SubjDirTemplate might look like
'[Exp]/[curSubjDir]/TASK/func/[curRunDir]'It presumes that the variables
Exp,curSubjDir, andcurRunDirexist. Here is some sample contentWith all this in place, the assignment should work, and we'll get
curRunDirectorywith a value of'/net/data4/MAS/5004/TASK/func/run_01'GenPath would need to
There are some other options we've discussed adding, like
Standards
I think @mangstad, @sripada, and I came up with some standards for how to prefix variables that will change within loops (e.g. SubjDir would be the cell array holding all the subject directories, curSubjDir would be the current value in the loop), but I don't remember them. Care to chip in guys?