Difference between revisions of "BrainStreamPathsFolders"

From TSG Doc
Jump to navigation Jump to search
(Created page with "<!---Start1---> = Paths and Folders = __TOC__ All files (e.g. functions or figures) and folders that are used in your experiment must be on the Http://www.mathworks.nl/help/...")
 
Line 7: Line 7:
 
== Adding folders to the search path ==
 
== Adding folders to the search path ==
  
At startup, BrainStream adds the BrainStream core folder and nearly all its subfolders to the search path. If you need additional files or folders, you must make sure they are added to the search path. It is possible to specify these folders in the block file under the keys [.DocsSectionsBlockFile#TopicExperiment MatlabPathFnc] or [.DocsSectionsBlockFile#TopicExperiment MatlabPathAdd]. Alternatively, you can use Matlab's <tt>[[Http://www.mathworks.nl/help/techdoc/ref/addpath.htmlAddpath|http://www.mathworks.nl/help/techdoc/ref/addpath.html addpath]]</tt> function to add individual folders. If you want to add a folder with all its subfolders, use addpath in combination with <tt>[[Http://www.mathworks.nl/help/techdoc/ref/genpath.htmlGenpath|http://www.mathworks.nl/help/techdoc/ref/genpath.html genpath]]</tt>:
+
At startup, BrainStream adds the BrainStream core folder and nearly all its subfolders to the search path. If you need additional files or folders, you must make sure they are added to the search path. It is possible to specify these folders in the block file under the keys [[BrainStreamBlockFile#TopicExperiment|MatlabPathFnc]] or [[BrainStreamBlockFile#TopicExperiment|MatlabPathAdd]]. Alternatively, you can use Matlab's <tt>[[Http://www.mathworks.nl/help/techdoc/ref/addpath.htmlAddpath|http://www.mathworks.nl/help/techdoc/ref/addpath.html addpath]]</tt> function to add individual folders. If you want to add a folder with all its subfolders, use addpath in combination with <tt>[[Http://www.mathworks.nl/help/techdoc/ref/genpath.htmlGenpath|http://www.mathworks.nl/help/techdoc/ref/genpath.html genpath]]</tt>:
 
<pre>addpath(pwd);          %adds the current working directory to the search path
 
<pre>addpath(pwd);          %adds the current working directory to the search path
 
addpath(genpath(pwd)); %adds the current working directory and all its subfolders to the search path  
 
addpath(genpath(pwd)); %adds the current working directory and all its subfolders to the search path  
Line 35: Line 35:
 
It is recommended to use relative path names when you specify a folder, whether it is in the blocksettings or in functions like <tt>addpath</tt>. This means that you specify the path name of the folder you want to add relative to a folder of which the location is already known. The advantage of using relative path names is that the proper folders will be added also if you work on a different computer.
 
It is recommended to use relative path names when you specify a folder, whether it is in the blocksettings or in functions like <tt>addpath</tt>. This means that you specify the path name of the folder you want to add relative to a folder of which the location is already known. The advantage of using relative path names is that the proper folders will be added also if you work on a different computer.
  
In BrainStream, you can make use of the <tt>[.DocsSectionsProgrmmersGuide#bs_folder bs_folder]</tt> function. For example, with input argument 'BLOCK', the output of this function is the path to the folder containing the block file of the experiment. If the block file is located in '/Volumes/BCI/my_bci/blockfile', and you want to add a folder which contains your functions and is located in '/Volumes/BCI/my_bci/functions', you can specify this folder like this:
+
In BrainStream, you can make use of the <tt>[[BrainStreamProgrmmersGuide#bs_folder|bs_folder]]</tt> function. For example, with input argument 'BLOCK', the output of this function is the path to the folder containing the block file of the experiment. If the block file is located in '/Volumes/BCI/my_bci/blockfile', and you want to add a folder which contains your functions and is located in '/Volumes/BCI/my_bci/functions', you can specify this folder like this:
 
<pre>functionfolder = fullfile(bs_folder('BLOCK'),..,'functions') % N.B. the '..' expression means going up one level</pre>
 
<pre>functionfolder = fullfile(bs_folder('BLOCK'),..,'functions') % N.B. the '..' expression means going up one level</pre>
  
Line 42: Line 42:
 
== Output folders ==
 
== Output folders ==
  
BrainStream saves output in the folder specified in the [.DocsSectionsBuildingExperiments#SecBlock block file] under topic Files and key [.DocsSectionsBlockFile#KeyOutFolder OutFolder].
+
BrainStream saves output in the folder specified in the [[BrainStreamBuildingExperiments#SecBlock|block file]] under topic Files and key [[BrainStreamBlockFile#KeyOutFolder|OutFolder]].
  
 
The output folder contains:
 
The output folder contains:
Line 60: Line 60:
 
<blockquote>
 
<blockquote>
  
[.DocsSectionsLogFile log file]: gives an overview of everything that happened during your experiment.
+
[[BrainStreamLogFile|log file]]: gives an overview of everything that happened during your experiment.
  
 
brainstream folder: contains copies of the user defined variables that have been saved with a 'save' statement in the Actions table.
 
brainstream folder: contains copies of the user defined variables that have been saved with a 'save' statement in the Actions table.

Revision as of 15:36, 21 September 2018

Paths and Folders

All files (e.g. functions or figures) and folders that are used in your experiment must be on the [Matlab search path].

Adding folders to the search path

At startup, BrainStream adds the BrainStream core folder and nearly all its subfolders to the search path. If you need additional files or folders, you must make sure they are added to the search path. It is possible to specify these folders in the block file under the keys MatlabPathFnc or MatlabPathAdd. Alternatively, you can use Matlab's [addpath] function to add individual folders. If you want to add a folder with all its subfolders, use addpath in combination with [genpath]:

addpath(pwd);          %adds the current working directory to the search path
addpath(genpath(pwd)); %adds the current working directory and all its subfolders to the search path 

It is often useful to write a user defined function that adds all necessary paths and execute this function at the start of the experiment (e.g. at the BS_INIT marker). For example, if the experiment needs access to functions that are located in the folder /Volumes/BCI/my_functions, you could make a function:

function event = add_folder(event)
addpath(fullfile('Volumes','BCI','my_functions')); % add my_functions folder to the Matlab search path

Then execute this function at the BS_INIT marker:

Actions Table
marker time
function
BS_INIT EVENT add_folder

Tip: Use the fullfile function

It is recommended to use Matlab's [fullfile] function when you specify a file or folder. This ensures that the proper folders will be added on computers with different operating systems, as different systems may use either '/' or '\' as a file separator.

Tip: Use relative path names

It is recommended to use relative path names when you specify a folder, whether it is in the blocksettings or in functions like addpath. This means that you specify the path name of the folder you want to add relative to a folder of which the location is already known. The advantage of using relative path names is that the proper folders will be added also if you work on a different computer.

In BrainStream, you can make use of the bs_folder function. For example, with input argument 'BLOCK', the output of this function is the path to the folder containing the block file of the experiment. If the block file is located in '/Volumes/BCI/my_bci/blockfile', and you want to add a folder which contains your functions and is located in '/Volumes/BCI/my_bci/functions', you can specify this folder like this:

functionfolder = fullfile(bs_folder('BLOCK'),..,'functions') % N.B. the '..' expression means going up one level

Output folders

BrainStream saves output in the folder specified in the block file under topic Files and key OutFolder.

The output folder contains:

subject folders: a separate folder is created for each new subject. The folder has the subject's name.

session folders: a separate folder is created for each session with the same subject. The folder's name is the date of the session (YYYYMMDD).

This folder contains the most recently saved version of user defined variables. This is the folder where BrainStream looks for variables when a 'load' statement is specified in the Actions table.

run folders: a separate runfolder is created for each block within the experiment. The name of the folder is the name of the block followed by _ and a number indicating how many times this block has been repeated. Each runfolder contains:

module folders: Each module stores its results in a separate folder named accordingly. Brain Stream always stores its result in the 'main' module.

log file: gives an overview of everything that happened during your experiment.

brainstream folder: contains copies of the user defined variables that have been saved with a 'save' statement in the Actions table.

expdefs folder: contains copies of the experiment definition tables and blocksettings.

raw_bdf folder: contains the raw EEG data.