-
Notifications
You must be signed in to change notification settings - Fork 0
file.m
tools.file
is responsible for file-path management and maintaining the inputs and outputs of ViNERS in a SPARC data structure.
tools.file
is part of package +tools
tools.file
, by itself, returns the path to the installation directory of ViNERS (e.g. C:\Users\Calvin\Documents\MATLAB\ViNERS
).
The basic usage is illustrated by tools.file('~/source/example.json')
, which returns the absolute path to example.json
in the source folder. However, tools.file
is most useful when working within a subjects (or sample or run) folder, which is illustrated with the following syntax:
tools.file('set','sub-401\sam-1')
sets the active subject to subject 401, sample 1.
tools.file('sub~\axons\axons (1).mat')
get axons file for this subject
The second call to tools.file
above can be shortened to:
tools.file('axons~\axons (1).mat')
get axons file for this subject
tools.file('out~\path\to\object')
looks for the subject/sample/run folder as a subfolder of ~/derivative
instead of ~/primary
.
tools.file
supports a number of other operations:
-
tools.file('list', ...)
list subjects -
tools.file('list', '<~ path>')
list contents of folder -
tools.file('rename','<~ path>')
rename file or folder (not tested recently) -
tools.file('info')
return info about current file/subject and machine/process information -
tools.file('get','<~ path>')
returns a full filepath from a partial filepath (in the example above,tools.file('get','axons~\axons*.mat')
would return the newest axons.mat file in the axons folder of the current subject. -
tools.file('get','<~ path>','next')
returns a full filepath for creating a new file which will not override any other files. -
tools.file('cache')
calls tools.cache -
tools.file('open','<~ path>')
callswinopen
on'<~ path>'
-
tools.file('short','path')
returns the<~ path>
for a given full path, with ViNERS' installation directory replaced with '~' -
tools.file('shorter','path')
returns a shorter<~ path>
for a given full path, withtools.file('sub~')
replaced with'sub~'
Note: tools.file
stores this information in a persistent variable, only reading from disk as needed (reading from +tools/running.json
). As a consequence, the first call to tools.file
(which in good practice is tools.file('set', [subject])
) will usually take a few seconds to complete.