This helper object saves information about the exact code that was run so that one has a record of how particular results were generated. This object gives several different methods for saving code in different files/memory configurations. The results are in a structure that has the name and path of the file being recorded, the text in the body of the file, the time when the file was last modified and the time when the log_code_object recorded the file This method inherits from the handle class so all logged files are persistently kept in the logged_code_structure as new files are added.
log_code_obj = log_code_object
This method logs the file that the called this method.
If file_name is a string, this method logs the file that is in file_names, or if files_names is a cell array of strings, this method logs all the files that are in the cell array.
This method logs all the files in the directory directory_name that have the pattern listed in file_pattern. For example, to log all the m-files in the current directory one would use the methods: log_code_obj.log_files_in_directory('./', '*.m')
This method logs all the functions that are in memory from a particular directory given in directory_name. This is particularly useful if there are a large number of files in a given directory but you only want to save the ones that were used by your code (see examples below).
To get the logged information one can call the following method (or just access the field logged_code_structure):
logged_code_structure = log_code_obj.return_logged_code_structure
The number of elements in logged_code_structure is equal to the number of files logged, and the structure has the following fields:
The name of the file that has been recorded.
The full path to the directory where the file has been recorded.
The text that is in the file.
The time when the file was last modified.
The time the file was logged (useful in case the file was changed after being logged).
We recommend calling the method log_code_obj.log_current_file in the beginning of any code you have the specifies what decoding object/parameters are used in a data analysis (that way if you change the code while the decoding analysis is running the original parameters will be recorded). If one wants to log which functions in the Neural Decoding Toolbox were used, one can then call the log_code_obj.log_functions_in_memory(path_to_toolbox) method to save all the functions that were used. For example:
1 2 3 4 5 6 7 8 9 10 11
% start of decoding scripts log_code_obj = log_code_object; log_code_obj.log_current_file; % log the script that is currently being run % create the decoding objects, run the decoding analysis with DECODING_RESULTS = cv.run_cv_decoding; log_code_obj.log_functions_in_memory(path_to_toolbox); % log the functions that were used in the NDT decoding_code_log = log_code_obj.logged_code_structure; save('my_results', 'DECODING_RESULTS', 'decoding_code_log');